|
|
|
@ -47,6 +47,7 @@ module Network.Xmpp.Types |
|
|
|
, Hostname(..) |
|
|
|
, Hostname(..) |
|
|
|
, hostname |
|
|
|
, hostname |
|
|
|
, SessionConfiguration(..) |
|
|
|
, SessionConfiguration(..) |
|
|
|
|
|
|
|
, TlsBehaviour(..) |
|
|
|
) |
|
|
|
) |
|
|
|
where |
|
|
|
where |
|
|
|
|
|
|
|
|
|
|
|
@ -67,7 +68,8 @@ import qualified Data.Text as Text |
|
|
|
import Data.Typeable(Typeable) |
|
|
|
import Data.Typeable(Typeable) |
|
|
|
import Data.XML.Types |
|
|
|
import Data.XML.Types |
|
|
|
|
|
|
|
|
|
|
|
import qualified Network.TLS as TLS |
|
|
|
import Network.TLS hiding (Version) |
|
|
|
|
|
|
|
import Network.TLS.Extra |
|
|
|
|
|
|
|
|
|
|
|
import qualified Network as N |
|
|
|
import qualified Network as N |
|
|
|
|
|
|
|
|
|
|
|
@ -666,7 +668,7 @@ data XmppFailure = StreamErrorFailure StreamErrorInfo -- ^ An error XML stream |
|
|
|
-- failed. |
|
|
|
-- failed. |
|
|
|
| XmppIllegalTcpDetails -- ^ The TCP details provided did not |
|
|
|
| XmppIllegalTcpDetails -- ^ The TCP details provided did not |
|
|
|
-- validate. |
|
|
|
-- validate. |
|
|
|
| TlsError TLS.TLSError -- ^ An error occurred in the |
|
|
|
| TlsError TLSError -- ^ An error occurred in the |
|
|
|
-- TLS layer |
|
|
|
-- TLS layer |
|
|
|
| TlsNoServerSupport -- ^ The server does not support |
|
|
|
| TlsNoServerSupport -- ^ The server does not support |
|
|
|
-- the use of TLS |
|
|
|
-- the use of TLS |
|
|
|
@ -1042,6 +1044,8 @@ data StreamConfiguration = |
|
|
|
-- session bind as defined in the (outdated) |
|
|
|
-- session bind as defined in the (outdated) |
|
|
|
-- RFC 3921 specification |
|
|
|
-- RFC 3921 specification |
|
|
|
, establishSession :: Bool |
|
|
|
, establishSession :: Bool |
|
|
|
|
|
|
|
-- | Settings to be used for TLS negotitation |
|
|
|
|
|
|
|
, tlsParams :: TLSParams |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1051,6 +1055,10 @@ instance Default StreamConfiguration where |
|
|
|
, socketDetails = Nothing |
|
|
|
, socketDetails = Nothing |
|
|
|
, resolvConf = defaultResolvConf |
|
|
|
, resolvConf = defaultResolvConf |
|
|
|
, establishSession = False |
|
|
|
, establishSession = False |
|
|
|
|
|
|
|
, tlsParams = defaultParamsClient { pConnectVersion = TLS12 |
|
|
|
|
|
|
|
, pAllowedVersions = [TLS12] |
|
|
|
|
|
|
|
, pCiphers = ciphersuite_strong |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
data Hostname = Hostname Text deriving (Eq, Show) |
|
|
|
data Hostname = Hostname Text deriving (Eq, Show) |
|
|
|
@ -1095,7 +1103,10 @@ data SessionConfiguration = SessionConfiguration |
|
|
|
sessionStreamConfiguration :: StreamConfiguration |
|
|
|
sessionStreamConfiguration :: StreamConfiguration |
|
|
|
-- | Handler to be run when the session ends (for whatever reason). |
|
|
|
-- | Handler to be run when the session ends (for whatever reason). |
|
|
|
, sessionClosedHandler :: XmppFailure -> IO () |
|
|
|
, sessionClosedHandler :: XmppFailure -> IO () |
|
|
|
|
|
|
|
-- | Function to generate the stream of stanza identifiers. |
|
|
|
, sessionStanzaIDs :: IO StanzaID |
|
|
|
, sessionStanzaIDs :: IO StanzaID |
|
|
|
|
|
|
|
-- | How the client should behave in regards to TLS. |
|
|
|
|
|
|
|
, sessionTlsBehaviour :: TlsBehaviour |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
instance Default SessionConfiguration where |
|
|
|
instance Default SessionConfiguration where |
|
|
|
@ -1106,4 +1117,11 @@ instance Default SessionConfiguration where |
|
|
|
atomically $ do |
|
|
|
atomically $ do |
|
|
|
curId <- readTVar idRef |
|
|
|
curId <- readTVar idRef |
|
|
|
writeTVar idRef (curId + 1 :: Integer) |
|
|
|
writeTVar idRef (curId + 1 :: Integer) |
|
|
|
return . read. show $ curId} |
|
|
|
return . read. show $ curId |
|
|
|
|
|
|
|
, sessionTlsBehaviour = PreferTls } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- | How the client should behave in regards to TLS. |
|
|
|
|
|
|
|
data TlsBehaviour = RequireTls -- ^ Require the use of TLS; disconnect if it's |
|
|
|
|
|
|
|
-- not offered. |
|
|
|
|
|
|
|
| PreferTls -- ^ Negotitate TLS if it's available. |
|
|
|
|
|
|
|
| RefuseTls -- ^ Never secure the stream with TLS. |
|
|
|
|