mileusna / spf Goto Github PK
View Code? Open in Web Editor NEWGo package for SPF record check
License: MIT License
Go package for SPF record check
License: MIT License
I might be mistaken here or maybe I'm overlooking something. If so, feel free to close the issue again. However, please take a look at the following example:
func main() {
result := spf.CheckHost(net.ParseIP("213.203.238.1"), "mailbox.org", "[email protected]", "")
println(result) // outputs NONE
}
However, the SPF record for mailbox.org
looks like so:
v=spf1 ip4:213.203.238.0/25 ip4:195.10.208.0/24 ip4:91.198.250.0/24 ip4:80.241.56.0/21 ip6:2001:67c:2050::/48 ip4:80.241.60.0/24 mx ~all
Without being too familiar with SPF, I would expect that 213.203.238.1
is well within the allowed range and the lookup should return a PASS
?
I'd like to be able to manually set the resolver server.
Hello,
I bumped into that issue. It looks like a CNAME cause the problem somewhere but I can't tell exactly where.
I may be due to the fact that MX records are CNAMEs:
mx6.teicee.com is an alias for pmg3.teicee.fr.
mx4.teicee.com is an alias for pmg1.teicee.fr.
mx5.teicee.com is an alias for pmg2.teicee.fr.
Source code to reproduce:
package main
import (
"net"
"fmt"
"github.com/mileusna/spf"
)
func main() {
ip := net.ParseIP("123.123.123.123")
r := spf.CheckHost(ip, "teicee.fr", "[email protected]", "")
fmt.Printf("status: %s\n", r)
}
traceback:
panic: interface conversion: dns.RR is *dns.CNAME, not *dns.A
goroutine 1 [running]:
github.com/mileusna/spf.lookupA({0xc00001c7d0?, 0x668940?})
/home/sirius/go/pkg/mod/github.com/mileusna/[email protected]/resolver.go:70 +0x185
github.com/mileusna/spf.(*check).check(0x0?, {0xc00001c6e0?, 0x10, 0x10}, {0xc00001c7d0?, 0x10?}, {0x0, 0x0}, {0xc00002454a, 0x1})
/home/sirius/go/pkg/mod/github.com/mileusna/[email protected]/spf.go:158 +0xa7
github.com/mileusna/spf.(*check).checkMX(0x6ddcde?, {0xc00001c6e0, 0x10, 0x10}, {0x6759e2?, 0x203000?}, {0x0, 0x0}, {0xc00002454a, 0x1})
/home/sirius/go/pkg/mod/github.com/mileusna/[email protected]/spf.go:213 +0x145
github.com/mileusna/spf.(*check).checkHost(0xc000125f00, {0xc00001c6e0, 0x10, 0x10}, {0x6759e2, 0x9}, {0x676e68, 0xe})
/home/sirius/go/pkg/mod/github.com/mileusna/[email protected]/spf.go:85 +0x4b4
github.com/mileusna/spf.CheckHost({0xc00001c6e0?, 0xc000032000?, 0x404e5c?}, {0x6759e2?, 0x407899?}, {0x676e68?, 0x401230?}, {0x0?, 0x0?})
/home/sirius/go/pkg/mod/github.com/mileusna/[email protected]/spf.go:60 +0xb0
main.main()
/tmp/test/main.go:12 +0x4d
exit status 2
Hello,
I bumped into a case similar to issue #5 but not caugth in v0.9.5.
It would be nice to have the same warning.
Traceback:
panic: interface conversion: dns.RR is *dns.CNAME, not *dns.MX
goroutine 1 [running]:
github.com/mileusna/spf.lookupMX({0xc00003777a?, 0x47fb89?})
/home/nico/go/pkg/mod/github.com/mileusna/[email protected]/resolver.go:112 +0x145
github.com/mileusna/spf.(*check).checkMX(0x868138?, {0xc0003eb380, 0x10, 0x10}, {0xc00003777a?, 0x4bdc26?}, {0x0, 0x0}, {0x0, 0x0})
/home/nico/go/pkg/mod/github.com/mileusna/[email protected]/spf.go:207 +0x66
github.com/mileusna/spf.(*check).checkHost(0xc00052fcc8, {0xc0003eb380, 0x10, 0x10}, {0xc0000bbe6b, 0xb}, {0xc0000bbf80, 0x11})
/home/nico/go/pkg/mod/github.com/mileusna/[email protected]/spf.go:85 +0x47b
github.com/mileusna/spf.CheckHost({0xc0003eb380?, 0x8?, 0xc00052fd90?}, {0xc0000bbe6b?, 0x1?}, {0xc0000bbf80?, 0x7b47c0?}, {0x0?, 0xc00039fda8?})
/home/nico/go/pkg/mod/github.com/mileusna/[email protected]/spf.go:60 +0xb0
main.main()
/home/nico/dev/checkspf/main.go:124 +0x435
exit status 2
Code:
package main
import (
"net"
"fmt"
"github.com/mileusna/spf"
)
func main() {
ip := net.ParseIP("123.123.123.123")
r := spf.CheckHost(ip, "annonces.fr", "[email protected]", "")
fmt.Printf("status: %s\n", r)
}
SPF is the following:
v=spf1 mx:www.annonces.fr mx:smtp.triplemind.com mx:mx.fluxgrid.net ?all
Thank you for your help
Regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.