From ec72f9bf18c95cc79b81627433f4ac2995581d50 Mon Sep 17 00:00:00 2001 From: Corey Thomasson Date: Thu, 26 Aug 2010 13:32:45 -0400 Subject: [PATCH] net: add LookupMX R=rsc CC=golang-dev https://golang.org/cl/1976049 --- src/pkg/net/dnsclient.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/pkg/net/dnsclient.go b/src/pkg/net/dnsclient.go index 619d9e2e031..18bd72c3f16 100644 --- a/src/pkg/net/dnsclient.go +++ b/src/pkg/net/dnsclient.go @@ -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 +}