mirror of
https://github.com/miekg/dns.git
synced 2025-12-16 09:11:34 +01:00
fix chaos
Perform the a and aaaa query in parallel
This commit is contained in:
parent
5721b8ff79
commit
60c66fa9ad
@ -1,12 +1,12 @@
|
|||||||
EXAMPLES=mx \
|
EXAMPLES=mx \
|
||||||
q \
|
|
||||||
chaos \
|
chaos \
|
||||||
axfr \
|
|
||||||
reflect \
|
|
||||||
xfrprx \
|
|
||||||
key2ds \
|
key2ds \
|
||||||
|
axfr
|
||||||
# funkensturm -- need fix
|
# these need to be fixed
|
||||||
|
#q \
|
||||||
|
#reflect \
|
||||||
|
#xfrprx \
|
||||||
|
#funkensturm
|
||||||
|
|
||||||
all:
|
all:
|
||||||
for i in $(EXAMPLES); do gomake -C $$i; done
|
for i in $(EXAMPLES); do gomake -C $$i; done
|
||||||
|
|||||||
@ -40,35 +40,46 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func qhandler(w dns.RequestWriter, m *dns.Msg) {
|
||||||
|
w.Send(m)
|
||||||
|
r, _ := w.Receive()
|
||||||
|
w.Write(r)
|
||||||
|
}
|
||||||
|
|
||||||
func addresses(conf *dns.ClientConfig, c *dns.Client, name string) []string {
|
func addresses(conf *dns.ClientConfig, c *dns.Client, name string) []string {
|
||||||
m := new(dns.Msg)
|
dns.HandleQueryFunc(os.Args[1], qhandler)
|
||||||
m.SetQuestion(os.Args[1], dns.TypeA) // Allocates space
|
dns.ListenAndQuery(nil, nil)
|
||||||
|
|
||||||
|
m4 := new(dns.Msg)
|
||||||
|
m4.SetQuestion(os.Args[1], dns.TypeA)
|
||||||
|
m6 := new(dns.Msg)
|
||||||
|
m6.SetQuestion(os.Args[1], dns.TypeAAAA)
|
||||||
|
c.Do(m4, conf.Servers[0]) // Also 1 and 2 (and merge the results??
|
||||||
|
c.Do(m6, conf.Servers[0])
|
||||||
|
|
||||||
var ips []string
|
var ips []string
|
||||||
|
i := 2 // two outstanding queries
|
||||||
r := c.Exchange(m, conf.Servers[0])
|
forever:
|
||||||
if r == nil {
|
for {
|
||||||
fmt.Printf("Nothing recevied for %s\n", name)
|
select {
|
||||||
return nil
|
case r := <-dns.DefaultReplyChan:
|
||||||
}
|
if r[1] !=nil && r[1].Rcode == dns.RcodeSuccess {
|
||||||
if r.Rcode != dns.RcodeSuccess {
|
for _, aa := range r[1].Answer {
|
||||||
return nil
|
switch aa.(type) {
|
||||||
}
|
case *dns.RR_A:
|
||||||
for _, a := range r.Answer {
|
ips = append(ips, aa.(*dns.RR_A).A.String()+":53")
|
||||||
ips = append(ips, a.(*dns.RR_A).A.String()+":53")
|
case *dns.RR_AAAA:
|
||||||
}
|
ips = append(ips, "[" + aa.(*dns.RR_AAAA).AAAA.String()+"]:53")
|
||||||
|
}
|
||||||
m.SetQuestion(os.Args[1], dns.TypeAAAA)
|
}
|
||||||
r = c.Exchange(m, conf.Servers[0])
|
} else {
|
||||||
if r == nil {
|
fmt.Printf("Nothing recevied for %s\n", name)
|
||||||
fmt.Printf("Nothing recevied for %s\n", name)
|
}
|
||||||
return ips
|
i--
|
||||||
}
|
if i == 0 {
|
||||||
if r.Rcode != dns.RcodeSuccess {
|
break forever
|
||||||
return ips
|
}
|
||||||
}
|
}
|
||||||
for _, a := range r.Answer {
|
}
|
||||||
ips = append(ips, "["+a.(*dns.RR_AAAA).AAAA.String()+"]:53")
|
|
||||||
}
|
|
||||||
|
|
||||||
return ips
|
return ips
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@ func helloMiek(w RequestWriter, r *Msg) {
|
|||||||
|
|
||||||
func TestClientASync(t *testing.T) {
|
func TestClientASync(t *testing.T) {
|
||||||
HandleQueryFunc("miek.nl", helloMiek) // All queries for miek.nl will be handled by HelloMiek
|
HandleQueryFunc("miek.nl", helloMiek) // All queries for miek.nl will be handled by HelloMiek
|
||||||
ListenAndQuery(nil, nil)
|
ListenAndQuery(nil, nil) // Detect if this isn't running
|
||||||
|
|
||||||
m := new(Msg)
|
m := new(Msg)
|
||||||
m.SetQuestion("miek.nl", TypeSOA)
|
m.SetQuestion("miek.nl", TypeSOA)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user