spfmacro

package module
v0.0.0-...-c2d6479 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

README

spfmacro

Name

spfmacro - Takes a various number of SPF records and serves an SPF macro

Description

Compilation

This package will always be compiled as part of CoreDNS and not in a standalone way. It will require you to use go get or as a dependency on plugin.cfg.

The manual will have more information about how to configure and extend the server with external plugins.

A simple way to consume this plugin, is by adding the following on plugin.cfg, and recompile it as detailed on coredns.io.

spfmacro:github.com/slash2314/spfmacro

After this you can compile coredns by:

go generate
go build

Or you can instead use make:

make

Syntax

Examples
spfmacro txt:_despf.mail.example.com
spfmacro txt:amazonses.com txt:spf.protection.outlook.com

Configuration

Your actual SPF record can look like this

v=spf1 include:{i}.{d}._spf.example.com

where _spf.example.com is represented by the server that runs the coredns instance.

Metrics

If monitoring is enabled (via the prometheus directive) the following metric is exported:

  • coredns_spfmacro_request_count_total{server} - query count to the spfmacro plugin.

The server label indicated which server handled the request, see the metrics plugin for details.

Ready

This plugin reports readiness to the ready plugin. It will be immediately ready.

Examples

In this configuration, we set the domain that will send as to mail.example.com using SPF records from the listed services:

mail.example.com._spf.example.com:54 {
    log
    spfmacro txt:amazonses.com txt:spf.protection.outlook.com
}

This can be tested using the following dig:

dig 199.255.192.1.mail.example.com._spf.example.com TXT @127.0.0.1 -p 54

and it will return

;; ANSWER SECTION:
199.255.192.1.mail.example.com._spf.example.com. 30 IN TXT "v=spf1 -all"

Also See

See the manual.

Documentation

Overview

Package spfmacro is a CoreDNS plugin that allows to serve spf macros.

Index

Constants

View Source
const DnsLookupAddr = "9.9.9.9:53"

Variables

View Source
var CIDRPattern = regexp.MustCompile(`(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/?\d{0,2})`)
View Source
var DomainPattern = regexp.MustCompile(`((txt|a|include):[((www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*))`)

var IPWithDomainPattern = regexp.MustCompile(`(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\.([((www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*))\._`)

View Source
var IPPattern = regexp.MustCompile(`(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})`)

Functions

func CheckDomainValidity

func CheckDomainValidity(domains []string) bool

func ParseIPs

func ParseIPs(queryResult string) []net.IPNet

func RetrieveSPFIPs

func RetrieveSPFIPs(domains []string) ([]net.IPNet, error)

Types

type ResponsePrinter

type ResponsePrinter struct {
	dns.ResponseWriter
}

ResponsePrinter wrap a dns.ResponseWriter and will write example to standard output when WriteMsg is called.

func NewResponsePrinter

func NewResponsePrinter(w dns.ResponseWriter) *ResponsePrinter

NewResponsePrinter returns ResponseWriter.

func (*ResponsePrinter) WriteMsg

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

WriteMsg calls the underlying ResponseWriter's WriteMsg method and prints "example" to standard output.

type SPFEntry

type SPFEntry struct {
	Type  uint16
	Value string
}

func ParseSPFEntry

func ParseSPFEntry(domain string) SPFEntry

type SPFMacro

type SPFMacro struct {
	Next    plugin.Handler
	Domains []string
	Subnets []net.IPNet
	M       sync.RWMutex
	L       *rate.Limiter
}

SPFMacro is a plugin to serve SPF Macro compatible DNS

func (*SPFMacro) CreateAcceptSPFRecord

func (e *SPFMacro) CreateAcceptSPFRecord(state request.Request) dns.RR

func (*SPFMacro) Name

func (e *SPFMacro) Name() string

Name implements the Handler interface.

func (*SPFMacro) Ready

func (e *SPFMacro) Ready() bool

Ready implements the ready.Readiness interface, once this flips to true CoreDNS assumes this plugin is ready for queries; it is not checked again.

func (*SPFMacro) ServeDNS

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

ServeDNS implements the plugin.Handler interface. This method gets called when spfmacro is used in a Server.

func (*SPFMacro) ValidateSPFMacroIP

func (e *SPFMacro) ValidateSPFMacroIP(requestPattern string) bool

Jump to

Keyboard shortcuts

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