diff options
Diffstat (limited to 'Presence/Presence.hs')
-rw-r--r-- | Presence/Presence.hs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/Presence/Presence.hs b/Presence/Presence.hs index 678a5c99..daa93716 100644 --- a/Presence/Presence.hs +++ b/Presence/Presence.hs | |||
@@ -369,7 +369,7 @@ rosterGetSubscribers :: PresenceState -> ConnectionKey -> IO [Text] | |||
369 | rosterGetSubscribers = rosterGetStuff ConfigFiles.getSubscribers | 369 | rosterGetSubscribers = rosterGetStuff ConfigFiles.getSubscribers |
370 | 370 | ||
371 | data Conn = Conn { connChan :: TChan Stanza | 371 | data Conn = Conn { connChan :: TChan Stanza |
372 | , auxAddr :: SockAddr } | 372 | , auxData :: ConnectionData } |
373 | 373 | ||
374 | -- Read config file as Text content rather than UTF8 bytestrings. | 374 | -- Read config file as Text content rather than UTF8 bytestrings. |
375 | configText :: Functor f => | 375 | configText :: Functor f => |
@@ -448,13 +448,13 @@ sendProbesAndSolicitations state k laddr chan = do | |||
448 | atomically $ writeTChan chan stanza | 448 | atomically $ writeTChan chan stanza |
449 | -- reverse xs `seq` return () | 449 | -- reverse xs `seq` return () |
450 | 450 | ||
451 | newConn :: PresenceState -> ConnectionKey -> SockAddr -> TChan Stanza -> IO () | 451 | newConn :: PresenceState -> ConnectionKey -> ConnectionData -> TChan Stanza -> IO () |
452 | newConn state k addr outchan = do | 452 | newConn state k cdta outchan = do |
453 | atomically $ modifyTVar' (keyToChan state) | 453 | atomically $ modifyTVar' (keyToChan state) |
454 | $ Map.insert k Conn { connChan = outchan | 454 | $ Map.insert k Conn { connChan = outchan |
455 | , auxAddr = addr } | 455 | , auxData = cdta } |
456 | when (isPeerKey k) | 456 | when (isPeerKey k) |
457 | $ sendProbesAndSolicitations state k addr outchan | 457 | $ sendProbesAndSolicitations state k (cdAddr cdta) outchan |
458 | 458 | ||
459 | delclient :: (Alternative m, Monad m) => | 459 | delclient :: (Alternative m, Monad m) => |
460 | ConnectionKey -> m LocalPresence -> m LocalPresence | 460 | ConnectionKey -> m LocalPresence -> m LocalPresence |
@@ -582,8 +582,8 @@ deliverMessage state fail msg = | |||
582 | fromMaybe fail {- reverse lookup failure -} $ mto <&> \(to',addr) -> do | 582 | fromMaybe fail {- reverse lookup failure -} $ mto <&> \(to',addr) -> do |
583 | let k = PeerKey addr | 583 | let k = PeerKey addr |
584 | chans <- atomically $ readTVar (keyToChan state) | 584 | chans <- atomically $ readTVar (keyToChan state) |
585 | fromMaybe fail $ (Map.lookup k chans) <&> \(Conn { connChan=chan | 585 | fromMaybe fail $ (Map.lookup k chans) <&> \(Conn { connChan = chan |
586 | , auxAddr=laddr }) -> do | 586 | , auxData = ConnectionData laddr ctyp }) -> do |
587 | (n,r) <- forClient state senderk (return (Nothing,Nothing)) | 587 | (n,r) <- forClient state senderk (return (Nothing,Nothing)) |
588 | $ \c -> return (Just (clientUser c), Just (clientResource c)) | 588 | $ \c -> return (Just (clientUser c), Just (clientResource c)) |
589 | -- original 'from' address is discarded. | 589 | -- original 'from' address is discarded. |
@@ -594,8 +594,8 @@ deliverMessage state fail msg = | |||
594 | NetworkOrigin senderk@(PeerKey {}) _ -> do | 594 | NetworkOrigin senderk@(PeerKey {}) _ -> do |
595 | key_to_chan <- atomically $ readTVar (keyToChan state) | 595 | key_to_chan <- atomically $ readTVar (keyToChan state) |
596 | fromMaybe fail $ (Map.lookup senderk key_to_chan) | 596 | fromMaybe fail $ (Map.lookup senderk key_to_chan) |
597 | <&> \(Conn { connChan=sender_chan | 597 | <&> \(Conn { connChan = sender_chan |
598 | , auxAddr=laddr }) -> do | 598 | , auxData = ConnectionData laddr ctyp }) -> do |
599 | fromMaybe fail $ (stanzaTo msg) <&> \to -> do | 599 | fromMaybe fail $ (stanzaTo msg) <&> \to -> do |
600 | (mine,(n,h,r)) <- rewriteJIDForClient laddr to [] | 600 | (mine,(n,h,r)) <- rewriteJIDForClient laddr to [] |
601 | if not mine then fail else do | 601 | if not mine then fail else do |
@@ -669,7 +669,7 @@ subscribedPeers user profile = do | |||
669 | -- | this JID is suitable for peers, not clients. | 669 | -- | this JID is suitable for peers, not clients. |
670 | clientJID :: Conn -> ClientState -> Text | 670 | clientJID :: Conn -> ClientState -> Text |
671 | clientJID con client = unsplitJID ( Just $ clientUser client | 671 | clientJID con client = unsplitJID ( Just $ clientUser client |
672 | , addrToText $ auxAddr con | 672 | , addrToText $ cdAddr $ auxData con |
673 | , Just $ clientResource client) | 673 | , Just $ clientResource client) |
674 | 674 | ||
675 | -- | Send presence notification to subscribed peers. | 675 | -- | Send presence notification to subscribed peers. |
@@ -790,9 +790,9 @@ answerProbe state mto k chan = do | |||
790 | conn <- liftT $ Map.lookup k ktc | 790 | conn <- liftT $ Map.lookup k ktc |
791 | let (mu,h,_) = splitJID to -- TODO: currently resource-id is ignored on presence | 791 | let (mu,h,_) = splitJID to -- TODO: currently resource-id is ignored on presence |
792 | -- probes. Is this correct? Check the spec. | 792 | -- probes. Is this correct? Check the spec. |
793 | liftMT $ guardPortStrippedAddress h (auxAddr conn) | 793 | liftMT $ guardPortStrippedAddress h (cdAddr $ auxData conn) |
794 | u <- liftT mu | 794 | u <- liftT mu |
795 | let ch = addrToText (auxAddr conn) | 795 | let ch = addrToText (cdAddr $ auxData conn) |
796 | profile = fromMaybe "." $ clientProfile <$> Map.lookup k cmap | 796 | profile = fromMaybe "." $ clientProfile <$> Map.lookup k cmap |
797 | return (u,profile,conn,ch) | 797 | return (u,profile,conn,ch) |
798 | 798 | ||
@@ -1004,7 +1004,7 @@ clientSubscriptionRequest state fail k stanza chan = do | |||
1004 | -- if already connected, send solicitation ... | 1004 | -- if already connected, send solicitation ... |
1005 | -- let from = clientJID con client | 1005 | -- let from = clientJID con client |
1006 | let from = unsplitJID ( Just $ clientUser client | 1006 | let from = unsplitJID ( Just $ clientUser client |
1007 | , addrToText $ auxAddr con | 1007 | , addrToText $ cdAddr $ auxData con |
1008 | , Nothing ) | 1008 | , Nothing ) |
1009 | mb <- rewriteJIDForPeer to | 1009 | mb <- rewriteJIDForPeer to |
1010 | forM_ mb $ \(to',addr) -> do | 1010 | forM_ mb $ \(to',addr) -> do |
@@ -1061,7 +1061,7 @@ peerSubscriptionRequest state fail k stanza chan = do | |||
1061 | (ktc,cmap) <- atomically $ (,) <$> readTVar (keyToChan state) | 1061 | (ktc,cmap) <- atomically $ (,) <$> readTVar (keyToChan state) |
1062 | <*> readTVar (clients state) | 1062 | <*> readTVar (clients state) |
1063 | fromMaybe fail $ (Map.lookup k ktc) | 1063 | fromMaybe fail $ (Map.lookup k ktc) |
1064 | <&> \Conn { auxAddr=laddr } -> do | 1064 | <&> \Conn { auxData=ConnectionData laddr ctyp } -> do |
1065 | (mine,totup) <- rewriteJIDForClient laddr to [] | 1065 | (mine,totup) <- rewriteJIDForClient laddr to [] |
1066 | if not mine then fail else do | 1066 | if not mine then fail else do |
1067 | (_,fromtup) <- rewriteJIDForClient laddr from [] | 1067 | (_,fromtup) <- rewriteJIDForClient laddr from [] |
@@ -1205,7 +1205,7 @@ peerInformSubscription state fail k stanza = do | |||
1205 | <*> readTVar (clients state) | 1205 | <*> readTVar (clients state) |
1206 | fromMaybe fail $ (Map.lookup k ktc) | 1206 | fromMaybe fail $ (Map.lookup k ktc) |
1207 | <&> \(Conn { connChan=sender_chan | 1207 | <&> \(Conn { connChan=sender_chan |
1208 | , auxAddr=laddr }) -> do | 1208 | , auxData =ConnectionData laddr ctyp }) -> do |
1209 | (_,(from_u,from_h,_)) <- rewriteJIDForClient laddr from [] | 1209 | (_,(from_u,from_h,_)) <- rewriteJIDForClient laddr from [] |
1210 | let from'' = unsplitJID (from_u,from_h,Nothing) | 1210 | let from'' = unsplitJID (from_u,from_h,Nothing) |
1211 | muser = do | 1211 | muser = do |