| ... |
... |
@@ -17,7 +17,6 @@ |
|
17
|
17
|
|
|
18
|
18
|
import logging
|
|
19
|
19
|
import select
|
|
20
|
|
-import socket
|
|
21
|
20
|
import re
|
|
22
|
21
|
|
|
23
|
22
|
from gajim.common.i18n import _
|
| ... |
... |
@@ -157,16 +156,16 @@ class Zeroconf: |
|
157
|
156
|
|
|
158
|
157
|
self.queried.append(True)
|
|
159
|
158
|
|
|
160
|
|
- def query_record_callback(self, sdRef, flags, interfaceIndex, errorCode,
|
|
161
|
|
- hosttarget, rrtype, rrclass, rdata, ttl):
|
|
|
159
|
+ def getaddrinfo_callback(self, sdRef, flags, interfaceIndex, errorCode,
|
|
|
160
|
+ hosttarget, address, ttl):
|
|
162
|
161
|
if errorCode != pybonjour.kDNSServiceErr_NoError:
|
|
163
|
|
- log.error('Error in query_record_callback: %s', str(errorCode))
|
|
|
162
|
+ log.error('Error in getaddrinfo_callback: %s', str(errorCode))
|
|
164
|
163
|
return
|
|
165
|
164
|
|
|
166
|
165
|
fullname, port, txtRecord = self.resolved_contacts[hosttarget]
|
|
167
|
166
|
|
|
168
|
167
|
txt = pybonjour.TXTRecord.parse(txtRecord)
|
|
169
|
|
- ip = socket.inet_ntoa(rdata)
|
|
|
168
|
+ ip = address[1]
|
|
170
|
169
|
|
|
171
|
170
|
name, bare_name, protocol, domain = self._parse_name(fullname)
|
|
172
|
171
|
|
| ... |
... |
@@ -207,20 +206,18 @@ class Zeroconf: |
|
207
|
206
|
self.resolved_contacts[hosttarget] = (fullname, port, txtRecord)
|
|
208
|
207
|
|
|
209
|
208
|
try:
|
|
210
|
|
- query_sdRef = None
|
|
211
|
|
- query_sdRef = \
|
|
212
|
|
- pybonjour.DNSServiceQueryRecord(
|
|
|
209
|
+ getaddrinfo_sdRef = \
|
|
|
210
|
+ pybonjour.DNSServiceGetAddrInfo(
|
|
213
|
211
|
interfaceIndex=interfaceIndex,
|
|
214
|
|
- fullname=hosttarget,
|
|
215
|
|
- rrtype=pybonjour.kDNSServiceType_A,
|
|
216
|
|
- callBack=self.query_record_callback)
|
|
|
212
|
+ hostname=hosttarget,
|
|
|
213
|
+ callBack=self.getaddrinfo_callback)
|
|
217
|
214
|
|
|
218
|
215
|
while not self.queried:
|
|
219
|
|
- ready = select.select([query_sdRef], [], [], resolve_timeout)
|
|
220
|
|
- if query_sdRef not in ready[0]:
|
|
221
|
|
- log.warning('Query record timed out')
|
|
|
216
|
+ ready = select.select([getaddrinfo_sdRef], [], [], resolve_timeout)
|
|
|
217
|
+ if getaddrinfo_sdRef not in ready[0]:
|
|
|
218
|
+ log.warning('GetAddrInfo timed out')
|
|
222
|
219
|
break
|
|
223
|
|
- pybonjour.DNSServiceProcessResult(query_sdRef)
|
|
|
220
|
+ pybonjour.DNSServiceProcessResult(getaddrinfo_sdRef)
|
|
224
|
221
|
else:
|
|
225
|
222
|
self.queried.pop()
|
|
226
|
223
|
|
| ... |
... |
@@ -231,8 +228,8 @@ class Zeroconf: |
|
231
|
228
|
self.error_CB(_('Error while adding service. %s') % error)
|
|
232
|
229
|
|
|
233
|
230
|
finally:
|
|
234
|
|
- if query_sdRef:
|
|
235
|
|
- query_sdRef.close()
|
|
|
231
|
+ if getaddrinfo_sdRef:
|
|
|
232
|
+ getaddrinfo_sdRef.close()
|
|
236
|
233
|
|
|
237
|
234
|
self.resolved.append(True)
|
|
238
|
235
|
|