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.Nameobject.- Parameters:
origin (
dns.name.NameorNone) – The origin to append to non-absolute names. The default is the root name.idna_codec (
dns.name.IDNACodecorNone) – The IDNA encoder/decoder. IfNone, the default IDNA encoder/decoder is used.
- Return type:
- 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.Nameobject.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.NameorNone) – The origin to append to non-absolute names. The default is the root name.idna_codec (
dns.name.IDNACodecorNone) – The IDNA encoder/decoder. IfNone, the default IDNA encoder/decoder is used.
- Return type:
- 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:
dns.name.BadPointer – if a compression pointer did not point backwards in the message.
dns.name.BadLabelType – if an invalid label type was encountered.
- Return type:
- dns.name.from_wire(message: bytes, current: int) tuple[Name, int][source]
Convert possibly compressed wire format into a
dns.name.Name.- Parameters:
- Raises:
dns.name.BadPointer – if a compression pointer did not point backwards in the message.
dns.name.BadLabelType – if an invalid label type was encountered.
- 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]