Class: Net::DNS::Header::RCode
- Inherits:
-
Object
- Object
- Net::DNS::Header::RCode
- Defined in:
- lib/net/dns/header.rb
Overview
DNS Header RCode handling class
It should be used internally by Net::DNS::Header class. However, it’s still possible to instantiate it directly.
require 'net/dns/header'
rcode = Net::DNS::Header::RCode.new 0
The RCode class represents the RCode field in the Header portion of a DNS packet. This field (called Response Code) is used to get informations about the status of a DNS operation, such as a query or an update. These are the values in the original Mockapetris’s standard (RFC1035):
-
0 No error condition
-
1 Format error - The name server was unable to interpret
the query.
-
2 Server failure - The name server was
unable to process this query due to a problem with the name server.
-
3 Name Error - Meaningful only for
responses from an authoritative name server, this code means that the domain name referenced in the query does not exist.
-
4 Not Implemented - The name server does
not support the requested kind of query.
-
5 Refused - The name server refuses to
perform the specified operation for policy reasons. For example, a name server may not wish to provide the information to the particular requester, or a name server may not wish to perform a particular operation (e.g., zone transfer) for particular data.
-
6-15 Reserved for future use.
In the next DNS RFCs, codes 6-15 has been assigned to the following errors:
-
6 YXDomain
-
7 YXRRSet
-
8 NXRRSet
-
9 NotAuth
-
10 NotZone
More RCodes has to come for TSIGs and other operations.
Constant Summary collapse
- NOERROR =
Constant for
rcode
Response Code No Error 0
- FORMAT =
Constant for
rcode
Response Code Format Error 1
- SERVER =
Constant for
rcode
Response Code Server Format Error 2
- NAME =
Constant for
rcode
Response Code Name Error 3
- NOTIMPLEMENTED =
Constant for
rcode
Response Code Not Implemented Error 4
- REFUSED =
Constant for
rcode
Response Code Refused Error 5
- RCodeType =
%w[NoError FormErr ServFail NXDomain NotImp Refused YXDomain YXRRSet NXRRSet NotAuth NotZone].freeze
- RCodeErrorString =
["No errors", "The name server was unable to interpret the query", "The name server was unable to process this query due to problem with the name server", "Domain name referenced in the query does not exists", "The name server does not support the requested kind of query", "The name server refuses to perform the specified operation for policy reasons", "", "", "", "", "",].freeze
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#explanation ⇒ Object
readonly
Returns the value of attribute explanation.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(code) ⇒ RCode
constructor
A new instance of RCode.
- #to_s ⇒ Object
Constructor Details
#initialize(code) ⇒ RCode
Returns a new instance of RCode.
135 136 137 138 139 140 141 |
# File 'lib/net/dns/header.rb', line 135 def initialize(code) raise ArgumentError, "RCode `#{code}' out of range" unless (0..10).cover? code @code = code @type = RCodeType[code] @explanation = RCodeErrorString[code] end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
131 132 133 |
# File 'lib/net/dns/header.rb', line 131 def code @code end |
#explanation ⇒ Object (readonly)
Returns the value of attribute explanation.
133 134 135 |
# File 'lib/net/dns/header.rb', line 133 def explanation @explanation end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
132 133 134 |
# File 'lib/net/dns/header.rb', line 132 def type @type end |
Instance Method Details
#to_s ⇒ Object
143 144 145 |
# File 'lib/net/dns/header.rb', line 143 def to_s @code.to_s end |