Making DNS Names

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

Convert text into a dns.name.Name object.

Parameters:
  • text (bytes or str) – The text to convert into a name.

  • origin (dns.name.Name or None) – The origin to append to non-absolute names. The default is the root name.

  • idna_codec (dns.name.IDNACodec or None) – The IDNA encoder/decoder. If None, the default IDNA encoder/decoder is used.

Return type:

dns.name.Name

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

Convert unicode text into a dns.name.Name object.

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

Parameters:
  • text (str) – The text to convert into a name.

  • origin (dns.name.Name or None) – The origin to append to non-absolute names. The default is the root name.

  • idna_codec (dns.name.IDNACodec or None) – The IDNA encoder/decoder. If None, the default IDNA encoder/decoder is used.

Return type:

dns.name.Name

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

Convert possibly compressed wire format into a dns.name.Name.

Parameters:

parser (dns.wirebase.Parser) – The wire format parser.

Raises:
Return type:

dns.name.Name

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

Convert possibly compressed wire format into a dns.name.Name.

Parameters:
  • message (bytes) – A bytes containing an entire DNS message in DNS wire form.

  • current (int) – The offset of the beginning of the name from the start of the message.

Raises:
Returns:

A tuple of the name that was read and the number of bytes of the wire format message which were consumed reading it.

Return type:

tuple[dns.name.Name, int]