spf

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

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

Go to latest
Published: Nov 12, 2018 License: BSD-2-Clause-Views Imports: 7 Imported by: 0

README

README.md

Status

GitHub release GitHub issues Go Version Build Status GoDoc SemVer License Go Report Card

A few functions related to SPF usage.

Installation

As with many Go utilities, a simple

go get github.com/keltia/spf

is enough to fetch, build and install.

Dependencies

  • Go >= 1.10

Only standard Go modules are used. I use Semantic Versioning for all my modules.

Usage

SYNOPSIS


    d, err := NewDomain("example.net")
    err := d.Fetch()
    
    // Recursively unroll SPF records (0 = no limit)
    blocks, err := d.Unroll(0)
    
    You can have more verbose output and debug by using these functions:
    
    spf.SetVerbose()
    spf.SetDebug()      // implies verbose
    ...
    spf.Reset()         // both flags are cleared

Tests

I'm trying to get to 100% coverage but some error cases are more difficult to create.

NOTE

There are several SPF-related modules in the Go community but what I want mostly (unraveling the chain) is not there (see https://godoc.org/blitiri.com.ar/go/spf).

License

This is released under the BSD 2-Clause license. See LICENSE.md.

Contributing

This project is an open Open Source project, please read CONTRIBUTING.md.

Feedback

We welcome pull requests, bug fixes and issue reports.

Before proposing a large change, first please discuss your change by raising an issue.

I use Git Flow for this package so please use something similar or the usual github workflow.

  1. Fork it ( https://github.com/keltia/spf/fork )
  2. Checkout the develop branch (git checkout develop)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reset

func Reset()

Reset is for the two flags

func SetDebug

func SetDebug()

SetDebug sets the mode too

func SetVerbose

func SetVerbose()

SetVerbose sets the mode

func Version

func Version() string

Version returns our current version

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context is used to switch resolvers (and test/mock)

type Domain

type Domain struct {
	Name string
	Raw  string
	// contains filtered or unexported fields
}

Domain represents a given SPF RR and the IPs behind

func NewDomain

func NewDomain(dom string) (*Domain, error)

NewDomain creates a Domain object

func (*Domain) Fetch

func (d *Domain) Fetch() error

Fetch gets the SPF TXT RR

func (*Domain) FetchMX

func (d *Domain) FetchMX() ([]string, error)

FetchMX gets the MX RR

func (*Domain) Unroll

func (d *Domain) Unroll(limit int) (*Result, error)

Unroll does recursively fetch & unroll SPF (by default

type ErrorResolver

type ErrorResolver struct{}

ErrorResolver always returns an error

func (ErrorResolver) LookupHost

func (ErrorResolver) LookupHost(host string) ([]string, error)

LookupHost is for forward resolving

func (ErrorResolver) LookupMX

func (r ErrorResolver) LookupMX(addr string) ([]*net.MX, error)

LookupMX use the real "net" function

func (ErrorResolver) LookupTXT

func (ErrorResolver) LookupTXT(s string) ([]string, error)

LookupTXT is for testing errors

type NullResolver

type NullResolver struct{}

NullResolver is empty

func (NullResolver) LookupHost

func (NullResolver) LookupHost(host string) ([]string, error)

LookupHost is for forward resolving

func (NullResolver) LookupMX

func (NullResolver) LookupMX(addr string) ([]*net.MX, error)

LookupMX use the real "net" function

func (NullResolver) LookupTXT

func (NullResolver) LookupTXT(addr string) ([]string, error)

LookupTXT always return a good and fixed answer

type RealResolver

type RealResolver struct{}

RealResolver will call the real one

func (RealResolver) LookupHost

func (RealResolver) LookupHost(host string) ([]string, error)

LookupHost is for forward resolving

func (RealResolver) LookupMX

func (RealResolver) LookupMX(addr string) ([]*net.MX, error)

LookupMX use the real "net" function

func (RealResolver) LookupTXT

func (RealResolver) LookupTXT(addr string) ([]string, error)

LookupTXT use the real "net" function

type Resolver

type Resolver interface {
	LookupHost(host string) ([]string, error)
	LookupMX(addr string) ([]*net.MX, error)
	LookupTXT(addr string) ([]string, error)
}

Resolver is the main interface we use

type Result

type Result struct {
	IPs []net.IPNet
	// contains filtered or unexported fields
}

Result is the main object used to recurse and store

func NewResult

func NewResult() *Result

func (*Result) AppendMX

func (r *Result) AppendMX(dom string) error

AppendMX gets all IP for the MXs

func (*Result) Condense

func (r *Result) Condense() []cidranger.RangerEntry

func (*Result) String

func (r *Result) String() string

String() is the basic Stringer

Directories

Path Synopsis
cmd
spfctl command

Jump to

Keyboard shortcuts

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