dnsserver

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

dnsserver - a simple DNS service toolkit

(This repository is adapted from docker/dnsserver by the original author)

This provides a very basic API for programming a DNS service that serves over UDP only. A records and simple SRV records are currently supported, although this may change in the future.

Stability

This should be considered moderately stable software; it has been used in several production environments in slightly modified form.

Documentation

You can find comprehensive documentation in the source comments or at the URL below:

http://godoc.org/github.com/erikh/dnsserver

Dependencies

License

We use the Apache 2.0 License as with all public Docker projects. You can read this here.

Contribution Guidelines

  • Fork the project and send a pull request
  • Please do not modify any license or version information.
  • Thanks!

Maintainer

Erik Hollensbe github@hollensbe.org

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server added in v0.2.0

type Server struct {
	// contains filtered or unexported fields
}

Server is the struct which describes the DNS server.

func New added in v0.2.0

func New(domain string) *Server

New creates a new DNS server. Domain is an unqualified domain that will be used as the TLD.

func NewWithDB added in v0.2.0

func NewWithDB(domain string, db db.DB) *Server

NewWithDB allows you to provide a custom DB implementation during construction.

func (*Server) Close added in v0.2.0

func (ds *Server) Close() error

Close closes the DNS server. If it is not started, nil is returned.

func (*Server) DeleteA added in v0.2.0

func (ds *Server) DeleteA(host string) error

DeleteA deletes a host. Note that this is not the FQDN, but a hostname.

func (*Server) DeleteSRV added in v0.2.0

func (ds *Server) DeleteSRV(service, protocol string) error

DeleteSRV deletes a SRV record based on the service and protocol.

func (*Server) GetA added in v0.2.0

func (ds *Server) GetA(name string) []*dns.A

GetA receives a FQDN; looks up and supplies the A record.

func (*Server) GetSRV added in v0.2.0

func (ds *Server) GetSRV(spec string) []*dns.SRV

GetSRV given a service spec, looks up and returns an array of *dns.SRV objects. These must be massaged into the []dns.RR after the fact.

func (*Server) ListA added in v0.2.0

func (ds *Server) ListA() (map[string]net.IP, error)

ListA lists all A records.

func (*Server) ListSRV added in v0.2.0

func (ds *Server) ListSRV() (map[string]*db.SRVRecord, error)

ListSRV lists all SRV records.

func (*Server) Listen added in v0.2.0

func (ds *Server) Listen(listenSpec string) error

Listen for DNS requests. listenSpec is a dotted-quad + port, e.g., 127.0.0.1:53. This function blocks and only returns when the DNS service is no longer functioning.

func (*Server) Listening added in v0.2.0

func (ds *Server) Listening() (net.IP, uint)

Listening returns the ip:port of the listener.

func (*Server) ServeDNS added in v0.2.0

func (ds *Server) ServeDNS(w dns.ResponseWriter, r *dns.Msg)

ServeDNS is the main callback for miekg/dns. Collects information about the query, constructs a response, and returns it to the connector.

func (*Server) SetA added in v0.2.0

func (ds *Server) SetA(host string, ip net.IP) error

SetA sets a host to an IP. Note that this is not the FQDN, but a hostname.

func (*Server) SetSRV added in v0.2.0

func (ds *Server) SetSRV(service, protocol string, srv *db.SRVRecord) error

SetSRV sets a SRV with a service and protocol. See SRVRecord for more information on what that requires.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL