Last active
August 8, 2016 21:15
-
-
Save nathanleclaire/47657140ce0005b90bdea7443e784b10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"github.com/miekg/dns" | |
) | |
const ( | |
service = "servers" | |
dockerDNSServer = "127.0.0.11:53" | |
) | |
func main() { | |
m := &dns.Msg{} | |
m.SetQuestion("tasks."+service+".", dns.TypeA) | |
c := &dns.Client{} | |
in, _, err := c.Exchange(m, dockerDNSServer) | |
if err != nil { | |
log.Panic(err) | |
} | |
for _, answer := range in.Answer { | |
if a, ok := answer.(*dns.A); ok { | |
fmt.Println(a.A) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment