Skip to content

Commit

Permalink
rec: Fix the EDNS padding python implementation for dnspython 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rgacogne committed Mar 8, 2021
1 parent 56f1a30 commit c8567be
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions regression-tests.recursor-dnssec/paddingoption.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ def __init__(self, numberOfBytes):
super(PaddingOption, self).__init__(12)
self.numberOfBytes = numberOfBytes

def to_wire(self, file):
def to_wire(self, file=None):
"""Create EDNS packet as defined in rfc7830."""

file.write(bytes(self.numberOfBytes))
if file:
file.write(bytes(self.numberOfBytes))
else:
return bytes(self.numberOfBytes)

def from_wire(cls, otype, wire, current, olen):
"""Read EDNS packet as defined in rfc7830.
Expand All @@ -32,6 +35,12 @@ def from_wire(cls, otype, wire, current, olen):

from_wire = classmethod(from_wire)

# needed in 2.0.0
@classmethod
def from_wire_parser(cls, otype, parser):
data = parser.get_remaining()
return cls(len(data))

def __repr__(self):
return '%s(%d)' % (
self.__class__.__name__,
Expand Down

0 comments on commit c8567be

Please sign in to comment.