##// END OF EJS Templates
zeroconf: Python 3 porting of vendored library...
Gregory Szorc -
r41660:a36f462c default
parent child Browse files
Show More
@@ -84,7 +84,6 b' import errno'
84 import itertools
84 import itertools
85 import select
85 import select
86 import socket
86 import socket
87 import string
88 import struct
87 import struct
89 import threading
88 import threading
90 import time
89 import time
@@ -106,7 +105,7 b" globals()['_GLOBAL_DONE'] = 0"
106
105
107 # Some DNS constants
106 # Some DNS constants
108
107
109 _MDNS_ADDR = '224.0.0.251'
108 _MDNS_ADDR = r'224.0.0.251'
110 _MDNS_PORT = 5353
109 _MDNS_PORT = 5353
111 _DNS_PORT = 53
110 _DNS_PORT = 53
112 _DNS_TTL = 60 * 60 # one hour default TTL
111 _DNS_TTL = 60 * 60 # one hour default TTL
@@ -221,7 +220,7 b' class DNSEntry(object):'
221 """A DNS entry"""
220 """A DNS entry"""
222
221
223 def __init__(self, name, type, clazz):
222 def __init__(self, name, type, clazz):
224 self.key = string.lower(name)
223 self.key = name.lower()
225 self.name = name
224 self.name = name
226 self.type = type
225 self.type = type
227 self.clazz = clazz & _CLASS_MASK
226 self.clazz = clazz & _CLASS_MASK
@@ -620,7 +619,7 b' class DNSIncoming(object):'
620 first = off
619 first = off
621
620
622 while True:
621 while True:
623 len = ord(self.data[off])
622 len = ord(self.data[off:off + 1])
624 off += 1
623 off += 1
625 if len == 0:
624 if len == 0:
626 break
625 break
@@ -631,7 +630,7 b' class DNSIncoming(object):'
631 elif t == 0xC0:
630 elif t == 0xC0:
632 if next < 0:
631 if next < 0:
633 next = off + 1
632 next = off + 1
634 off = ((len & 0x3F) << 8) | ord(self.data[off])
633 off = ((len & 0x3F) << 8) | ord(self.data[off:off + 1])
635 if off >= first:
634 if off >= first:
636 raise BadDomainNameCircular(off)
635 raise BadDomainNameCircular(off)
637 first = off
636 first = off
@@ -1333,7 +1332,7 b' class Zeroconf(object):'
1333 # SO_REUSEADDR and SO_REUSEPORT have been set, so ignore it
1332 # SO_REUSEADDR and SO_REUSEPORT have been set, so ignore it
1334 pass
1333 pass
1335 self.socket.setsockopt(socket.SOL_IP, socket.IP_ADD_MEMBERSHIP,
1334 self.socket.setsockopt(socket.SOL_IP, socket.IP_ADD_MEMBERSHIP,
1336 socket.inet_aton(_MDNS_ADDR) + socket.inet_aton('0.0.0.0'))
1335 socket.inet_aton(_MDNS_ADDR) + socket.inet_aton(r'0.0.0.0'))
1337
1336
1338 self.listeners = []
1337 self.listeners = []
1339 self.browsers = []
1338 self.browsers = []
@@ -1657,7 +1656,7 b' class Zeroconf(object):'
1657 self.engine.notify()
1656 self.engine.notify()
1658 self.unregisterAllServices()
1657 self.unregisterAllServices()
1659 self.socket.setsockopt(socket.SOL_IP, socket.IP_DROP_MEMBERSHIP,
1658 self.socket.setsockopt(socket.SOL_IP, socket.IP_DROP_MEMBERSHIP,
1660 socket.inet_aton(_MDNS_ADDR) + socket.inet_aton('0.0.0.0'))
1659 socket.inet_aton(_MDNS_ADDR) + socket.inet_aton(r'0.0.0.0'))
1661 self.socket.close()
1660 self.socket.close()
1662
1661
1663 # Test a few module features, including service registration, service
1662 # Test a few module features, including service registration, service
General Comments 0
You need to be logged in to leave comments. Login now