Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.servicetypes[info.type]=1
now = currentTimeMillis()
nextTime = now
i = 0
while i < 3:
if now < nextTime:
self.wait(nextTime - now)
now = currentTimeMillis()
continue
out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
out.addAnswerAtTime(DNSPointer(info.type, _TYPE_PTR,
_CLASS_IN, ttl, info.name), 0)
out.addAnswerAtTime(DNSService(info.name, _TYPE_SRV,
_CLASS_IN, ttl, info.priority, info.weight, info.port,
info.server), 0)
out.addAnswerAtTime(DNSText(info.name, _TYPE_TXT, _CLASS_IN,
ttl, info.text), 0)
if info.address:
out.addAnswerAtTime(DNSAddress(info.server, _TYPE_A,
_CLASS_IN, ttl, info.address), 0)
self.send(out)
i += 1
nextTime += _REGISTER_TIME
pass
now = currentTimeMillis()
nextTime = now
i = 0
while i < 3:
if now < nextTime:
self.wait(nextTime - now)
now = currentTimeMillis()
continue
out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
out.addAnswerAtTime(DNSPointer(info.type, _TYPE_PTR,
_CLASS_IN, 0, info.name), 0)
out.addAnswerAtTime(DNSService(info.name, _TYPE_SRV,
_CLASS_IN, 0, info.priority, info.weight, info.port,
info.name), 0)
out.addAnswerAtTime(DNSText(info.name, _TYPE_TXT, _CLASS_IN,
0, info.text), 0)
if info.address:
out.addAnswerAtTime(DNSAddress(info.server, _TYPE_A,
_CLASS_IN, 0, info.address), 0)
self.send(out)
i += 1
nextTime += _UNREGISTER_TIME
now = currentTimeMillis()
nextTime = now
i = 0
while i < 3:
if now < nextTime:
self.wait(nextTime - now)
now = currentTimeMillis()
continue
out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
for info in self.services.values():
out.addAnswerAtTime(DNSPointer(info.type, _TYPE_PTR,
_CLASS_IN, 0, info.name), 0)
out.addAnswerAtTime(DNSService(info.name, _TYPE_SRV,
_CLASS_IN, 0, info.priority, info.weight,
info.port, info.server), 0)
out.addAnswerAtTime(DNSText(info.name, _TYPE_TXT,
_CLASS_IN, 0, info.text), 0)
if info.address:
out.addAnswerAtTime(DNSAddress(info.server,
_TYPE_A, _CLASS_IN, 0, info.address), 0)
self.send(out)
i += 1
nextTime += _UNREGISTER_TIME
pass
now = currentTimeMillis()
nextTime = now
i = 0
while i < 3:
if now < nextTime:
self.wait(nextTime - now)
now = currentTimeMillis()
continue
out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
out.addAnswerAtTime(DNSPointer(info.type, _TYPE_PTR,
_CLASS_IN, 0, info.name), 0)
out.addAnswerAtTime(DNSService(info.name, _TYPE_SRV,
_CLASS_IN, 0, info.priority, info.weight, info.port,
info.name), 0)
out.addAnswerAtTime(DNSText(info.name, _TYPE_TXT, _CLASS_IN,
0, info.text), 0)
if info.address:
out.addAnswerAtTime(DNSAddress(info.server, _TYPE_A,
_CLASS_IN, 0, info.address), 0)
self.send(out)
i += 1
nextTime += _UNREGISTER_TIME
self.servicetypes[info.type] = 1
now = currentTimeMillis()
nextTime = now
i = 0
while i < 3:
if now < nextTime:
self.wait(nextTime - now)
now = currentTimeMillis()
continue
out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
out.addAnswerAtTime(DNSPointer(info.type, _TYPE_PTR,
_CLASS_IN, ttl, info.name), 0)
out.addAnswerAtTime(DNSService(info.name, _TYPE_SRV,
_CLASS_IN, ttl, info.priority, info.weight, info.port,
info.server), 0)
out.addAnswerAtTime(DNSText(info.name, _TYPE_TXT, _CLASS_IN,
ttl, info.text), 0)
if info.address:
out.addAnswerAtTime(DNSAddress(info.server, _TYPE_A,
_CLASS_IN, ttl, info.address), 0)
self.send(out)
i += 1
nextTime += _REGISTER_TIME
def readOthers(self):
"""Reads the answers, authorities and additionals section of the
packet"""
n = self.numAnswers + self.numAuthorities + self.numAdditionals
for i in xrange(n):
domain = self.readName()
type, clazz, ttl, length = self.unpack('!HHiH')
rec = None
if type == _TYPE_A:
rec = DNSAddress(domain, type, clazz, ttl, self.readString(4))
elif type == _TYPE_CNAME or type == _TYPE_PTR:
rec = DNSPointer(domain, type, clazz, ttl, self.readName())
elif type == _TYPE_TXT:
rec = DNSText(domain, type, clazz, ttl, self.readString(length))
elif type == _TYPE_SRV:
rec = DNSService(domain, type, clazz, ttl,
self.readUnsignedShort(), self.readUnsignedShort(),
self.readUnsignedShort(), self.readName())
elif type == _TYPE_HINFO:
rec = DNSHinfo(domain, type, clazz, ttl,
self.readCharacterString(), self.readCharacterString())
elif type == _TYPE_AAAA:
rec = DNSAddress(domain, type, clazz, ttl, self.readString(16))
else:
# Try to ignore types we don't know about
# Skip the payload for the resource record so the next
# records can be parsed correctly
self.offset += length
if rec is not None:
def __eq__(self, other):
"""Tests equality on text"""
return isinstance(other, DNSText) and self.text == other.text
def readOthers(self):
"""Reads the answers, authorities and additionals section of the
packet"""
n = self.numAnswers + self.numAuthorities + self.numAdditionals
for i in xrange(n):
domain = self.readName()
type, clazz, ttl, length = self.unpack('!HHiH')
rec = None
if type == _TYPE_A:
rec = DNSAddress(domain, type, clazz, ttl, self.readString(4))
elif type == _TYPE_CNAME or type == _TYPE_PTR:
rec = DNSPointer(domain, type, clazz, ttl, self.readName())
elif type == _TYPE_TXT:
rec = DNSText(domain, type, clazz, ttl, self.readString(length))
elif type == _TYPE_SRV:
rec = DNSService(domain, type, clazz, ttl,
self.readUnsignedShort(), self.readUnsignedShort(),
self.readUnsignedShort(), self.readName())
elif type == _TYPE_HINFO:
rec = DNSHinfo(domain, type, clazz, ttl,
self.readCharacterString(), self.readCharacterString())
elif type == _TYPE_AAAA:
rec = DNSAddress(domain, type, clazz, ttl, self.readString(16))
else:
# Try to ignore types we don't know about
# Skip the payload for the resource record so the next
# records can be parsed correctly
self.offset += length
if rec is not None: