oneaddr

package module
v0.0.0-...-954d332 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

oneaddr

Name

oneaddr - filters response and retains only one (first) address

Description

oneaddr will remove all addresses from response except first one. It is intended to be used with loadbalance plugin.

Syntax

oneaddr

Examples

Let's consider following configuration for example.org zone. We aim to enable round-robin loadbalancing, but ensure fair distribution and reveal just one worker server in the DNS response.

Zone file db.example.org:

$ORIGIN example.org.
@	3600 IN	SOA sns.dns.icann.org. noc.dns.icann.org. 2017042745 7200 3600 1209600 3600
	3600 IN NS a.iana-servers.net.
	3600 IN NS b.iana-servers.net.

www     IN A     127.0.0.1
www     IN A     127.0.0.2
www     IN A     127.0.0.3
www     IN A     127.0.0.4
www     IN A     127.0.0.5
www     IN A     127.0.0.6
www     IN A     127.0.0.7
www     IN A     127.0.0.8
www     IN A     127.0.0.9
www     IN A     127.0.0.10

CoreDNS configuration:

example.org {
	file db.example.org
	loadbalance
	oneaddr
}

With such configuration only one A-record will be present in the DNS response. Since loadbalance module randomizes order and oneaddr picks first address, IP address in the responses will vary and distribute load across worker servers.

Documentation

Overview

Package oneaddr is a plugin for rewriting responses to retain only single address

Package oneaddr is a plugin for rewriting responses to retain only single address

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OneAddr

type OneAddr struct {
	Next plugin.Handler
}

OneAddr is a plugin to rewrite responses to retain only first address in the response.

func (OneAddr) Name

func (oa OneAddr) Name() string

Name implements the Handler interface.

func (OneAddr) ServeDNS

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

ServeDNS implements the plugin.Handler interface.

type OneAddrResponseWriter

type OneAddrResponseWriter struct {
	dns.ResponseWriter
}

OneAddrResponseWriter is a response writer that shuffles A, AAAA and MX records.

func (*OneAddrResponseWriter) Write

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

Write implements the dns.ResponseWriter interface.

func (*OneAddrResponseWriter) WriteMsg

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

WriteMsg implements the dns.ResponseWriter interface.

Jump to

Keyboard shortcuts

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