Message EDNS Options
EDNS allows for larger messages and also provides an extension
mechanism for the protocol. EDNS options are typed data, and are
treated much like Rdata. For example, if dnspython encounters the EDNS
ECS option code when parsing a DNS wire format message, it
will create a dns.edns.ECSOption object to represent it.
- dns.edns.NSID = OptionType.NSID
EDNS option type codes
- dns.edns.DAU = OptionType.DAU
EDNS option type codes
- dns.edns.DHU = OptionType.DHU
EDNS option type codes
- dns.edns.N3U = OptionType.N3U
EDNS option type codes
- dns.edns.ECS = OptionType.ECS
EDNS option type codes
- dns.edns.EXPIRE = OptionType.EXPIRE
EDNS option type codes
- dns.edns.COOKIE = OptionType.COOKIE
EDNS option type codes
- dns.edns.KEEPALIVE = OptionType.KEEPALIVE
EDNS option type codes
- dns.edns.PADDING = OptionType.PADDING
EDNS option type codes
- dns.edns.CHAIN = OptionType.CHAIN
EDNS option type codes
- class dns.edns.Option(otype: OptionType | str)[source]
Base class for all EDNS option types.
Initialize an option.
- Parameters:
otype (
dns.edns.OptionType) – The option type.
- classmethod from_wire_parser(otype: OptionType, parser: Parser) Option[source]
Build an EDNS option object from wire format.
- Parameters:
otype (
dns.edns.OptionType) – The option type.parser (
dns.wire.Parser) – The parser, restricted to the option length.
- Return type:
- to_generic() GenericOption[source]
Create a
dns.edns.GenericOptionequivalent of this option.- Return type:
- class dns.edns.GenericOption(otype: OptionType | str, data: bytes | str)[source]
Generic Option Class
This class is used for EDNS option types for which we have no better implementation.
Initialize an option.
- Parameters:
otype (
dns.edns.OptionType) – The option type.
- classmethod from_wire_parser(otype: OptionType | str, parser: Parser) Option[source]
Build an EDNS option object from wire format.
- Parameters:
otype (
dns.edns.OptionType) – The option type.parser (
dns.wire.Parser) – The parser, restricted to the option length.
- Return type:
- to_generic() GenericOption[source]
Create a
dns.edns.GenericOptionequivalent of this option.- Return type:
- class dns.edns.ECSOption(address: str, srclen: int | None = None, scopelen: int = 0)[source]
EDNS Client Subnet (ECS, RFC7871)
Initialize an ECSOption.
- Parameters:
- static from_text(text: str) Option[source]
Convert a string into a dns.edns.ECSOption
text, a str, the text form of the option.
Returns a dns.edns.ECSOption.
Examples:
>>> import dns.edns >>> >>> # basic example >>> dns.edns.ECSOption.from_text('1.2.3.4/24') >>> >>> # also understands scope >>> dns.edns.ECSOption.from_text('1.2.3.4/24/32') >>> >>> # IPv6 >>> dns.edns.ECSOption.from_text('2001:4b98::1/64/64') >>> >>> # it understands results from `dns.edns.ECSOption.to_text()` >>> dns.edns.ECSOption.from_text('ECS 1.2.3.4/24/32')
- classmethod from_wire_parser(otype: OptionType | str, parser: Parser) Option[source]
Build an EDNS option object from wire format.
- Parameters:
otype (
dns.edns.OptionType) – The option type.parser (
dns.wire.Parser) – The parser, restricted to the option length.
- Return type:
- class dns.edns.EDEOption(code: EDECode | str, text: str | None = None)[source]
Extended DNS Error (EDE, RFC8914)
Initialize an EDEOption.
- Parameters:
code (
dns.edns.EDECodeor str) – The info code of the extended error.text (str or
None) – Additional information about the error.
- classmethod from_wire_parser(otype: OptionType | str, parser: Parser) Option[source]
Build an EDNS option object from wire format.
- Parameters:
otype (
dns.edns.OptionType) – The option type.parser (
dns.wire.Parser) – The parser, restricted to the option length.
- Return type:
- class dns.edns.NSIDOption(nsid: bytes)[source]
Initialize an option.
- Parameters:
otype (
dns.edns.OptionType) – The option type.
- classmethod from_wire_parser(otype: OptionType | str, parser: Parser) Option[source]
Build an EDNS option object from wire format.
- Parameters:
otype (
dns.edns.OptionType) – The option type.parser (
dns.wire.Parser) – The parser, restricted to the option length.
- Return type:
- class dns.edns.CookieOption(client: bytes, server: bytes)[source]
Initialize an option.
- Parameters:
otype (
dns.edns.OptionType) – The option type.
- classmethod from_wire_parser(otype: OptionType | str, parser: Parser) Option[source]
Build an EDNS option object from wire format.
- Parameters:
otype (
dns.edns.OptionType) – The option type.parser (
dns.wire.Parser) – The parser, restricted to the option length.
- Return type:
- class dns.edns.ReportChannelOption(agent_domain: Name)[source]
Initialize an option.
- Parameters:
otype (
dns.edns.OptionType) – The option type.
- classmethod from_wire_parser(otype: OptionType | str, parser: Parser) Option[source]
Build an EDNS option object from wire format.
- Parameters:
otype (
dns.edns.OptionType) – The option type.parser (
dns.wire.Parser) – The parser, restricted to the option length.
- Return type:
- class dns.edns.EDEExtraTextLanguageOption(language: str)[source]
Extended DNS Error EXTRA-TEXT language (EDE-EXTRA-TEXT-LANGUAGE)
Initialize an EDEExtraTextLanguageOption.
- Parameters:
language (str) – The language of EXTRA-TEXT in the EDE option.
- classmethod from_wire_parser(otype: OptionType | str, parser: Parser) Option[source]
Build an EDNS option object from wire format.
- Parameters:
otype (
dns.edns.OptionType) – The option type.parser (
dns.wire.Parser) – The parser, restricted to the option length.
- Return type:
- class dns.edns.FilteringContactOption(contact: str)[source]
Filtering contact (FILTERING-CONTACT)
Initialize a FilteringContactOption.
- Parameters:
contact (str) – A filtering contact URI as a string.
- classmethod from_wire_parser(otype: OptionType | str, parser: Parser) Option[source]
Build an EDNS option object from wire format.
- Parameters:
otype (
dns.edns.OptionType) – The option type.parser (
dns.wire.Parser) – The parser, restricted to the option length.
- Return type:
- class dns.edns.FilteringOrganizationOption(organization: str)[source]
Filtering organization (FILTERING-ORGANIZATION)
Initialize a FilteringOrganizationOption.
- Parameters:
organization (str) – The filtering organization.
- classmethod from_wire_parser(otype: OptionType | str, parser: Parser) Option[source]
Build an EDNS option object from wire format.
- Parameters:
otype (
dns.edns.OptionType) – The option type.parser (
dns.wire.Parser) – The parser, restricted to the option length.
- Return type:
- class dns.edns.FilteringDBOption(db: str)[source]
Filtering DB (FILTERING-DB)
Initialize a FilteringDBOption.
- Parameters:
db (str) – The filtering database containing the identifier, name, or description of the filtering database against which a matched query caused the filtering to occur.
- classmethod from_wire_parser(otype: OptionType | str, parser: Parser) Option[source]
Build an EDNS option object from wire format.
- Parameters:
otype (
dns.edns.OptionType) – The option type.parser (
dns.wire.Parser) – The parser, restricted to the option length.
- Return type:
- dns.edns.get_option_class(otype: OptionType) Any[source]
Return the class for the specified option type.
The GenericOption class is used if a more specific class is not known.
- dns.edns.option_from_wire_parser(otype: OptionType | str, parser: Parser) Option[source]
Build an EDNS option object from wire format.
- Parameters:
otype (int or
dns.edns.OptionType) – The option type.parser (
dns.wire.Parser) – The parser, restricted to the option length.
- Return type:
- dns.edns.option_from_wire(otype: OptionType | str, wire: bytes, current: int, olen: int) Option[source]
Build an EDNS option object from wire format.
- Parameters:
otype (int or
dns.edns.OptionType) – The option type.wire (bytes) – The wire-format message.
current (int) – The offset in wire of the beginning of the rdata.
olen (int) – The length of the wire-format option data.
- Return type:
- dns.edns.register_type(implementation: Any, otype: OptionType) None[source]
Register the implementation of an option type.
- Parameters:
implementation – A subclass of
dns.edns.Option.otype (
dns.edns.OptionType) – The option type.