1
0
mirror of https://github.com/golang/go synced 2024-11-21 23:14:40 -07:00

net: add LookupMX

R=rsc
CC=golang-dev
https://golang.org/cl/1976049
This commit is contained in:
Corey Thomasson 2010-08-26 13:32:45 -04:00 committed by Russ Cox
parent 4d903504b3
commit ec72f9bf18

View File

@ -335,3 +335,22 @@ func LookupSRV(name string) (cname string, addrs []*SRV, err os.Error) {
}
return
}
type MX struct {
Host string
Pref uint16
}
func LookupMX(name string) (entries []*MX, err os.Error) {
var records []dnsRR
_, records, err = lookup(name, dnsTypeMX)
if err != nil {
return
}
entries = make([]*MX, len(records))
for i := 0; i < len(records); i++ {
r := records[i].(*dnsRR_MX)
entries[i] = &MX{r.Mx, r.Pref}
}
return
}