summaryrefslogtreecommitdiff
path: root/Presence/XMPPServer.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Presence/XMPPServer.hs')
-rw-r--r--Presence/XMPPServer.hs24
1 files changed, 13 insertions, 11 deletions
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs
index 2e3c0a37..362cc8a8 100644
--- a/Presence/XMPPServer.hs
+++ b/Presence/XMPPServer.hs
@@ -49,7 +49,7 @@ import Control.Monad
49import Control.Concurrent (forkIO) 49import Control.Concurrent (forkIO)
50import Control.Concurrent.STM 50import Control.Concurrent.STM
51-- import Control.Concurrent.STM.TChan 51-- import Control.Concurrent.STM.TChan
52import Network.Socket 52import Network.SocketLike
53import Text.Printf 53import Text.Printf
54import System.Posix.Signals 54import System.Posix.Signals
55import Data.ByteString (ByteString) 55import Data.ByteString (ByteString)
@@ -873,7 +873,7 @@ makePong namespace mid to from =
873 ] 873 ]
874 874
875 875
876xmppInbound :: Server ConnectionKey SockAddr 876xmppInbound :: Server ConnectionKey SockAddr ReleaseKey
877 -> XMPPServerParameters 877 -> XMPPServerParameters
878 -> ConnectionKey 878 -> ConnectionKey
879 -> SockAddr 879 -> SockAddr
@@ -1175,7 +1175,7 @@ presenceStanza stanza_type type_attr me jid =
1175 ] 1175 ]
1176 , EventEndElement "{jabber:server}presence" ] 1176 , EventEndElement "{jabber:server}presence" ]
1177 1177
1178forkConnection :: Server ConnectionKey SockAddr 1178forkConnection :: Server ConnectionKey SockAddr ReleaseKey
1179 -> XMPPServerParameters 1179 -> XMPPServerParameters
1180 -> ConnectionKey 1180 -> ConnectionKey
1181 -> SockAddr 1181 -> SockAddr
@@ -1355,8 +1355,9 @@ data PeerState
1355 | PeerConnected (TChan Stanza) 1355 | PeerConnected (TChan Stanza)
1356-} 1356-}
1357 1357
1358peerKey :: (Socket,SockAddr) -> IO (ConnectionKey,SockAddr) 1358peerKey :: SocketLike sock => sock -> IO (ConnectionKey,SockAddr)
1359peerKey (sock,addr) = do 1359peerKey sock = do
1360 addr <- getSocketName sock
1360 peer <- 1361 peer <-
1361 sIsConnected sock >>= \c -> 1362 sIsConnected sock >>= \c ->
1362 if c then getPeerName sock -- addr is normally socketName 1363 if c then getPeerName sock -- addr is normally socketName
@@ -1364,8 +1365,9 @@ peerKey (sock,addr) = do
1364 laddr <- getSocketName sock 1365 laddr <- getSocketName sock
1365 return $ (PeerKey (peer `withPort` fromIntegral peerport),laddr) 1366 return $ (PeerKey (peer `withPort` fromIntegral peerport),laddr)
1366 1367
1367clientKey :: (Socket,SockAddr) -> IO (ConnectionKey,SockAddr) 1368clientKey :: SocketLike sock => sock -> IO (ConnectionKey,SockAddr)
1368clientKey (sock,addr) = do 1369clientKey sock = do
1370 addr <- getSocketName sock
1369 paddr <- getPeerName sock 1371 paddr <- getPeerName sock
1370 return $ (ClientKey addr,paddr) 1372 return $ (ClientKey addr,paddr)
1371 1373
@@ -1435,7 +1437,7 @@ sendRoster query xmpp replyto = do
1435 -} 1437 -}
1436 1438
1437 1439
1438socketFromKey :: Server ConnectionKey SockAddr -> ConnectionKey -> IO SockAddr 1440socketFromKey :: Server ConnectionKey SockAddr ReleaseKey -> ConnectionKey -> IO SockAddr
1439socketFromKey sv k = do 1441socketFromKey sv k = do
1440 map <- atomically $ readTVar (conmap sv) 1442 map <- atomically $ readTVar (conmap sv)
1441 let mcd = Map.lookup k map 1443 let mcd = Map.lookup k map
@@ -1605,7 +1607,7 @@ makeErrorStanza stanza = do
1605 ] 1607 ]
1606 1608
1607monitor :: 1609monitor ::
1608 Server ConnectionKey SockAddr 1610 Server ConnectionKey SockAddr ReleaseKey
1609 -> ConnectionParameters ConnectionKey SockAddr 1611 -> ConnectionParameters ConnectionKey SockAddr
1610 -> XMPPServerParameters 1612 -> XMPPServerParameters
1611 -> IO b 1613 -> IO b
@@ -1773,7 +1775,7 @@ monitor sv params xmpp = do
1773 _ = str :: String 1775 _ = str :: String
1774 1776
1775data XMPPServer 1777data XMPPServer
1776 = XMPPServer { _xmpp_sv :: Server ConnectionKey SockAddr 1778 = XMPPServer { _xmpp_sv :: Server ConnectionKey SockAddr ReleaseKey
1777 , _xmpp_peer_params :: ConnectionParameters ConnectionKey SockAddr 1779 , _xmpp_peer_params :: ConnectionParameters ConnectionKey SockAddr
1778 } 1780 }
1779 1781
@@ -1785,7 +1787,7 @@ xmppServer :: ( MonadResource m
1785 , MonadIO m 1787 , MonadIO m
1786 ) => XMPPServerParameters -> m XMPPServer 1788 ) => XMPPServerParameters -> m XMPPServer
1787xmppServer xmpp = do 1789xmppServer xmpp = do
1788 sv <- server 1790 sv <- server allocate
1789 -- some fuzz helps avoid simultaneity 1791 -- some fuzz helps avoid simultaneity
1790 pingfuzz <- liftIO $ do 1792 pingfuzz <- liftIO $ do
1791 gen <- System.Random.getStdGen 1793 gen <- System.Random.getStdGen