GithubHelp home page GithubHelp logo

gospf's Introduction

GoSPF

Build Status

Sender Policy Framework for Go

Usage

Get GoSPF and run all unit test:

$ go get github.com/gopistolet/gospf
$ cd $GOPATH/src/github.com/gopistolet/gospf
$ go test ./...

Command line tool

Compile the code:

$ go build -o spf github.com/gopistolet/gospf/gospf

You can run GoSPF in the console to validate an IP address against a domain: ./spf domain ip ["debug"]. e.g.:

$ ./spf google.com 66.249.80.0

With debug flag added, GoSPF will output the whole parsed SPF object.

Library

GoSPF is meant to be included in other projects. To use GoSPF you must create a new SPF instance (witch takes a domain and a gospf/dns interface). Once you have the SPF instance you can call CheckIP(ip string) on it, which will return a response following RFC 7208 2.6. Results of Evaluation (i.e. Neutral, Pass, SoftFail, Fail, ...)

Example:

package main

import (
    "fmt"
    "github.com/gopistolet/gospf"
    "github.com/gopistolet/gospf/dns"
)

func main() {

    domain := "google.com"
    ip     := "66.249.80.0"

    // create SPF instance
    spf, err := gospf.New(domain, &dns.GoSPFDNS{})
    if err != nil {
        fmt.Println(err)
        return
    }

    // check the given IP on that instance
    check, err := spf.CheckIP(ip)
    if err != nil {
        fmt.Println(err)
        return
    }

    fmt.Println(ip, "->", check)

}

Implementation

Directives
GoSPF supports all, include, a, mx, ip4 and ip6 mechanisms with the respective qualifiers +, ?, ~ and -. All implemented as defined in RFC 7208. Support for exists mechanism isn't implemented yet. Support for ptr mechanism is no priority:

Use of the ptr mechanism and the %p macro has been strongly discouraged (Sections 5.5 and 7.2). The ptr mechanism and the %p macro remain part of the protocol because they were found to be in use, but records ought to be updated to avoid them.

Modifiers
Currently only support for redirect modifier. (Other modifiers won't cause parse errors.)

Macros
Macros aren't supported (yet).

License

GoSPF is licensed under the BSD 2-clause “Simplified” License.

Author

Mathias Beke - denbeke.be

gospf's People

Contributors

denbeke avatar trtstm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.