header

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: Apache-2.0 Imports: 8 Imported by: 6

README

header

Name

header - modifies the header for queries and responses.

Description

header ensures that the flags are in the desired state for queries and responses. The modifications are made transparently for the client and subsequent plugins.

Syntax

header {
    [SELECTOR] ACTION FLAGS...
    [SELECTOR] ACTION FLAGS...
}
  • SELECTOR defines if the action should be applied on query or response. In future CoreDNS version the selector will be mandatory. For backwards compatibility the action will be applied on response if the selector is undefined.

  • ACTION defines the state for DNS message header flags. Actions are evaluated in the order they are defined so last one has the most precedence. Allowed values are:

    • set
    • clear
  • FLAGS are the DNS header flags that will be modified. Current supported flags include:

    • aa - Authoritative(Answer)
    • ra - RecursionAvailable
    • rd - RecursionDesired

Examples

Make sure recursive available ra flag is set in all the responses:

. {
    header {
        response set ra
    }
}

Make sure "recursion available" ra and "authoritative answer" aa flags are set and "recursion desired" is cleared in all responses:

. {
    header {
        response set ra aa
        response clear rd
    }
}

Make sure "recursion desired" rd is set for all subsequent plugins::

. {
    header {
        query set rd
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Header struct {
	QueryRules    []Rule
	ResponseRules []Rule
	Next          plugin.Handler
}

Header modifies flags of dns.MsgHdr in queries and / or responses

func (Header) Name

func (h Header) Name() string

Name implements the plugin.Handler interface.

func (Header) ServeDNS

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

ServeDNS implements the plugin.Handler interface.

type ResponseHeaderWriter

type ResponseHeaderWriter struct {
	dns.ResponseWriter
	Rules []Rule
}

ResponseHeaderWriter is a response writer that allows modifying dns.MsgHdr

func (*ResponseHeaderWriter) Write

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

Write implements the dns.ResponseWriter interface.

func (*ResponseHeaderWriter) WriteMsg

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

WriteMsg implements the dns.ResponseWriter interface.

type Rule

type Rule struct {
	Flag  string
	State bool
}

Rule is used to set/clear Flag in dns.MsgHdr

Jump to

Keyboard shortcuts

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