Categorygithub.com/cmol/dns
modulepackage
0.0.0-20240901130552-9bf60eba0d19
Repository: https://github.com/cmol/dns.git
Documentation: pkg.go.dev

# README

DNS

DNS is a hands on library for DNS message parsing and building in Golang for those who would like to control the details of DNS messages.

Prerequisites

This library is not a DNS server. You can build a DNS server with this library, but it is not handled by the library itself. This means that you need a basic knowledge of DNS to use this library, though examples will be provided.

Installation

Add import to your application:

import "github.com/cmol/dns"

Usage

// Read a DNS message query from a 'bytes.Buffer'
query, err = dns.ParseMessage(buffer)

// Make a reply struct to said message
reply = dns.ReplyTo(query)

// Add EDNS information to the message
reply.Additional = []dns.Record{*dns.DefaultOpt(1024)}

// Create output buffer and build message in the buffer
buf := new(bytes.Buffer)
err = reply.Build(buf, dns.NewDomains())

// Send out the message on an existing remote connection
n, err = connection.WriteToUDP(buf.Bytes(), remoteAddr)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

New Resource Record parsers and builders are welcome, but

Please make sure to update tests as appropriate.

Supported Resource Record types

Current list of supported RR types, though I will add more as I use the library:

  • A
  • AAAA
  • CNAME
  • OPT
  • TXT
  • SRV
  • PTR

More types are welcome! Please add tests and references to the standard in the PR.

License

MIT

# Packages

No description provided by the author

# Functions

BuildName returns a dns encoded name with pointers if possible.
DefaultOpt returns a standard OPT record.
NewDomains returns a new map for parsing and building.
ParseMessage creates a new Message containing parsed DNS information from buf.
ParseName returns a name given a pointer.
ParseQuestion parses DNS question records.
ParseRecord is the generic entry to parsing all records.
ReplyTo creates a reply Message from a Message.

# Constants

List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
CacheFlushBit holds the bit for the mDNS cache flush instruction.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
HdrLength is the length of a DNS message header.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
IN is the standard class.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
NamePointer indication byte.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
OptAa describes weither a response came from the authoritative server.
OptQr describes if the message is a query (0) or response (1).
OptRa describes if recursion is available.
OptRd describes if recursion is desired.
OptTc describes if the messages was truncated.
PointerMask is the reverse of the indication byte for 16 bits.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
List of all DNS type constants.
UnicastResponseBit holds the bit for the mDNS unicast response.
List of all DNS type constants.
List of all DNS type constants.

# Variables

RRTypeStrings holds name mapping for DNS type constants.

# Structs

CName implements interface RData.
Domains holds maps for parsing and building CNAME pointers.
IPv4 implements interface RData.
IPv6 implements interface RData.
Message is the structure of an entire DNS message including subtypes.
Opt implements interface for RDATA.
Ptr implements interface RData.
Question holds single dns questions.
Record struct used by record specific types.
Srv implements interface RData.
Txt implements interface RData.

# Interfaces

RData interface for all record types.

# Type aliases

No description provided by the author
No description provided by the author