sts

package module
v0.0.0-...-1394ae6 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

README

SMTP-STS Validator

GoDoc

This is a simple library and command line tool implementing a primitive SMTP-STS validator.

The library has four commands:

     getdns     fetch the domain's policy *version* and print it
     getpolicy  fetch the domain's policy and print it
     getmxs     fetch the domain's policy and MXs, and filter the MXs against the policy, reporting any which are invalid
     testsmtp   fetch the domain's policy and MXs, filter the MXs, and test STARTTLS

Example usage:

$ ./bin/cli getdns yahoo.com                                                                                  
Version: 20161109010200Z
$ ./bin/cli getpolicy yahoo.com                                                                               
Policy: {1 [*.am0.yahoodns.net] 2016-11-14 11:16:30.414524442 +0000 UTC }
$ ./bin/cli getmxs yahoo.com                                                                                  
Policy: {1 [*.am0.yahoodns.net] 2016-11-14 11:16:51.858961329 +0000 UTC }
Matching MXes: 
        mta7.am0.yahoodns.net.  1
        mta5.am0.yahoodns.net.  1
        mta6.am0.yahoodns.net.  1
$ ./bin/cli testsmtp yahoo.com                                                                                
Policy: {1 [*.am0.yahoodns.net] 2016-11-14 11:17:05.269545742 +0000 UTC }
Matching MXes: 
        mta7.am0.yahoodns.net.  1
        mta5.am0.yahoodns.net.  1
        mta6.am0.yahoodns.net.  1
Testing MX mta7.am0.yahoodns.net....OK!
Testing MX mta5.am0.yahoodns.net....OK!
Testing MX mta6.am0.yahoodns.net....OK!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckMXViaSMTP

func CheckMXViaSMTP(mx *net.MX) error

CheckMXViaSMTP returns an error if a secure connection to the MX cannot be established.

func FilterMXs

func FilterMXs(mxs []*net.MX, policy Policy) (valid []*net.MX, err error)

FilterMXs tests if the MX records for "domain" are valid according to "policy." Returns valid MXes for the domain, and error if any are invalid according to the policy.

func PolicyVersionForDomain

func PolicyVersionForDomain(domain string) (string, error)

PolicyVersionForDomain fetches the policy version for a given domain.

Types

type Mode

type Mode int32

Mode can be Policy_ENFORCE, Policy_TESTING, or Policy_NONE.

const (
	Policy_ENFORCE Mode = iota
	Policy_TESTING
	Policy_NONE
)

type Policy

type Policy struct {
	Mode    Mode
	MXs     []string
	Expires time.Time
	Id      string
}

Policy represents a parsed policy.

func ParsePolicy

func ParsePolicy(raw string) (Policy, error)

ParsePolicy returns a Policy from a raw string, or error.

func PolicyForDomain

func PolicyForDomain(domain string) (Policy, error)

PolicyForDomain fetches the policy for a given domain.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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