Making DNS Rdata¶
- dns.rdata.from_text(rdclass: Union[dns.rdataclass.RdataClass, str], rdtype: Union[dns.rdatatype.RdataType, str], tok: Union[dns.tokenizer.Tokenizer, str], origin: Optional[dns.name.Name] = None, relativize: bool = True, relativize_to: Optional[dns.name.Name] = None, idna_codec: Optional[dns.name.IDNACodec] = None) dns.rdata.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
orstr
, the rdataclass.rdtype, a
dns.rdatatype.RdataType
orstr
, the rdatatype.tok, a
dns.tokenizer.Tokenizer
or astr
.origin, a
dns.name.Name
(orNone
), the origin to use for relative names.relativize, a
bool
. If true, name will be relativized.relativize_to, a
dns.name.Name
(orNone
), 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. IfNone
, 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: Union[dns.rdataclass.RdataClass, str], rdtype: Union[dns.rdatatype.RdataType, str], parser: dns.wire.Parser, origin: Optional[dns.name.Name] = None) dns.rdata.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
orstr
, the rdataclass.rdtype, a
dns.rdatatype.RdataType
orstr
, the rdatatype.parser, a
dns.wire.Parser
, the parser, which should be restricted to the rdata length.origin, a
dns.name.Name
(orNone
). If notNone
, then names will be relativized to this origin.Returns an instance of the chosen Rdata subclass.
- dns.rdata.from_wire(rdclass: Union[dns.rdataclass.RdataClass, str], rdtype: Union[dns.rdatatype.RdataType, str], wire: bytes, current: int, rdlen: int, origin: Optional[dns.name.Name] = None) dns.rdata.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 rdataorigin, a
dns.name.Name
(orNone
). If notNone
, then names will be relativized to this origin.Returns an instance of the chosen Rdata subclass.