Browse Source

Merge branch 'master' of git://github.com/rnons/pontarius-xmpp

master
Philipp Balzarek 12 years ago
parent
commit
c5ec2e3c0a
  1. 3
      pontarius-xmpp.cabal
  2. 4
      source/Network/Xmpp/Lens.hs
  3. 10
      source/Network/Xmpp/Tls.hs
  4. 21
      source/Network/Xmpp/Types.hs

3
pontarius-xmpp.cabal

@ -65,8 +65,7 @@ Library
, stm >=2.1.2.1 , stm >=2.1.2.1
, stringprep >=1.0.0 , stringprep >=1.0.0
, text >=0.11.1.5 , text >=0.11.1.5
, tls >=1.1.3 , tls >=1.2
, tls-extra >=0.6.0
, transformers >=0.2.2.0 , transformers >=0.2.2.0
, unbounded-delays >=0.1 , unbounded-delays >=0.1
, void >=0.5.5 , void >=0.5.5

4
source/Network/Xmpp/Lens.hs

@ -105,7 +105,7 @@ import qualified Data.Text as Text
import Data.Text(Text) import Data.Text(Text)
import Data.XML.Types(Element) import Data.XML.Types(Element)
import Network.DNS(ResolvConf) import Network.DNS(ResolvConf)
import Network.TLS (TLSParams) import Network.TLS (ClientParams)
import Network.Xmpp.Concurrent.Types import Network.Xmpp.Concurrent.Types
import Network.Xmpp.IM.Roster.Types import Network.Xmpp.IM.Roster.Types
import Network.Xmpp.IM.Message import Network.Xmpp.IM.Message
@ -390,7 +390,7 @@ tlsBehaviourL :: Lens StreamConfiguration TlsBehaviour
tlsBehaviourL inj sc@StreamConfiguration{tlsBehaviour = x} tlsBehaviourL inj sc@StreamConfiguration{tlsBehaviour = x}
= (\x' -> sc{tlsBehaviour = x'}) <$> inj x = (\x' -> sc{tlsBehaviour = x'}) <$> inj x
tlsParamsL :: Lens StreamConfiguration TLSParams tlsParamsL :: Lens StreamConfiguration ClientParams
tlsParamsL inj sc@StreamConfiguration{tlsParams = x} tlsParamsL inj sc@StreamConfiguration{tlsParams = x}
= (\x' -> sc{tlsParams = x'}) <$> inj x = (\x' -> sc{tlsParams = x'}) <$> inj x

10
source/Network/Xmpp/Tls.hs

@ -107,12 +107,12 @@ tls con = fmap join -- We can have Left values both from exceptions and the
modify (\s -> s{streamConnectionState = Secured}) modify (\s -> s{streamConnectionState = Secured})
return () return ()
client :: (MonadIO m, CPRG rng) => Params -> rng -> Backend -> m Context client :: (MonadIO m, CPRG rng) => ClientParams -> rng -> Backend -> m Context
client params gen backend = do client params gen backend = do
contextNew backend params gen contextNew backend params gen
tlsinit :: (MonadIO m, MonadIO m1) => tlsinit :: (MonadIO m, MonadIO m1) =>
TLSParams ClientParams
-> Backend -> Backend
-> m ( Source m1 BS.ByteString -> m ( Source m1 BS.ByteString
, Sink BS.ByteString m1 () , Sink BS.ByteString m1 ()
@ -164,7 +164,7 @@ mkReadBuffer recv = do
-- seem to use it. -- seem to use it.
connectTls :: ResolvConf -- ^ Resolv conf to use (try 'defaultResolvConf' as a connectTls :: ResolvConf -- ^ Resolv conf to use (try 'defaultResolvConf' as a
-- default) -- default)
-> TLSParams -- ^ TLS parameters to use when securing the connection -> ClientParams -- ^ TLS parameters to use when securing the connection
-> String -- ^ Host to use when connecting (will be resolved -> String -- ^ Host to use when connecting (will be resolved
-- using SRV records) -- using SRV records)
-> ErrorT XmppFailure IO StreamHandle -> ErrorT XmppFailure IO StreamHandle
@ -184,9 +184,7 @@ wrapExceptions :: IO a -> IO (Either XmppFailure a)
wrapExceptions f = Ex.catches (liftM Right $ f) wrapExceptions f = Ex.catches (liftM Right $ f)
[ Ex.Handler $ return . Left . XmppIOException [ Ex.Handler $ return . Left . XmppIOException
, Ex.Handler $ wrap . XmppTlsError , Ex.Handler $ wrap . XmppTlsError
, Ex.Handler $ wrap . XmppTlsConnectionNotEstablished , Ex.Handler $ wrap . XmppTlsException
, Ex.Handler $ wrap . XmppTlsTerminated
, Ex.Handler $ wrap . XmppTlsHandshakeFailed
, Ex.Handler $ return . Left , Ex.Handler $ return . Left
] ]
where where

21
source/Network/Xmpp/Types.hs

@ -544,9 +544,7 @@ data StreamErrorInfo = StreamErrorInfo
} deriving (Show, Eq) } deriving (Show, Eq)
data XmppTlsError = XmppTlsError TLSError data XmppTlsError = XmppTlsError TLSError
| XmppTlsConnectionNotEstablished ConnectionNotEstablished | XmppTlsException TLSException
| XmppTlsTerminated Terminated
| XmppTlsHandshakeFailed HandshakeFailed
deriving (Show, Eq, Typeable) deriving (Show, Eq, Typeable)
-- | Signals an XMPP stream error or another unpredicted stream-related -- | Signals an XMPP stream error or another unpredicted stream-related
@ -1191,16 +1189,19 @@ data StreamConfiguration =
-- | How the client should behave in regards to TLS. -- | How the client should behave in regards to TLS.
, tlsBehaviour :: TlsBehaviour , tlsBehaviour :: TlsBehaviour
-- | Settings to be used for TLS negotitation -- | Settings to be used for TLS negotitation
, tlsParams :: TLSParams , tlsParams :: ClientParams
} }
-- | Default parameters for TLS. Those are the default client parameters from the tls package with the ciphers set to ciphersuite_strong -- | Default parameters for TLS. Those are the default client parameters from the tls package with the ciphers set to ciphersuite_strong
xmppDefaultParams :: Params xmppDefaultParams :: ClientParams
xmppDefaultParams = defaultParamsClient{ pCiphers = ciphersuite_strong xmppDefaultParams = (defaultParamsClient "" BS.empty)
++ [ cipher_AES256_SHA1 { clientSupported = def
, cipher_AES128_SHA1 { supportedCiphers = ciphersuite_strong
] ++ [ cipher_AES256_SHA1
} , cipher_AES128_SHA1
]
}
}
instance Default StreamConfiguration where instance Default StreamConfiguration where
def = StreamConfiguration { preferredLang = Nothing def = StreamConfiguration { preferredLang = Nothing

Loading…
Cancel
Save