dns

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: MIT Imports: 2 Imported by: 1

README

DNS - Simple DNS Client and Server

PkgGoDev Build Status Go Report Card Coverage Status GitHub issues Release

Installation

To install the package, run:

go get github.com/go-zoox/dns

Getting Started

func main() {
	server := dns.NewServer(&dns.ServerOptions{
		Port: 53,
	})
	client := dns.NewClient()

	server.Handle(func(host string, typ int) ([]string, error) {
		key := fmt.Sprintf("%s_%d", host, typ)

		if host == "gozoox.com" {
			return []string{"6.6.6.6"}, nil
		}

		if ips, err := client.LookUp(host, &dns.LookUpOptions{Typ: typ}); err != nil {
			return nil, err
		} else {
			logger.Info("found host(%s %d) %v", host, typ, ips)
			return ips, nil
		}
	})

	server.Serve()
}

Features

Client
  • Plain DNS
    • Plain DNS in UDP
    • Plain DNS in TCP
  • DNS-over-TLS (DoT)
  • DNS-over-HTTPS (DoH)
  • DNS-over-QUIC (DoQ)
  • DNSCrypt
Server
  • Plain DNS
    • Plain DNS in UDP
    • Plain DNS in TCP
  • DNS-over-TLS (DoT)
  • DNS-over-HTTPS (DoH)
  • DNS-over-QUIC (DoQ)

Inspired By

License

GoZoox is released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "1.2.0"

Version is the version of dns

Functions

func NewClient

func NewClient(options ...*ClientOptions) *client.Client

NewClient creates a new DNS client

func NewServer

func NewServer(options ...*ServerOptions) *server.Server

NewServer creates a new DNS server

Types

type ClientOptions

type ClientOptions = client.Options

ClientOptions is an alias for client.Options

type ServerOptions

type ServerOptions = server.Options

ServerOptions is an alias for server.Options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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