cname

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

README

cname

The cname plugin eliminates CNAME records.

Syntax

cname

This will transform responses like this:

;; ANSWER SECTION:
example.com.		3600	IN	CNAME	two.example.org.
two.example.org.	3600	IN	CNAME	one.example.net.
one.example.net.	3600	IN	A	127.0.0.1

into

;; ANSWER SECTION:
example.com.		3600	IN	A	127.0.0.1

Installation

As per CoreDNS docs, there are two ways.

Build with compile-time configuration file
$ git clone https://github.com/coredns/coredns
$ cd coredns
$ vim plugin.cfg
# Add the line cname:github.com/iandri/cname before the file middleware
$ go generate
$ go build
$ ./coredns -plugins | grep cname
Build with external golang source code
$ git clone https://github.com/iandri/cname
$ cd cname/coredns
$ go build
$ ./coredns -plugins | grep cname

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cname

type Cname struct {
	Next plugin.Handler
}

Rewrite is plugin to rewrite requests internally before being handled.

func (Cname) Name

func (c Cname) Name() string

Name implements the Handler interface.

func (Cname) Ready

func (c Cname) Ready() bool

func (Cname) ServeDNS

func (c Cname) 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.

Directories

Path Synopsis
coredns module

Jump to

Keyboard shortcuts

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