Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Pythia.Services.NetInterface
Description
This module exports interface related services.
Since: 0.1
Synopsis
- queryNetInterfaces :: (MonadPathReader m, MonadThrow m, MonadTypedProcess m) => NetInterfaceApp -> m NetInterfaces
- queryNetInterface :: (MonadPathReader m, MonadThrow m, MonadTypedProcess m) => Device -> NetInterfaceApp -> m NetInterface
- findUp :: NetInterfaces -> Maybe NetInterface
- newtype NetInterfaces = MkNetInterfaces {}
- data NetInterface = MkNetInterface {}
- data NetInterfaceState
- data NetInterfaceType
- newtype Device = MkDevice {}
- data IpType
- newtype IpAddress a = MkIpAddress {
- unIpAddress :: Refined (IpRefinement a) Text
- data NetInterfaceApp
Queries
queryNetInterfaces :: (MonadPathReader m, MonadThrow m, MonadTypedProcess m) => NetInterfaceApp -> m NetInterfaces Source #
Queries for all network interface data.
Since: 0.1
queryNetInterface :: (MonadPathReader m, MonadThrow m, MonadTypedProcess m) => Device -> NetInterfaceApp -> m NetInterface Source #
Like queryNetInterfaces
but returns data for a single device.
Since: 0.1
Functions
findUp :: NetInterfaces -> Maybe NetInterface Source #
Takes the first NetInterface
that has state NetStateUp
, according to
NetInterfaceState
's Ord
:
Ethernet
<Wifi
<Wifi_P2P
<Loopback
<Tun
Examples
>>>
findUp $ MkNetInterfaces []
Nothing
>>>
:{
let wifiUp = MkNetInterface "" (Just Wifi) NetStateUp (Just "WifiUp") mempty mempty wifiNetStateDown = MkNetInterface "" (Just Wifi) NetStateDown (Just "WifiNetStateDown") mempty mempty loopUp = MkNetInterface "" (Just Loopback) NetStateUp (Just "LoopUp") mempty mempty in findUp $ MkNetInterfaces [loopUp, wifiNetStateDown, wifiUp] :} Just (MkNetInterface {device = MkDevice {unDevice = ""}, ntype = Just Wifi, state = NetStateUp, name = Just "WifiUp", ipv4s = MkIpAddresses {unIpAddresses = []}, ipv6s = MkIpAddresses {unIpAddresses = []}})
Since: 0.1
Types
newtype NetInterfaces Source #
Since: 0.1
Constructors
MkNetInterfaces | |
Fields |
Instances
data NetInterface Source #
Full connection data.
Since: 0.1
Constructors
MkNetInterface | |
Fields
|
Instances
data NetInterfaceState Source #
Various connection states.
Since: 0.1
Constructors
NetStateUp | Since: 0.1 |
NetStateDown | Since: 0.1 |
NetStateUnknown Text | Since: 0.1 |
Instances
data NetInterfaceType Source #
Various connection types.
Since: 0.1
Instances
Newtype wrapper over a network device name.
Since: 0.1
Instances
IsString Device Source # | Since: 0.1 |
Defined in Pythia.Services.Types.Network Methods fromString :: String -> Device # | |
Generic Device Source # | |
Read Device Source # | Since: 0.1 |
Show Device Source # | Since: 0.1 |
NFData Device Source # | Since: 0.1 |
Defined in Pythia.Services.Types.Network | |
Eq Device Source # | Since: 0.1 |
Ord Device Source # | Since: 0.1 |
Display Device Source # | Since: 0.1 |
Defined in Pythia.Services.Types.Network | |
(k ~ An_Iso, a ~ Text, b ~ Text) => LabelOptic "unDevice" k Device Device a b Source # | Since: 0.1 |
Defined in Pythia.Services.Types.Network | |
type Rep Device Source # | Since: 0.1 |
Defined in Pythia.Services.Types.Network |
IP types.
Since: 0.1
Type for an IP address. The type family IpRefinement
refines the
underlying Text
according to the spec.
Ipv4
: All characters are digits or dots, and the length is0 < l < 16
.Ipv6
: All characters are hex digits or colons, and the length is0 < l < 40
.
Since: 0.1
Constructors
MkIpAddress | |
Fields
|
Instances
(k ~ An_Iso, a ~ Refined (IpRefinement s) Text, b ~ Refined (IpRefinement s) Text) => LabelOptic "unIpAddress" k (IpAddress s) (IpAddress s) a b Source # | Since: 0.1 |
Defined in Pythia.Services.Types.Network | |
Generic (IpAddress a) Source # | |
Show (IpAddress a) Source # | Since: 0.1 |
NFData (IpAddress a) Source # | Since: 0.1 |
Defined in Pythia.Services.Types.Network | |
Eq (IpAddress a) Source # | Since: 0.1 |
Ord (IpAddress a) Source # | Since: 0.1 |
Defined in Pythia.Services.Types.Network | |
Display (IpAddress a) Source # | Since: 0.1 |
Defined in Pythia.Services.Types.Network | |
type Rep (IpAddress a) Source # | Since: 0.1 |
Defined in Pythia.Services.Types.Network type Rep (IpAddress a) = D1 ('MetaData "IpAddress" "Pythia.Services.Types.Network" "pythia-0.1-inplace" 'True) (C1 ('MetaCons "MkIpAddress" 'PrefixI 'True) (S1 ('MetaSel ('Just "unIpAddress") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Refined (IpRefinement a) Text)))) |
Configuration
data NetInterfaceApp Source #
Determines how we should query the system for interface state information.
Since: 0.1
Constructors
NetInterfaceAppNmCli | Uses the Network Manager cli utility. Since: 0.1 |
NetInterfaceAppIp | Uses the 'ip' utility. Since: 0.1 |