Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __eq__(self, other):
"""Tests equality as per DNSRecord"""
return isinstance(other, DNSRecord) and DNSEntry.__eq__(self, other)
DNSRecord.__init__(self, name, type, clazz, ttl)
self.alias = alias
def write(self, out):
"""Used in constructing an outgoing packet"""
out.writeName(self.alias)
def __eq__(self, other):
"""Tests equality on alias"""
return isinstance(other, DNSPointer) and self.alias == other.alias
def __repr__(self):
"""String representation"""
return self.toString(self.alias)
class DNSText(DNSRecord):
"""A DNS text record"""
def __init__(self, name, type, clazz, ttl, text):
DNSRecord.__init__(self, name, type, clazz, ttl)
self.text = text
def write(self, out):
"""Used in constructing an outgoing packet"""
out.writeString(self.text)
def __eq__(self, other):
"""Tests equality on text"""
return isinstance(other, DNSText) and self.text == other.text
def __repr__(self):
"""String representation"""
def write(self, out):
"""Used in constructing an outgoing packet"""
out.writeString(self.cpu)
out.writeString(self.oso)
def __eq__(self, other):
"""Tests equality on cpu and os"""
return (isinstance(other, DNSHinfo) and
self.cpu == other.cpu and self.os == other.os)
def __repr__(self):
"""String representation"""
return self.cpu + " " + self.os
class DNSPointer(DNSRecord):
"""A DNS pointer record"""
def __init__(self, name, type, clazz, ttl, alias):
DNSRecord.__init__(self, name, type, clazz, ttl)
self.alias = alias
def write(self, out):
"""Used in constructing an outgoing packet"""
out.writeName(self.alias)
def __eq__(self, other):
"""Tests equality on alias"""
return isinstance(other, DNSPointer) and self.alias == other.alias
def __repr__(self):
"""String representation"""
"""Sets this record's TTL and created time to that of
another record."""
self.created = other.created
self.ttl = other.ttl
def write(self, out):
"""Abstract method"""
raise AbstractMethodException
def toString(self, other):
"""String representation with addtional information"""
arg = "%s/%s,%s" % (self.ttl,
self.getRemainingTTL(currentTimeMillis()), other)
return DNSEntry.toString(self, "record", arg)
class DNSAddress(DNSRecord):
"""A DNS address record"""
def __init__(self, name, type, clazz, ttl, address):
DNSRecord.__init__(self, name, type, clazz, ttl)
self.address = address
def write(self, out):
"""Used in constructing an outgoing packet"""
out.writeString(self.address)
def __eq__(self, other):
"""Tests equality on address"""
return isinstance(other, DNSAddress) and self.address == other.address
def __repr__(self):
"""String representation"""
def __eq__(self, other):
"""Tests equality as per DNSRecord"""
return isinstance(other, DNSRecord) and DNSEntry.__eq__(self, other)
DNSRecord.__init__(self, name, type, clazz, ttl)
self.alias = alias
def write(self, out):
"""Used in constructing an outgoing packet"""
out.writeName(self.alias)
def __eq__(self, other):
"""Tests equality on alias"""
return isinstance(other, DNSPointer) and self.alias == other.alias
def __repr__(self):
"""String representation"""
return self.toString(self.alias)
class DNSText(DNSRecord):
"""A DNS text record"""
def __init__(self, name, type, clazz, ttl, text):
DNSRecord.__init__(self, name, type, clazz, ttl)
self.text = text
def write(self, out):
"""Used in constructing an outgoing packet"""
out.writeString(self.text)
def __eq__(self, other):
"""Tests equality on text"""
return isinstance(other, DNSText) and self.text == other.text
def __repr__(self):
"""String representation"""
def write(self, out):
"""Used in constructing an outgoing packet"""
out.writeString(self.text)
def __eq__(self, other):
"""Tests equality on text"""
return isinstance(other, DNSText) and self.text == other.text
def __repr__(self):
"""String representation"""
if len(self.text) > 10:
return self.toString(self.text[:7] + "...")
else:
return self.toString(self.text)
class DNSService(DNSRecord):
"""A DNS service record"""
def __init__(self, name, type, clazz, ttl, priority, weight, port, server):
DNSRecord.__init__(self, name, type, clazz, ttl)
self.priority = priority
self.weight = weight
self.port = port
self.server = server
def write(self, out):
"""Used in constructing an outgoing packet"""
out.writeShort(self.priority)
out.writeShort(self.weight)
out.writeShort(self.port)
out.writeName(self.server)
def write(self, out):
"""Used in constructing an outgoing packet"""
out.writeString(self.address)
def __eq__(self, other):
"""Tests equality on address"""
return isinstance(other, DNSAddress) and self.address == other.address
def __repr__(self):
"""String representation"""
try:
return socket.inet_ntoa(self.address)
except:
return self.address
class DNSHinfo(DNSRecord):
"""A DNS host information record"""
def __init__(self, name, type, clazz, ttl, cpu, os):
DNSRecord.__init__(self, name, type, clazz, ttl)
self.cpu = cpu
self.os = os
def write(self, out):
"""Used in constructing an outgoing packet"""
out.writeString(self.cpu)
out.writeString(self.oso)
def __eq__(self, other):
"""Tests equality on cpu and os"""
return (isinstance(other, DNSHinfo) and
self.cpu == other.cpu and self.os == other.os)