src/dnsprotocol/types

Source   Edit  

Types

Additionals = seq[ResourceRecord]
It is an alias for seq[ResourceRecord] Source   Edit  
Answers = seq[ResourceRecord]
It is an alias for seq[ResourceRecord] Source   Edit  
Authorities = seq[ResourceRecord]
It is an alias for seq[ResourceRecord] Source   Edit  
BinMsg = string
Binary DNS protocol message. Source   Edit  
CAAFlags {.size: 1.} = object
  
Source   Edit  
Class {.pure, size: 2.} = enum
  IN = 1,                   ## The Internet
  CS = 2,                   ## The CSNET class (Obsolete - used only for examples in some obsolete RFCs)
  CH = 3,                   ## The CHAOS class - not supported
  HS = 4                     ## Hesiod [Dyer 87] - not supported
Appear in resource records. Source   Edit  
Flags = object
  qr*: QR                    ## A one bit field that specifies whether this message is a query (0), or a response (1).
  opcode*: OpCode            ## A four bit field that specifies kind of query in this message. This value is set by the originator of a query and copied into the response.
  aa*: bool                  ## Authoritative Answer - this bit is valid in responses, and specifies that the responding name server is an authority for the domain name in question section. Note that the contents of the answer section may have multiple owner names because of aliases. The AA bit corresponds to the name which matches the query name, or the first owner name in the answer section.
  tc*: bool                  ## TrunCation - specifies that this message was truncated due to length greater than that permitted on the transmission channel.
  rd*: bool                  ## Recursion Desired - this bit may be set in a query and is copied into the response. If RD is set, it directs the name server to pursue the query recursively. Recursive query support is optional.
  ra*: bool                  ## Recursion Available - this be is set or cleared in a response, and denotes whether recursive query support is available in the name server.
  z*: uint8                  ## Reserved for future use.  Must be zero in all queries and responses.
  rcode*: RCode              ## Response code - this 4 bit field is set as part of responses.
  
Source   Edit  
Message = object
  header*: Header            ## The header includes fields that specify which of the remaining sections are present, and also specify whether the message is a query or a response, a standard query or some other opcode, etc.
  questions*: Questions      ## The question for the name server
  answers*: Answers          ## Resource records answering the question
  authorities*: Authorities  ## Resource records pointing toward an authority
  additionals*: Additionals  ## Resource records holding additional information
  
All communications inside of the domain protocol are carried in a single format called a message. The top level format of message is divided into 5 sections (some of which are empty in certain cases) shown below: Source   Edit  
OpCode {.pure.} = enum
  Query = 0,                ## A standard query
  IQuery = 1,               ## An inverse query (Obsolete - RFC-3425)
  Status = 2                 ## A server status request
A four bit field that specifies kind of query in this message. This value is set by the originator of a query and copied into the response. The values are: Source   Edit  
OPTOption = object
  code*: uint16              ## Assigned by the Expert Review process as defined by the DNSEXT working group and the IESG.
  data*: string              ## Varies per OPTION-CODE. MUST be treated as a bit field.
  
Source   Edit  
QClass {.pure, size: 2.} = enum
  IN = 1,                   ## The Internet
  CS = 2,                   ## The CSNET class (Obsolete - used only for examples in some obsolete RFCs)
  CH = 3,                   ## The CHAOS class - not supported
  HS = 4,                   ## Hesiod [Dyer 87] - not supported
  ANY = 255                  ## Any class
Appear in the question section of a query. Source   Edit  
QR {.pure.} = enum
  Query = 0,                ## Message is a query
  Response = 1               ## Message is a response
A one bit field that specifies whether this message is a query (0), or a response (1). Source   Edit  
QType {.pure, size: 2.} = enum
  A = 1,                    ## A host address
  NS = 2,                   ## An authoritative name server
  MD = 3,                   ## A mail destination (Obsolete - use MX)
  MF = 4,                   ## A mail forwarder (Obsolete - use MX)
  CNAME = 5,                ## The canonical name for an alias
  SOA = 6,                  ## Marks the start of a zone of authority
  MB = 7,                   ## A mailbox domain name (EXPERIMENTAL)
  MG = 8,                   ## A mail group member (EXPERIMENTAL)
  MR = 9,                   ## A mail rename domain name (EXPERIMENTAL)
  NULL = 10,                ## A null RR (EXPERIMENTAL)
  WKS = 11,                 ## A well known service description
  PTR = 12,                 ## A domain name pointer
  HINFO = 13,               ## Host information
  MINFO = 14,               ## Mailbox or mail list information
  MX = 15,                  ## Mail exchange
  TXT = 16,                 ## Text strings
  AAAA = 28,                ## Host IPv6 address - RFC-1886
  SRV = 33,                 ## Location of services - RFC-2782
  OPT = 41,                 ## OPT pseudo-RR (meta-RR) - RFC-6891
  IXFR = 251,               ## Incremental zone transfer - RFC-1995
  AXFR = 252,               ## A request for a transfer of an entire zone
  MAILB = 253,              ## A request for mailbox-related records (MB, MG or MR)
  MAILA = 254,              ## A request for mail agent RRs (Obsolete - see MX)
  ANY = 255,                ## A request for all records
  CAA = 257                  ## Certification Authority Restriction - RFC-8659
Appear in the question part of a query. Source   Edit  
Question = object
  qname*: string             ## A domain name represented as a sequence of labels, where each label consists of a length octet followed by that number of octets. The domain name terminates with the zero length octet for the null label of the root. Note that this field may be an odd number of octets; no padding is used.
  qtype*: QType              ## A two octet code which specifies the type of the query. The values for this field include all codes valid for a TYPE field, together with some more general codes which can match more than one type of RR.
  qclass*: QClass            ## A two octet code that specifies the class of the query. For example, the QCLASS field is IN for the Internet.
  
The question contains fields that describe a question to a name server. Source   Edit  
Questions = seq[Question]
It is an alias for seq[Question] Source   Edit  
RCode {.pure.} = enum
  NoError = 0,              ## No error condition
  FormatError = 1,          ## The name server was unable to interpret the query.
  ServerFailure = 2,        ## The name server was unable to process this query due to a problem with the name server.
  NameError = 3,            ## Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist.
  NotImplemented = 4,       ## The name server does not support the requested kind of query.
  Refused = 5,              ## 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.
  BADVERSorBADSIG = 16       ## Bad OPT Version RFC-6891 or TSIG Signature Failure RFC-8945
Response code - this 4 bit field is set as part of responses. RR OPT brings 8 bits as an extension of RCode RFC-6891. Source   Edit  
RData = ref object of RootObj
A variable length string of octets that describes the resource. The format of this information varies according to the TYPE and CLASS of the resource record. Source   Edit  
RDataA = ref object of RData
  address*: array[4, uint8]  ## A 32 bit Internet address.
  
Source   Edit  
RDataAAAA = ref object of RData
  address*: array[16, uint8] ## A 128 bit IPv6 address is encoded in the data portion of an AAAA resource record in network byte order (high-order byte first).
  
Source   Edit  
RDataCAA = ref object of RData
  flags*: CAAFlags
  tagLength*: uint8          ## A single octet containing an unsigned integer specifying the tag length in octets. The tag length MUST be at least 1.
  tag*: string               ## A non-zero-length sequence of ASCII letters and numbers in lowercase.
  value*: string             ## A sequence of octets representing the Property Value. Property Values are encoded as binary values and MAY employ sub-formats.
  
Source   Edit  
RDataCNAME = ref object of RData
  cname*: string             ## A <domain-name> which specifies the canonical or primary name for the owner.  The owner name is an alias.
  
Source   Edit  
RDataHINFO = ref object of RData
  cpu*: string               ## A <character-string> which specifies the CPU type.
  os*: string                ## A <character-string> which specifies the operating system type.
  
Source   Edit  
RDataMB = ref object of RData
  madname*: string
Source   Edit  
RDataMD = ref object of RData
  madname*: string           ## A <domain-name> which specifies a host which has a mail agent for the domain which should be able to deliver mail for the domain.
  
Source   Edit  
RDataMF = ref object of RData
  madname*: string           ## A <domain-name> which specifies a host which has a mail agent for the domain which will accept mail for forwarding to the domain.
  
Source   Edit  
RDataMG = ref object of RData
  mgmname*: string           ## A <domain-name> which specifies a mailbox which is a member of the mail group specified by the domain name.
  
Source   Edit  
RDataMINFO = ref object of RData
  rmailbx*: string           ## A <domain-name> which specifies a mailbox which is responsible for the mailing list or mailbox.  If this domain name names the root, the owner of the MINFO RR is responsible for itself.  Note that many existing mailing lists use a mailbox X-request for the RMAILBX field of mailing list X, e.g., Msgroup-request for Msgroup.  This field provides a more general mechanism.
  emailbx*: string           ## A <domain-name> which specifies a mailbox which is to receive error messages related to the mailing list or mailbox specified by the owner of the MINFO RR (similar to the ERRORS-TO: field which has been proposed).  If this domain name names the root, errors should be returned to the sender of the message.
  
Source   Edit  
RDataMR = ref object of RData
  newname*: string           ## A <domain-name> which specifies a mailbox which is the proper rename of the specified mailbox.
  
Source   Edit  
RDataMX = ref object of RData
  preference*: uint16        ## A 16 bit integer which specifies the preference given to this RR among others at the same owner.  Lower values are preferred.
  exchange*: string          ## A <domain-name> which specifies a host willing to act as a mail exchange for the owner name.
  
Source   Edit  
RDataNS = ref object of RData
  nsdname*: string           ## A <domain-name> which specifies a host which should be authoritative for the specified class and domain.
  
Source   Edit  
RDataNULL = ref object of RData
  anything*: string          ## Anything at all may be in the RDATA field so long as it is 65535 octets or less.
  
Source   Edit  
RDataOPT = ref object of RData
  options*: seq[OPTOption]   ## May contain zero or more `OPTOption`
  
Source   Edit  
RDataPTR = ref object of RData
  ptrdname*: string          ## A <domain-name> which points to some location in the domain name space.
  
Source   Edit  
RDataSOA = ref object of RData
  mname*: string             ## The <domain-name> of the name server that was the original or primary source of data for this zone.
  rname*: string             ## A <domain-name> which specifies the mailbox of the person responsible for this zone.
  serial*: uint32            ## The unsigned 32 bit version number of the original copy of the zone.  Zone transfers preserve this value.  This value wraps and should be compared using sequence space arithmetic.
  refresh*: uint32           ## A 32 bit time interval before the zone should be refreshed.
  retry*: uint32             ## A 32 bit time interval that should elapse before a failed refresh should be retried.
  expire*: uint32            ## A 32 bit time value that specifies the upper limit on the time interval that can elapse before the zone is no longer authoritative.
  minimum*: uint32           ## The unsigned 32 bit minimum TTL field that should be exported with any RR from this zone.
  
Source   Edit  
RDataSRV = ref object of RData
  priority*: uint16          ## The priority of this target host.  A client MUST attempt to contact the target host with the lowest-numbered priority it can reach; target hosts with the same priority SHOULD be tried in an order defined by the weight field.  The range is 0-65535.  This is a 16 bit unsigned integer in network byte order.
  weight*: uint16            ## A server selection mechanism.  The weight field specifies a relative weight for entries with the same priority. Larger weights SHOULD be given a proportionately higher probability of being selected. The range of this number is 0-65535.  This is a 16 bit unsigned integer in network byte order.
  port*: uint16              ## The port on this target host of this service.  The range is 0- 65535.  This is a 16 bit unsigned integer in network byte order.
  target*: string            ## A <domain-name> which specifies a host willing to act as a mail exchange for the owner name.
  
Source   Edit  
RDataTXT = ref object of RData
  txtdata*: seq[string]      ## One or more <character-string>s
  
Source   Edit  
RDataUnknown = ref object of RData
  data*: string              ## Stores all data in the rdata field according to rdlength
  
Source   Edit  
RDataWKS = ref object of RData
  address*: array[4, uint8]  ## An 32 bit Internet address
  protocol*: uint8           ## An 8 bit IP protocol number
  bitmap*: string            ## A variable length bit map. The bit map must be a multiple of 8 bits long.
  
Source   Edit  
ResourceRecord = object
  name*: string              ## An owner name, i.e., the name of the node to which this resource record pertains.
  rdlength*: uint16          ## An unsigned 16 bit integer that specifies the length in octets of the RDATA field.
  rdata*: RData              ## A variable length string of octets that describes the resource. The format of this information varies according to the TYPE and CLASS of the resource record.
  
The answer, authority, and additional sections all share the same format: a variable number of resource records, where the number of records is specified in the corresponding count field in the header. Source   Edit  
Type {.pure, size: 2.} = enum
  Reserved0 = 0,            ## Reserved - to work the `case` in `ResourceRecord`
  A = 1,                    ## A host address
  NS = 2,                   ## An authoritative name server
  MD = 3,                   ## A mail destination (Obsolete - use MX)
  MF = 4,                   ## A mail forwarder (Obsolete - use MX)
  CNAME = 5,                ## The canonical name for an alias
  SOA = 6,                  ## Marks the start of a zone of authority
  MB = 7,                   ## A mailbox domain name (EXPERIMENTAL)
  MG = 8,                   ## A mail group member (EXPERIMENTAL)
  MR = 9,                   ## A mail rename domain name (EXPERIMENTAL)
  NULL = 10,                ## A null RR (EXPERIMENTAL)
  WKS = 11,                 ## A well known service description
  PTR = 12,                 ## A domain name pointer
  HINFO = 13,               ## Host information
  MINFO = 14,               ## Mailbox or mail list information
  MX = 15,                  ## Mail exchange
  TXT = 16,                 ## Text strings
  AAAA = 28,                ## Host IPv6 address - RFC-1886
  SRV = 33,                 ## Location of services - RFC-2782
  OPT = 41,                 ## OPT pseudo-RR (meta-RR) - RFC-6891
  CAA = 257                  ## Certification Authority Authorization - RFC-8659
Are used in resource records. Source   Edit