Rdata classes and types¶
Sets of typed data can be associated with a given name. A single typed datum is called an rdata. The type of an rdata is specified by its rdataclass and rdatatype. The class is almost always IN, the Internet class, and may often be omitted in the dnspython APIs.
The dns.rdataclass
module provides constants for each defined
rdata class, as well as some helpful functions. The dns.rdatatype
module does the same for rdata types. Examples of the constants are:
dns.rdataclass.IN
dns.rdatatype.AAAA
DNS Rdata Classes.
- dns.rdataclass.from_text(text: str) dns.rdataclass.RdataClass [source]¶
Convert text into a DNS rdata class value.
The input text can be a defined DNS RR class mnemonic or instance of the DNS generic class syntax.
For example, “IN” and “CLASS1” will both result in a value of 1.
Raises
dns.rdatatype.UnknownRdataclass
if the class is unknown.Raises
ValueError
if the rdata class value is not >= 0 and <= 65535.Returns a
dns.rdataclass.RdataClass
.
- dns.rdataclass.is_metaclass(rdclass: dns.rdataclass.RdataClass) bool [source]¶
True if the specified class is a metaclass.
The currently defined metaclasses are ANY and NONE.
rdclass is a
dns.rdataclass.RdataClass
.
- dns.rdataclass.to_text(value: dns.rdataclass.RdataClass) str [source]¶
Convert a DNS rdata class value to text.
If the value has a known mnemonic, it will be used, otherwise the DNS generic class syntax will be used.
Raises
ValueError
if the rdata class value is not >= 0 and <= 65535.Returns a
str
.
DNS Rdata Types.
- exception dns.rdatatype.UnknownRdatatype(*args, **kwargs)[source]¶
DNS resource record type is unknown.
- dns.rdatatype.from_text(text: str) dns.rdatatype.RdataType [source]¶
Convert text into a DNS rdata type value.
The input text can be a defined DNS RR type mnemonic or instance of the DNS generic type syntax.
For example, “NS” and “TYPE2” will both result in a value of 2.
Raises
dns.rdatatype.UnknownRdatatype
if the type is unknown.Raises
ValueError
if the rdata type value is not >= 0 and <= 65535.Returns a
dns.rdatatype.RdataType
.
- dns.rdatatype.is_metatype(rdtype: dns.rdatatype.RdataType) bool [source]¶
True if the specified type is a metatype.
rdtype is a
dns.rdatatype.RdataType
.The currently defined metatypes are TKEY, TSIG, IXFR, AXFR, MAILA, MAILB, ANY, and OPT.
Returns a
bool
.
- dns.rdatatype.is_singleton(rdtype: dns.rdatatype.RdataType) bool [source]¶
Is the specified type a singleton type?
Singleton types can only have a single rdata in an rdataset, or a single RR in an RRset.
The currently defined singleton types are CNAME, DNAME, NSEC, NXT, and SOA.
rdtype is an
int
.Returns a
bool
.
- dns.rdatatype.register_type(rdtype: dns.rdatatype.RdataType, rdtype_text: str, is_singleton: bool = False) None [source]¶
Dynamically register an rdatatype.
rdtype, a
dns.rdatatype.RdataType
, the rdatatype to register.rdtype_text, a
str
, the textual form of the rdatatype.is_singleton, a
bool
, indicating if the type is a singleton (i.e. RRsets of the type can have only one member.)
- dns.rdatatype.to_text(value: dns.rdatatype.RdataType) str [source]¶
Convert a DNS rdata type value to text.
If the value has a known mnemonic, it will be used, otherwise the DNS generic type syntax will be used.
Raises
ValueError
if the rdata type value is not >= 0 and <= 65535.Returns a
str
.