dns

package module
v0.1.1 Latest Latest
Warning

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

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

README

dns

Implements a working macOS DNS resolver (really just a Dialer) for projects that must cross-compile from Linux systems or just don't want CGO.

In my experience, it is common to disable CGO for macOS CI builds. However, there's been a few issues with that. This library adds a drop-in replacement for Go's net.DefaultResolver to fill the gap.

import _ "github.com/johnstarich/go/dns/init"

This resolver reads the system's full DNS configuration and attempts to find the a successful nameserver. First, the dialer reaches out to the default nameserver. If the response isn't fast enough, more nameservers are attempted simultaneously.

On non-macOS builds a normal resolver is used, so this is safe to use for multi-platform builds.

Thoughts or questions? Please open an issue to discuss.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() *net.Resolver

func NewWithConfig

func NewWithConfig(config Config) *net.Resolver

Types

type Config

type Config struct {
	Logger                 *zap.Logger
	InitialNameserverDelay time.Duration
	NextNameserverInterval time.Duration
}

type Dialer

type Dialer interface {
	DialContext(ctx context.Context, network, address string) (net.Conn, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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