alias

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

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

Go to latest
Published: Oct 22, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

README

alias

The alias plugin eliminates CNAME records from zone apex by making the subsequent resolved records look like they belong to the zone apex. This behaves similarily to CloudFlare's Zone Flattening.

This plugin only works with the file middleware with upstream set, or when A or AAAA records exist alongside the CNAME record.

Preferrably, this should not be used in favour of the RFC drafts for the new ANAME records, but the DNS library used by CoreDNS does not support ANAME records yet.

Syntax

alias

Examples

example.com {
  file example.com.db {
    upstream 8.8.8.8
  }
  alias
}

All it does is transform records like this:

;; ANSWER SECTION:
example.com.	300	IN	CNAME	some.magic.example.org.
some.magic.example.org. 299 IN A	123.123.45.67

into

;; ANSWER SECTION:
example.com.	299	IN	A	123.123.45.67

Installation

$ go get github.com/coredns/coredns
$ go get github.com/serverwentdown/alias
$ cd $GOPATH/src/github.com/coredns/coredns
$ vim plugin.cfg
# Add the line alias:github.com/serverwentdown/alias before the file middleware
$ go generate
$ go build
$ ./coredns -plugins | grep alias

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alias

type Alias struct {
	Next plugin.Handler
}

Rewrite is plugin to rewrite requests internally before being handled.

func (Alias) Name

func (al Alias) Name() string

Name implements the Handler interface.

func (Alias) ServeDNS

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

ServeDNS implements the plugin.Handler interface.

type ResponseModifier

type ResponseModifier struct {
	dns.ResponseWriter
}

func NewResponseModifier

func NewResponseModifier(w dns.ResponseWriter) *ResponseModifier

Returns a dns.Msg modifier that replaces CNAME on root zones with other records.

func (*ResponseModifier) Hijack

func (r *ResponseModifier) Hijack()

Hijack implements dns.Hijacker. It simply wraps the underlying ResponseWriter's Hijack method if there is one, or returns an error.

func (*ResponseModifier) Write

func (r *ResponseModifier) Write(buf []byte) (int, error)

Write is a wrapper that records the size of the message that gets written.

func (*ResponseModifier) WriteMsg

func (r *ResponseModifier) WriteMsg(res *dns.Msg) error

WriteMsg records the status code and calls the underlying ResponseWriter's WriteMsg method.

Jump to

Keyboard shortcuts

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