Making DNS Names

dns.name.from_text(text: bytes | str, origin: ~dns.name.Name | None = <DNS name .>, idna_codec: ~dns.name.IDNACodec | None = None) Name[source]

Convert text into a Name object.

text, a bytes or str, is the text to convert into a name.

origin, a dns.name.Name, specifies the origin to append to non-absolute names. The default is the root name.

idna_codec, a dns.name.IDNACodec, specifies the IDNA encoder/decoder. If None, the default IDNA 2003 encoder/decoder is used.

Returns a dns.name.Name.

dns.name.from_unicode(text: str, origin: ~dns.name.Name | None = <DNS name .>, idna_codec: ~dns.name.IDNACodec | None = None) Name[source]

Convert unicode text into a Name object.

Labels are encoded in IDN ACE form according to rules specified by the IDNA codec.

text, a str, is the text to convert into a name.

origin, a dns.name.Name, specifies the origin to append to non-absolute names. The default is the root name.

idna_codec, a dns.name.IDNACodec, specifies the IDNA encoder/decoder. If None, the default IDNA 2003 encoder/decoder is used.

Returns a dns.name.Name.

dns.name.from_wire_parser(parser: Parser) Name[source]

Convert possibly compressed wire format into a Name.

parser is a dns.wire.Parser.

Raises dns.name.BadPointer if a compression pointer did not point backwards in the message.

Raises dns.name.BadLabelType if an invalid label type was encountered.

Returns a dns.name.Name

dns.name.from_wire(message: bytes, current: int) Tuple[Name, int][source]

Convert possibly compressed wire format into a Name.

message is a bytes containing an entire DNS message in DNS wire form.

current, an int, is the offset of the beginning of the name from the start of the message

Raises dns.name.BadPointer if a compression pointer did not point backwards in the message.

Raises dns.name.BadLabelType if an invalid label type was encountered.

Returns a (dns.name.Name, int) tuple consisting of the name that was read and the number of bytes of the wire format message which were consumed reading it.