dispatch

package module
v1.10.1-v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: MIT Imports: 21 Imported by: 0

README

dispatch

A coredns plugin for dispatch request to other upstream by matched domain.

Syntax

dispatch FROM... {
    to TO...
    
    healthcheck DURATION
    maxfails INTEGER
}
  • FROM... is the file list which contains base domain to match for the request to be redirected. URL can also be used.

    .(i.e. root zone) can be used solely to match all incoming requests as a fallback.

    Two kind of formats are supported currently:

    • DOMAIN, which the whole line is the domain name.

    • server=/DOMAIN/..., which is the format of dnsmasq config file, note that only the DOMAIN will be honored, other fields will be simply discarded.

    Text after # character will be treated as comment.

    Unparsable lines(including whitespace-only line) are therefore just ignored.

  • to TO... are the destination endpoints to redirected to. This is a mandatory option.

    The to syntax allows you to specify a protocol, a port, etc:

    [dns://]IP[:PORT] use protocol specified in incoming DNS requests, it may UDP or TCP.

    [udp://]IP:[:PORT] use UDP protocol for DNS query, even if request comes in TCP.

    [tcp://]IP:[:PORT] use TCP protocol for DNS query, even if request comes in UDP.

    tls://IP[:PORT][@TLS_SERVER_NAME] for DNS over TLS, if you combine : and @, @ must come last. Be aware of some DoT servers require TLS server name as a mandatory option.

    json-doh://URL use JSON DNS over HTTPS for DNS query.

    ietf-doh://URL use IETF(RFC 8484) DNS over HTTPS for DNS query.

    doh://URL randomly choose JSON or IETF DNS over HTTPS for DNS query, make sure the upstream host support both of type.

    Example:

    dns://1.1.1.1
    8.8.8.8
    tcp://9.9.9.9
    udp://2606:4700:4700::1111
    
    tls://1.1.1.1@one.one.one.one
    tls://8.8.8.8
    tls://dns.quad9.net
    
    doh://cloudflare-dns.com/dns-query
    json-doh://1.1.1.1/dns-query
    json-doh://dns.google/resolve
    ietf-doh://dns.quad9.net/dns-query
    

Example

.:53 {
    dispatch https://expample.com/dnsmasq-dns.conf custom-domain.conf {
        to 1.1.1.1 tls://1.1.1.1@one.one.one.one
        
        healthcheck 10s
        maxfails 5
        reload 24h
    }
    dispatch home.conf {
        to 10.1.1.10:53
    }
    forward . 8.8.8.8 
}

Documentation

Index

Constants

View Source
const (
	DomainTreeMatchALl = 0x01
)

Variables

This section is empty.

Functions

func Error

func Error(err error) error

Types

type Dispatch

type Dispatch struct {
	Next     plugin.Handler
	Matchers []*Matcher
}

func (*Dispatch) Name

func (d *Dispatch) Name() string

func (*Dispatch) OnShutdown

func (d *Dispatch) OnShutdown() error

func (*Dispatch) OnStartup

func (d *Dispatch) OnStartup() error

func (*Dispatch) ServeDNS

func (d *Dispatch) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

type Domain

type Domain string

func (Domain) Next

func (d Domain) Next() Domain

func (Domain) Top

func (d Domain) Top() Domain

type DomainTree

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

func NewDomainTree

func NewDomainTree() (dt *DomainTree)

func NewTreeFromFile

func NewTreeFromFile(file string) (*DomainTree, error)

func NewTreeFromReader

func NewTreeFromReader(reader io.Reader) (*DomainTree, error)

func NewTreeFromUrl

func NewTreeFromUrl(url string) (*DomainTree, error)

func (*DomainTree) Has

func (dt *DomainTree) Has(d string) bool

func (*DomainTree) Insert

func (dt *DomainTree) Insert(d string)

func (*DomainTree) Merge

func (dt *DomainTree) Merge(other *DomainTree)

type Matcher

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

func NewMatchers

func NewMatchers(c *caddy.Controller) ([]*Matcher, error)

func (*Matcher) Start

func (m *Matcher) Start()

func (*Matcher) Stop

func (m *Matcher) Stop()

Directories

Path Synopsis
Package proxy implements a forwarding proxy.
Package proxy implements a forwarding proxy.

Jump to

Keyboard shortcuts

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