From 6a0d899027cde832631e8fe1576b84cd263dfa85 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Fri, 15 Apr 2022 10:07:43 +0200 Subject: [PATCH] Fix examples by using net.JoinHostPort Small fix in the examples to properly work with v6 addresses. Closes: #1365 #1367 Signed-off-by: Miek Gieben --- example_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/example_test.go b/example_test.go index 71cc8899c..0138f617a 100644 --- a/example_test.go +++ b/example_test.go @@ -16,7 +16,7 @@ func ExampleMX() { m := new(dns.Msg) m.SetQuestion("miek.nl.", dns.TypeMX) m.RecursionDesired = true - r, _, err := c.Exchange(m, config.Servers[0]+":"+config.Port) + r, _, err := c.Exchange(m, net.JoinHostPort(config.Servers[0], config.Port)) if err != nil { return } @@ -39,7 +39,7 @@ func ExampleDS() { zone := "miek.nl" m.SetQuestion(dns.Fqdn(zone), dns.TypeDNSKEY) m.SetEdns0(4096, true) - r, _, err := c.Exchange(m, config.Servers[0]+":"+config.Port) + r, _, err := c.Exchange(m, net.JoinHostPort(config.Servers[0], config.Port)) if err != nil { return } @@ -64,6 +64,7 @@ type APAIR struct { func NewAPAIR() dns.PrivateRdata { return new(APAIR) } func (rd *APAIR) String() string { return rd.addr[0].String() + " " + rd.addr[1].String() } + func (rd *APAIR) Parse(txt []string) error { if len(txt) != 2 { return errors.New("two addresses required for APAIR")