revert last srv commit so svn is usable
This commit is contained in:
parent
310baa5234
commit
3200801bc7
|
@ -33,13 +33,9 @@ from client import PlugIn
|
||||||
from protocol import *
|
from protocol import *
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import DNS, random
|
import dns.resolver
|
||||||
DNS.ParseResolvConf()
|
|
||||||
HAVE_DNS = True
|
|
||||||
except:
|
except:
|
||||||
HAVE_DNS = False
|
pass
|
||||||
self.DEBUG("Warning: cannot perform SRV queries because 'dns' module is unavailable", 'warn')
|
|
||||||
|
|
||||||
|
|
||||||
DATA_RECEIVED='DATA RECEIVED'
|
DATA_RECEIVED='DATA RECEIVED'
|
||||||
DATA_SENT='DATA SENT'
|
DATA_SENT='DATA SENT'
|
||||||
|
@ -64,23 +60,19 @@ class TCPsocket(PlugIn):
|
||||||
self._exported_methods=[self.send,self.disconnect]
|
self._exported_methods=[self.send,self.disconnect]
|
||||||
|
|
||||||
# SRV resolver
|
# SRV resolver
|
||||||
if HAVE_DNS : # if dnspython is available support SRV
|
if 'dns' in globals(): # if dnspython is available support SRV
|
||||||
host, port = server
|
host, port = server
|
||||||
possible_queries = ['_xmpp-client._tcp.' + host]
|
possible_queries = ['_xmpp-client._tcp.' + host]
|
||||||
|
|
||||||
dnsrequest = DNS.Request()
|
|
||||||
for query in possible_queries:
|
for query in possible_queries:
|
||||||
try:
|
try:
|
||||||
response = dnsrequest.req(query, qtype='SRV')
|
answers = [x for x in dns.resolver.query(query, 'SRV')]
|
||||||
answers = [x for x in response.answers]
|
|
||||||
if answers:
|
if answers:
|
||||||
# extract the data from a random SRV RR
|
host = str (answers[0].target)
|
||||||
rr = random.choice(answers)
|
port = int (answers[0].port)
|
||||||
_, _, port, host = rr['data']
|
|
||||||
port = int(port)
|
|
||||||
break
|
break
|
||||||
except DNS.DNSError, err :
|
except:
|
||||||
self.DEBUG("An error occurred querying SRV record for %s" % query, 'warn')
|
pass
|
||||||
|
|
||||||
server = (host, port)
|
server = (host, port)
|
||||||
# end of SRV resolver
|
# end of SRV resolver
|
||||||
|
|
Loading…
Reference in New Issue