dns

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2018 License: MIT, BSD-3-Clause Imports: 9 Imported by: 0

README

package dns

This package provides an installer and an implementation of a DNS server that can serve requests for a given list of tlds.

If you configure the server to work with test then any DNS lookup that ends with .test will resolve to localhost. Eg. example.test.

Credits

The majority of the code for this package was extracted from https://github.com/puma/puma-dev.

Documentation

Overview

Example
package main

import (
	"fmt"
	"log"

	"github.com/moomerman/zap/dns"
)

func main() {

	port := 9253
	domains := []string{"test", "dev"}

	if err := dns.ConfigureResolver(domains, port, "example"); err != nil {
		log.Println(err)
		panic("couldn't configure resolver")
	}

	var dns dns.Responder
	dns.Address = fmt.Sprintf("127.0.0.1:%d", port)
	log.Println("* DNSServer", dns.Address)

	dns.Serve(domains)
}
Output:

Index

Examples

Constants

View Source
const DefaultAddress = ":9253"

DefaultAddress is the default address for the DNS server

Variables

This section is empty.

Functions

func ConfigureResolver

func ConfigureResolver(domains []string, port int, name string) error

ConfigureResolver configures the system to resolve the domains

Types

type Responder

type Responder struct {
	Address string
	Domains []string
	// contains filtered or unexported fields
}

Responder holds the configuration for the DNS server

func (*Responder) Serve

func (d *Responder) Serve()

Serve starts the DNS server

func (*Responder) Stop added in v0.3.1

func (d *Responder) Stop()

Stop stops the DNS servers

Jump to

Keyboard shortcuts

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