Message Rcodes

A DNS Rcode describes the result of a DNS request. If EDNS is not in use, then the rcode is encoded solely in the DNS header. If EDNS is in use, then the rcode is encoded using bits form both the header and the EDNS OPT RR.

dns.rcode.NOERROR = Rcode.NOERROR
dns.rcode.FORMERR = Rcode.FORMERR
dns.rcode.SERVFAIL = Rcode.SERVFAIL
dns.rcode.NXDOMAIN = Rcode.NXDOMAIN
dns.rcode.NOTIMP = Rcode.NOTIMP
dns.rcode.REFUSED = Rcode.REFUSED
dns.rcode.YXDOMAIN = Rcode.YXDOMAIN
dns.rcode.YXRRSET = Rcode.YXRRSET
dns.rcode.NXRRSET = Rcode.NXRRSET
dns.rcode.NOTAUTH = Rcode.NOTAUTH
dns.rcode.NOTZONE = Rcode.NOTZONE
dns.rcode.BADVERS = Rcode.BADVERS
dns.rcode.from_text(text: str) Rcode[source]

Convert text into an rcode.

text, a str, the textual rcode or an integer in textual form.

Raises dns.rcode.UnknownRcode if the rcode mnemonic is unknown.

Returns a dns.rcode.Rcode.

dns.rcode.to_text(value: Rcode, tsig: bool = False) str[source]

Convert rcode into text.

value, a dns.rcode.Rcode, the rcode.

Raises ValueError if rcode is < 0 or > 4095.

Returns a str.

dns.rcode.from_flags(flags: int, ednsflags: int) Rcode[source]

Return the rcode value encoded by flags and ednsflags.

flags, an int, the DNS flags field.

ednsflags, an int, the EDNS flags field.

Raises ValueError if rcode is < 0 or > 4095

Returns a dns.rcode.Rcode.

dns.rcode.to_flags(value: Rcode) Tuple[int, int][source]

Return a (flags, ednsflags) tuple which encodes the rcode.

value, a dns.rcode.Rcode, the rcode.

Raises ValueError if rcode is < 0 or > 4095.

Returns an (int, int) tuple.