Permalink
Browse files

Doesn't fail if host has NO SRV record

Just catch an other exception type coming from the dns resolver that
could be raised with hosts like "anon.example.com" which just don't have
any SRV record.
  • Loading branch information...
1 parent 4fb77ac commit 9dbf246f0bfcac2c4ce538431ee629f126c86447 @louiz louiz committed with legastero Nov 8, 2010
Showing with 2 additions and 11 deletions.
  1. +0 −9 sleekxmpp/basexmpp.py
  2. +1 −1 sleekxmpp/clientxmpp.py
  3. +1 −1 sleekxmpp/componentxmpp.py
View
@@ -28,15 +28,6 @@
log = logging.getLogger(__name__)
-
-# Flag indicating if DNS SRV records are available for use.
-SRV_SUPPORT = True
-try:
- import dns.resolver
-except:
- SRV_SUPPORT = False
-
-
# In order to make sure that Unicode is handled properly
# in Python 2.x, reset the default encoding.
if sys.version_info < (3, 0):
View
@@ -164,7 +164,7 @@ def connect(self, address=tuple()):
try:
xmpp_srv = "_xmpp-client._tcp.%s" % self.server
answers = dns.resolver.query(xmpp_srv, dns.rdatatype.SRV)
- except dns.resolver.NXDOMAIN:
+ except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
log.debug("No appropriate SRV record found." + \
" Using JID server name.")
else:
@@ -15,7 +15,7 @@
from sleekxmpp import plugins
from sleekxmpp import stanza
-from sleekxmpp.basexmpp import BaseXMPP, SRV_SUPPORT
+from sleekxmpp.basexmpp import BaseXMPP
from sleekxmpp.xmlstream import XMLStream, RestartStream
from sleekxmpp.xmlstream import StanzaBase, ET
from sleekxmpp.xmlstream.matcher import *

0 comments on commit 9dbf246

Please sign in to comment.