module Database.Blacktip.Types
( Config(..)
, Interface(..)
, ServerState(..)
, ArrowOfTimeError(..)
, NoInterfaceError(..)
, ParseError(..)
, IdentityRecord(..)
, InterfaceName
, Milliseconds
, Sequence
, UniqueId
, defaultConfig
)
where
import qualified Data.Int as DI
import qualified Filesystem.Path.CurrentOS as FPC
import qualified Network.Info as NI
import Control.DeepSeq
import GHC.Generics
type InterfaceName = String
data Interface = NIInterface NI.NetworkInterface
| IName InterfaceName
deriving Show
type Milliseconds = Int
type Sequence = DI.Int16
data Config =
Config { interface :: Interface
, timestampPath :: FPC.FilePath
, allowableDowntime :: Milliseconds }
deriving Show
defaultConfig :: Config
defaultConfig =
Config { interface = IName "eth0"
, timestampPath = FPC.decodeString "/tmp/blacktip-timestamp"
, allowableDowntime = 2592000000 }
data ServerState =
ServerState { ssTime :: Milliseconds
, ssSequence :: Sequence }
deriving Show
type UniqueId = Integer
data IdentityRecord =
IdentityRecord { identityTime :: Milliseconds
, identityMac :: NI.MAC
, identitySequence :: Sequence }
deriving (Eq, Ord, Show)
data ParseError = ParseError deriving Show
data ArrowOfTimeError = ArrowOfTimeError deriving Show
data NoInterfaceError = NoInterfaceError deriving (Eq, Generic, Ord, Show)
instance NFData NoInterfaceError
instance NFData NI.NetworkInterface