mileusna/spf

panic: interface conversion: dns.RR is *dns.CNAME, not *dns.A

Closed this issue · 1 comments

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", "name@teicee.fr", "")
    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/spf@v0.9.4/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/spf@v0.9.4/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/spf@v0.9.4/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/spf@v0.9.4/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/spf@v0.9.4/spf.go:60 +0xb0
main.main()
        /tmp/test/main.go:12 +0x4d
exit status 2

I will take a look, panic is not an option, but keep in mind that CNAMEs are not allowed in MX records, according to RFC974, RFC1034 3.6.2, RFC1912 2.4, and RFC2181 10.3.

https://intodns.com/teicee.fr