some changes, but doesnt make it work
This commit is contained in:
parent
d93e0341bb
commit
616312a0fb
|
@ -10,17 +10,16 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
c, _ := dns.ClientConfigFromFile("/etc/resolv.conf")
|
||||
config, _ := dns.ClientConfigFromFile("/etc/resolv.conf")
|
||||
if len(os.Args) != 2 {
|
||||
fmt.Printf("%s DOMAIN\n", os.Args[0])
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
m := new(dns.Msg)
|
||||
m.SetQuestion(
|
||||
m.Question = make([]dns.Question, 1)
|
||||
d := new(dns.Conn)
|
||||
d.RemoteAddr = c.Servers[0]
|
||||
for _, a := range addresses(d, os.Args[0]) {
|
||||
for _, a := range addresses(config, os.Args[0]) {
|
||||
d.RemoteAddr = a
|
||||
if err := d.Dial("udp"); err != nil {
|
||||
fmt.Printf("%v\n", err)
|
||||
|
@ -40,13 +39,12 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
func addresses(d *dns.Conn, name string) []string {
|
||||
func addresses(config *dns.ClientConfig, name string) []string {
|
||||
m := new(dns.Msg)
|
||||
m.SetQuestion(os.Args[1], dns.TypeA)
|
||||
m.MsgHdr.RecursionDesired = true //only set this bit
|
||||
m.Question = make([]dns.Question, 1)
|
||||
var ips []string
|
||||
|
||||
m.Question[0] = dns.Question{os.Args[1], dns.TypeA, dns.ClassINET}
|
||||
in, err := dns.SimpleQuery("udp", d, m)
|
||||
if in == nil {
|
||||
fmt.Printf("Nothing recevied: %s\n", err.String())
|
||||
|
|
Loading…
Reference in New Issue