Skip to content

Commit

Permalink
Add get_options() helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
rthalley committed Feb 20, 2024
1 parent 5180041 commit 86a2841
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dns/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,11 +912,13 @@ def set_opcode(self, opcode: dns.opcode.Opcode) -> None:
self.flags &= 0x87FF
self.flags |= dns.opcode.to_flags(opcode)

def get_options(self, otype: dns.edns.OptionType) -> List[dns.edns.Option]:
"""Return the list of options of the specified type."""
return [option for option in self.options if option.otype == otype]

def extended_errors(self) -> List[dns.edns.EDEOption]:
"""Return the list of Extended DNS Error (EDE) options in the message"""
return [
option for option in self.options if option.otype == dns.edns.OptionType.EDE
]
return self.get_options(dns.edns.OptionType.EDE)

def _get_one_rr_per_rrset(self, value):
# What the caller picked is fine.
Expand Down

0 comments on commit 86a2841

Please sign in to comment.