From 6895d65db10a60b5153194aaa22b4a39213c3454 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 22 May 2016 19:17:00 +0200 Subject: Fix resource.py; lint --- project2/proj2_s4498062/dns/resource.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'project2/proj2_s4498062/dns/resource.py') diff --git a/project2/proj2_s4498062/dns/resource.py b/project2/proj2_s4498062/dns/resource.py index 71f09be..adce3e7 100644 --- a/project2/proj2_s4498062/dns/resource.py +++ b/project2/proj2_s4498062/dns/resource.py @@ -30,15 +30,12 @@ class ResourceRecord(object): def to_bytes(self, offset, composer): """ Convert ResourceRecord to bytes """ - name = composer.to_bytes(offset, [self.name]) - offset += len(name) + record = composer.to_bytes(offset, [self.name]) + record += struct.pack("!HHI", self.type_, self.class_, self.ttl) + offset += len(record) + 2 rdata = self.rdata.to_bytes(offset, composer) - return (name + struct.pack( - "!HHIH", - self.type_, - self.class_, - self.ttl, - len(rdata)) + rdata) + record += struct.pack("!H", len(rdata)) + rdata + return record @classmethod def from_bytes(cls, packet, offset, parser): -- cgit v1.2.3