summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-07-20 21:18:55 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-07-20 21:18:55 -0400
commitc3c525ab804dd11b97db8705143f4b4070c983ee (patch)
tree1bd8c5b7979a8aab2f931a45ef7094f3699b7f7b
parenta65235e41846e895b72e5bdaad2859e99113a4c8 (diff)
When an XMPP server has SRV records, try them, but don't then fall back to the regular host if they all fail.
gmail.com has some XMPP SRV records, but does not itself respond to XMPP traffic, although it does accept connections on port 5222. So if a user entered the wrong password, it would try all the SRVs and fall back to trying gmail, and hang at that point. This seems the right thing to do, not just a workaround.
-rw-r--r--Assistant/XMPP/Client.hs9
-rw-r--r--debian/changelog2
2 files changed, 8 insertions, 3 deletions
diff --git a/Assistant/XMPP/Client.hs b/Assistant/XMPP/Client.hs
index 960073036..677bb2ff3 100644
--- a/Assistant/XMPP/Client.hs
+++ b/Assistant/XMPP/Client.hs
@@ -34,17 +34,20 @@ connectXMPP c a = case parseJID (xmppJID c) of
{- Do a SRV lookup, but if it fails, fall back to the cached xmppHostname. -}
connectXMPP' :: JID -> XMPPCreds -> (JID -> XMPP a) -> IO [(HostPort, Either SomeException ())]
-connectXMPP' jid c a = reverse <$> (go [] =<< lookupSRV srvrecord)
+connectXMPP' jid c a = reverse <$> (handle =<< lookupSRV srvrecord)
where
srvrecord = mkSRVTcp "xmpp-client" $
T.unpack $ strDomain $ jidDomain jid
serverjid = JID Nothing (jidDomain jid) Nothing
- go l [] = do
+ handle [] = do
let h = xmppHostname c
let p = PortNumber $ fromIntegral $ xmppPort c
r <- run h p $ a jid
- return (r : l)
+ return [r]
+ handle srvs = go [] srvs
+
+ go l [] = return l
go l ((h,p):rest) = do
{- Try each SRV record in turn, until one connects,
- at which point the MVar will be full. -}
diff --git a/debian/changelog b/debian/changelog
index a0e4283e7..d78f1a599 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -28,6 +28,8 @@ git-annex (4.20130710) UNRELEASED; urgency=low
* Bug fix: Adding files that contained a tarball of a git-annex repository,
or other content in the first line that looks like a git-annex link,
could cause git-annex add to malfunction and lose the file content.
+ * When an XMPP server has SRV records, try them, but don't then fall
+ back to the regular host if they all fail.
-- Joey Hess <joeyh@debian.org> Tue, 09 Jul 2013 19:17:13 -0400