packages feed

iptadmin-1.2.0: src/IptAdmin/Types.hs

module IptAdmin.Types where

import Control.Monad.Error
import Control.Monad.State
import Data.IORef
import Data.Map
import Data.Time
import Happstack.Server.SimpleHTTP
import Iptables.Types

-- | Authorization monad
type IptAdminAuth = ServerPartT (ErrorT String IO)

-- | Main request handler monad
type IptAdmin = ServerPartT (ErrorT String (StateT MainState IO))

type SessionId = String

type Sessions = Map SessionId Session

data Session = Session { lastVisit :: UTCTime
                       , backup :: Maybe String
                       , sIptables :: Iptables
                       }
                       deriving (Show)

type MainState = (SessionId, IORef Sessions, IptAdminConfig)

data IptAdminConfig = IptAdminConfig { cSaveCommand :: String
                                     , cPort :: Int
                                     , cPamName :: String
                                     }

-- | Display bytes or packets on show page
data CountersType = CTBytes
                  | CTPackets