dnspython  1.16.0
About: dnspython is a DNS toolkit (for Python 2.x) that supports almost all record types.
  Fossies Dox: dnspython-1.16.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

dns.name Namespace Reference


class  AbsoluteConcatenation
class  BadEscape
class  BadLabelType
class  BadPointer
class  EmptyLabel
class  IDNA2003Codec
class  IDNA2008Codec
class  IDNACodec
class  IDNAException
class  LabelTooLong
class  Name
class  NameTooLong
class  NeedAbsoluteNameOrOrigin
class  NoIDNA2008
class  NoParent


def _escapify (label, unicode_mode=False)
def _validate_labels (labels)
def _maybe_convert_to_binary (label)
def from_unicode (text, origin=root, idna_codec=None)
def from_text (text, origin=root, idna_codec=None)
def from_wire (message, current)


bool have_idna_2008 = True
 maxint = sys.maxint
 _escaped = bytearray(b'"().;\\@$')
 IDNA_2003_Practical = IDNA2003Codec(False)
 IDNA_2003_Strict = IDNA2003Codec(True)
 IDNA_2003 = IDNA_2003_Practical
 IDNA_2008_Practical = IDNA2008Codec(True, False, True, False)
 IDNA_2008_UTS_46 = IDNA2008Codec(True, False, False, False)
 IDNA_2008_Strict = IDNA2008Codec(False, False, False, True)
 IDNA_2008_Transitional = IDNA2008Codec(True, True, False, False)
 IDNA_2008 = IDNA_2008_Practical
 root = Name([b''])
 empty = Name([])

Function Documentation

◆ _escapify()

def dns.name._escapify (   label,
  unicode_mode = False 
Escape the characters in label which need it.
@param unicode_mode: escapify only special and whitespace (<= 0x20)
@returns: the escaped string
@rtype: string

Definition at line 243 of file name.py.

Referenced by dns.name.IDNACodec.decode(), dns.name.IDNA2003Codec.decode(), and dns.name.IDNA2008Codec.decode().

◆ _maybe_convert_to_binary()

def dns.name._maybe_convert_to_binary (   label)
If label is ``text``, convert it to ``binary``.  If it is already
``binary`` just return it.

Definition at line 305 of file name.py.

Referenced by dns.name.Name.__init__().

◆ _validate_labels()

def dns.name._validate_labels (   labels)
Check for empty labels in the middle of a label sequence,
labels that are too long, and for too many labels.

Raises ``dns.name.NameTooLong`` if the name as a whole is too long.

Raises ``dns.name.EmptyLabel`` if a label is empty (i.e. the root
label) and appears in a position other than the end of the label

Definition at line 275 of file name.py.

Referenced by dns.name.Name.__init__(), and dns.name.Name.__setstate__().

◆ from_text()

def dns.name.from_text (   text,
  origin = root,
  idna_codec = None 

◆ from_unicode()

def dns.name.from_unicode (   text,
  origin = root,
  idna_codec = None 
Convert unicode text into a Name object.

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

*text*, a ``text``, 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``.

Definition at line 798 of file name.py.

References dns._compat.unichr.

Referenced by dns.name.from_text().

◆ from_wire()

def dns.name.from_wire (   message,
Convert possibly compressed wire format into a Name.

*message* is a ``binary`` 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.

Definition at line 945 of file name.py.

References dns.wiredata.maybe_wrap().

Referenced by dns.message._WireReader._get_question(), dns.message._WireReader._get_section(), dns.rdtypes.CH.A.A.from_wire(), dns.rdtypes.nsbase.NSBase.from_wire(), dns.rdtypes.ANY.RP.RP.from_wire(), dns.rdtypes.mxbase.MXBase.from_wire(), dns.rdtypes.IN.PX.PX.from_wire(), dns.rdtypes.IN.SRV.SRV.from_wire(), dns.rdtypes.ANY.HIP.HIP.from_wire(), dns.rdtypes.ANY.SOA.SOA.from_wire(), dns.rdtypes.IN.NAPTR.NAPTR.from_wire(), dns.rdtypes.ANY.NSEC.NSEC.from_wire(), dns.rdtypes.IN.IPSECKEY.IPSECKEY.from_wire(), dns.rdtypes.ANY.RRSIG.RRSIG.from_wire(), dns.tsig.get_algorithm_and_mac(), and dns.tsig.validate().

Variable Documentation

◆ _escaped

dns.name._escaped = bytearray(b'"().;\\@$')

Definition at line 232 of file name.py.

◆ empty

dns.name.empty = Name([])

Definition at line 796 of file name.py.

◆ have_idna_2008

bool dns.name.have_idna_2008 = True

Definition at line 28 of file name.py.

◆ IDNA_2003

dns.name.IDNA_2003 = IDNA_2003_Practical

Definition at line 236 of file name.py.

◆ IDNA_2003_Practical

dns.name.IDNA_2003_Practical = IDNA2003Codec(False)

Definition at line 234 of file name.py.

◆ IDNA_2003_Strict

dns.name.IDNA_2003_Strict = IDNA2003Codec(True)

Definition at line 235 of file name.py.

◆ IDNA_2008

dns.name.IDNA_2008 = IDNA_2008_Practical

Definition at line 241 of file name.py.

◆ IDNA_2008_Practical

dns.name.IDNA_2008_Practical = IDNA2008Codec(True, False, True, False)

Definition at line 237 of file name.py.

◆ IDNA_2008_Strict

dns.name.IDNA_2008_Strict = IDNA2008Codec(False, False, False, True)

Definition at line 239 of file name.py.

◆ IDNA_2008_Transitional

dns.name.IDNA_2008_Transitional = IDNA2008Codec(True, True, False, False)

Definition at line 240 of file name.py.

◆ IDNA_2008_UTS_46

dns.name.IDNA_2008_UTS_46 = IDNA2008Codec(True, False, False, False)

Definition at line 238 of file name.py.

◆ maxint

tuple dns.name.maxint = sys.maxint

Definition at line 38 of file name.py.



Definition at line 54 of file name.py.


int dns.name.NAMERELN_EQUAL = 3

Definition at line 52 of file name.py.


int dns.name.NAMERELN_NONE = 0

Definition at line 46 of file name.py.


int dns.name.NAMERELN_SUBDOMAIN = 2

Definition at line 50 of file name.py.



Definition at line 48 of file name.py.

◆ root

dns.name.root = Name([b''])

Definition at line 793 of file name.py.