M lib/Network/Protocol/XMPP.hs => lib/Network/Protocol/XMPP.hs +1 -0
@@ 62,6 62,7 @@ module Network.Protocol.XMPP
-- ** Resuming sessions
, Session
, getSession
+ , sessionIsSecure
, runXMPP
) where
M lib/Network/Protocol/XMPP/Handle.hs => lib/Network/Protocol/XMPP/Handle.hs +5 -0
@@ 20,6 20,7 @@ module Network.Protocol.XMPP.Handle
, startTLS
, hPutBytes
, hGetBytes
+ , handleIsSecure
) where
import Control.Monad (when)
@@ 69,3 70,7 @@ hGetBytes (SecureHandle h s) n = liftTLS s $ do
when (pending == 0) (liftIO wait)
lazy <- TLS.getBytes n
return (Data.ByteString.concat (Data.ByteString.Lazy.toChunks lazy))
+
+handleIsSecure :: Handle -> Bool
+handleIsSecure PlainHandle{} = False
+handleIsSecure SecureHandle{} = True
M lib/Network/Protocol/XMPP/Monad.hs => lib/Network/Protocol/XMPP/Monad.hs +6 -0
@@ 26,6 26,7 @@ module Network.Protocol.XMPP.Monad
, getHandle
, getSession
+ , sessionIsSecure
, readEvents
, getElement
@@ 140,6 141,11 @@ getSession = XMPP R.ask
getHandle :: XMPP H.Handle
getHandle = fmap sessionHandle getSession
+sessionIsSecure :: XMPP Bool
+sessionIsSecure = do
+ h <- getHandle
+ return (H.handleIsSecure h)
+
liftTLS :: ErrorT Text IO a -> XMPP a
liftTLS io = do
res <- liftIO (runErrorT io)