module Network.TLS.Hooks
( Logging(..)
, Hooks(..)
, defaultHooks
) where
import qualified Data.ByteString as B
import Network.TLS.Struct (Header, Handshake)
import Network.TLS.Struct13 (Handshake13)
import Network.TLS.X509 (CertificateChain)
import Data.Default.Class
data Logging = Logging
{ loggingPacketSent :: String -> IO ()
, loggingPacketRecv :: String -> IO ()
, loggingIOSent :: B.ByteString -> IO ()
, loggingIORecv :: Header -> B.ByteString -> IO ()
}
defaultLogging :: Logging
defaultLogging = Logging
{ loggingPacketSent = \_ -> return ()
, loggingPacketRecv = \_ -> return ()
, loggingIOSent = \_ -> return ()
, loggingIORecv = \_ _ -> return ()
}
instance Default Logging where
def = defaultLogging
data Hooks = Hooks
{
hookRecvHandshake :: Handshake -> IO Handshake
, hookRecvHandshake13 :: Handshake13 -> IO Handshake13
, hookRecvCertificates :: CertificateChain -> IO ()
, hookLogging :: Logging
}
defaultHooks :: Hooks
defaultHooks = Hooks
{ hookRecvHandshake = return
, hookRecvHandshake13 = return
, hookRecvCertificates = return . const ()
, hookLogging = def
}
instance Default Hooks where
def = defaultHooks