summaryrefslogtreecommitdiff
path: root/project2/proj2_s4498062/dns/resource.py
diff options
context:
space:
mode:
Diffstat (limited to 'project2/proj2_s4498062/dns/resource.py')
-rw-r--r--project2/proj2_s4498062/dns/resource.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/project2/proj2_s4498062/dns/resource.py b/project2/proj2_s4498062/dns/resource.py
index 19a09bb..89201ec 100644
--- a/project2/proj2_s4498062/dns/resource.py
+++ b/project2/proj2_s4498062/dns/resource.py
@@ -30,6 +30,13 @@ class ResourceRecord(object):
self.ttl = ttl
self.rdata = rdata
+ def match(self, name=None, type_=None, class_=None, ttl=None):
+ """Check if the record matches properties"""
+ return (name is None or self.name == name) and \
+ (type_ is None or self.type_ == type_) and \
+ (class_ is None or self.class_ == class_) and \
+ (ttl is None or self.ttl == ttl)
+
def to_bytes(self, offset, composer):
""" Convert ResourceRecord to bytes """
record = composer.to_bytes(offset, [self.name])
@@ -51,6 +58,9 @@ class ResourceRecord(object):
offset += rdlength
return cls(name, type_, class_, ttl, rdata), offset
+ def __repr__(self):
+ return ' '.join(map(str, [self.name, self.type_, self.rdata.data]))
+
class RecordData(object):
""" Record Data """