Making DNS Rdata

dns.rdata.from_text(rdclass: RdataClass | str, rdtype: RdataType | str, tok: Tokenizer | str, origin: Name | None = None, relativize: bool = True, relativize_to: Name | None = None, idna_codec: IDNACodec | None = None) Rdata[source]

Build an rdata object from text format.

This function attempts to dynamically load a class which implements the specified rdata class and type. If there is no class-and-type-specific implementation, the GenericRdata class is used.

Once a class is chosen, its from_text() class method is called with the parameters to this function.

If tok is a str, then a tokenizer is created and the string is used as its input.

rdclass, a dns.rdataclass.RdataClass or str, the rdataclass.

rdtype, a dns.rdatatype.RdataType or str, the rdatatype.

tok, a dns.tokenizer.Tokenizer or a str.

origin, a dns.name.Name (or None), the origin to use for relative names.

relativize, a bool. If true, name will be relativized.

relativize_to, a dns.name.Name (or None), the origin to use when relativizing names. If not set, the origin value will be used.

idna_codec, a dns.name.IDNACodec, specifies the IDNA encoder/decoder to use if a tokenizer needs to be created. If None, the default IDNA 2003 encoder/decoder is used. If a tokenizer is not created, then the codec associated with the tokenizer is the one that is used.

Returns an instance of the chosen Rdata subclass.

dns.rdata.from_wire_parser(rdclass: RdataClass | str, rdtype: RdataType | str, parser: Parser, origin: Name | None = None) Rdata[source]

Build an rdata object from wire format

This function attempts to dynamically load a class which implements the specified rdata class and type. If there is no class-and-type-specific implementation, the GenericRdata class is used.

Once a class is chosen, its from_wire() class method is called with the parameters to this function.

rdclass, a dns.rdataclass.RdataClass or str, the rdataclass.

rdtype, a dns.rdatatype.RdataType or str, the rdatatype.

parser, a dns.wire.Parser, the parser, which should be restricted to the rdata length.

origin, a dns.name.Name (or None). If not None, then names will be relativized to this origin.

Returns an instance of the chosen Rdata subclass.

dns.rdata.from_wire(rdclass: RdataClass | str, rdtype: RdataType | str, wire: bytes, current: int, rdlen: int, origin: Name | None = None) Rdata[source]

Build an rdata object from wire format

This function attempts to dynamically load a class which implements the specified rdata class and type. If there is no class-and-type-specific implementation, the GenericRdata class is used.

Once a class is chosen, its from_wire() class method is called with the parameters to this function.

rdclass, an int, the rdataclass.

rdtype, an int, the rdatatype.

wire, a bytes, the wire-format message.

current, an int, the offset in wire of the beginning of the rdata.

rdlen, an int, the length of the wire-format rdata

origin, a dns.name.Name (or None). If not None, then names will be relativized to this origin.

Returns an instance of the chosen Rdata subclass.