dnsserver

package module
v0.0.0-...-5d11eac Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2014 License: Apache-2.0 Imports: 4 Imported by: 0

README

dnsserver - a simple DNS service toolkit

This provides a very basic API for programming a DNS service that serves over UDP. Single A (non-RR) records and SRV records are currently supported, although this may change in the future.

Stability

This should be considered alpha quality software and is currently not suitable for production use.

Documentation

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

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

Usage

There is an example program here.

Dependencies

github.com/miekg/dns

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 DNSServer

type DNSServer struct {
	Domain string // using the constructor, this will always end in a '.', making it a FQDN.
	// contains filtered or unexported fields
}

Struct which describes the DNS server.

func NewDNSServer

func NewDNSServer(domain string) *DNSServer

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

func (*DNSServer) DeleteA

func (ds *DNSServer) DeleteA(host string)

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

func (*DNSServer) DeleteSRV

func (ds *DNSServer) DeleteSRV(service, protocol string)

Deletes a SRV record based on the service and protocol.

func (*DNSServer) GetA

func (ds *DNSServer) GetA(fqdn string) *dns.A

Receives a FQDN; looks up and supplies the A record.

func (*DNSServer) GetSRV

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

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 (*DNSServer) Listen

func (ds *DNSServer) 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 (*DNSServer) ServeDNS

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

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

func (*DNSServer) SetA

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

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

func (*DNSServer) SetSRV

func (ds *DNSServer) SetSRV(service, protocol string, srvs []SRVRecord)

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

type SRVRecord

type SRVRecord struct {
	Port uint16
	Host string
}

Encapsulates the data segment of a SRV record. Priority and Weight are always 0 in our SRV records.

func (SRVRecord) Equal

func (s SRVRecord) Equal(s2 SRVRecord) bool

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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