diff options
author | joe <joe@jerkface.net> | 2018-05-27 17:17:18 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2018-05-27 17:17:18 -0400 |
commit | 14d245ee6b5d3f1e51d5455c2c1b055087b99485 (patch) | |
tree | 8d69fd30b7b457f926deb9dd2cc40087482bb104 /Presence | |
parent | 735fa5c892700efb78c7a9205b719f064ce429a6 (diff) |
Comments.
Diffstat (limited to 'Presence')
-rw-r--r-- | Presence/Presence.hs | 10 | ||||
-rw-r--r-- | Presence/XMPPServer.hs | 9 |
2 files changed, 17 insertions, 2 deletions
diff --git a/Presence/Presence.hs b/Presence/Presence.hs index f1bae255..41204818 100644 --- a/Presence/Presence.hs +++ b/Presence/Presence.hs | |||
@@ -502,6 +502,9 @@ peerKeyToResolvedName buds pk = do | |||
502 | return $ fromMaybe (peerKeyToText pk) (listToMaybe ns') | 502 | return $ fromMaybe (peerKeyToText pk) (listToMaybe ns') |
503 | 503 | ||
504 | 504 | ||
505 | -- Given a local address and an IP-address JID, we return True if the JID is | ||
506 | -- local, False otherwise. Additionally, a list of equivalent hostname JIDS | ||
507 | -- are returned. | ||
505 | multiplyJIDForClient :: SockAddr -> Text -> IO (Bool,[(Maybe Text,Text,Maybe Text)]) | 508 | multiplyJIDForClient :: SockAddr -> Text -> IO (Bool,[(Maybe Text,Text,Maybe Text)]) |
506 | multiplyJIDForClient laddr jid = do | 509 | multiplyJIDForClient laddr jid = do |
507 | let (n,h,r) = splitJID jid | 510 | let (n,h,r) = splitJID jid |
@@ -819,6 +822,8 @@ answerProbe state mto k chan = do | |||
819 | pstanza <- makePresenceStanza "jabber:server" (Just jid) Offline | 822 | pstanza <- makePresenceStanza "jabber:server" (Just jid) Offline |
820 | atomically $ writeTChan (connChan conn) pstanza | 823 | atomically $ writeTChan (connChan conn) pstanza |
821 | 824 | ||
825 | -- Send friend requests and remote presences stored in remotesByPeer to XMPP | ||
826 | -- clients. | ||
822 | sendCachedPresence :: PresenceState -> ConnectionKey -> IO () | 827 | sendCachedPresence :: PresenceState -> ConnectionKey -> IO () |
823 | sendCachedPresence state k = do | 828 | sendCachedPresence state k = do |
824 | forClient state k (return ()) $ \client -> do | 829 | forClient state k (return ()) $ \client -> do |
@@ -888,7 +893,9 @@ modifyRosterFile :: (Traversable t, MonadPlus t) => | |||
888 | -> t1) | 893 | -> t1) |
889 | -> Text -- user | 894 | -> Text -- user |
890 | -> Text -- profile | 895 | -> Text -- profile |
891 | -> Text -> [SockAddr] -> Bool -> t1 | 896 | -> Text |
897 | -> [SockAddr] -- If a JID reverse-resolves to this address, consider it same. | ||
898 | -> Bool -> t1 | ||
892 | modifyRosterFile doit whose profile to addrs bAdd = do | 899 | modifyRosterFile doit whose profile to addrs bAdd = do |
893 | let (mu,_,_) = splitJID to | 900 | let (mu,_,_) = splitJID to |
894 | cmp jid = runTraversableT $ do | 901 | cmp jid = runTraversableT $ do |
@@ -1058,6 +1065,7 @@ peerSubscriptionRequest state fail k stanza chan = do | |||
1058 | 1065 | ||
1059 | let from' = unsplitJID fromtup | 1066 | let from' = unsplitJID fromtup |
1060 | 1067 | ||
1068 | -- Update roster files (subscribe: add to pending, unsubscribe: remove from subscribers). | ||
1061 | already_pending <- | 1069 | already_pending <- |
1062 | if is_wanted then | 1070 | if is_wanted then |
1063 | addToRosterFile ConfigFiles.modifyPending u profile from' addrs | 1071 | addToRosterFile ConfigFiles.modifyPending u profile from' addrs |
diff --git a/Presence/XMPPServer.hs b/Presence/XMPPServer.hs index bcd75ee2..520242cf 100644 --- a/Presence/XMPPServer.hs +++ b/Presence/XMPPServer.hs | |||
@@ -267,6 +267,7 @@ addrToText (addr@(SockAddrInet6 _ _ _ _)) = Text.pack $ stripColon (show addr) | |||
267 | where | 267 | where |
268 | (pre,bracket) = break (==']') s | 268 | (pre,bracket) = break (==']') s |
269 | 269 | ||
270 | -- Shows (as Text) the IP address associated with the given ConnectionKey. | ||
270 | peerKeyToText :: ConnectionKey -> Text | 271 | peerKeyToText :: ConnectionKey -> Text |
271 | peerKeyToText (PeerKey { callBackAddress=addr }) = addrToText addr | 272 | peerKeyToText (PeerKey { callBackAddress=addr }) = addrToText addr |
272 | peerKeyToText (ClientKey { localAddress=addr }) = "ErrorClIeNt0" | 273 | peerKeyToText (ClientKey { localAddress=addr }) = "ErrorClIeNt0" |
@@ -462,6 +463,9 @@ sendModifiedStanzaToPeer stanza chan = do | |||
462 | processedType x = x | 463 | processedType x = x |
463 | 464 | ||
464 | 465 | ||
466 | -- Modifies a server-to-server stanza to send it to a client. This changes the | ||
467 | -- namespace and also filters some non-supported attributes. Any other | ||
468 | -- modifications need to be made by the caller. | ||
465 | sendModifiedStanzaToClient :: Stanza -> TChan Stanza -> IO () | 469 | sendModifiedStanzaToClient :: Stanza -> TChan Stanza -> IO () |
466 | sendModifiedStanzaToClient stanza chan = do | 470 | sendModifiedStanzaToClient stanza chan = do |
467 | (echan,clsrs,quitvar) <- conduitToChan c | 471 | (echan,clsrs,quitvar) <- conduitToChan c |
@@ -1181,7 +1185,10 @@ simulateChatError err mfrom = | |||
1181 | ] | 1185 | ] |
1182 | 1186 | ||
1183 | 1187 | ||
1184 | presenceSolicitation :: Text -> Text -> IO Stanza | 1188 | -- | Create a friend-request stanza. |
1189 | presenceSolicitation :: Text -- ^ JID of sender making request. | ||
1190 | -> Text -- ^ JID of recipient who needs to approve it. | ||
1191 | -> IO Stanza | ||
1185 | presenceSolicitation = presenceStanza (PresenceRequestSubscription True) "subscribe" | 1192 | presenceSolicitation = presenceStanza (PresenceRequestSubscription True) "subscribe" |
1186 | 1193 | ||
1187 | presenceProbe :: Text -> Text -> IO Stanza | 1194 | presenceProbe :: Text -> Text -> IO Stanza |