Skip to content

Commit

Permalink
Merge branch 'main' of github.com:dnstapir/tem
Browse files Browse the repository at this point in the history
  • Loading branch information
johanix committed Jun 5, 2024
2 parents 15c3000 + 762d6ab commit 8a765b6
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions xfr.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,20 @@ func (td *TemData) RpzAxfrOut(w dns.ResponseWriter, r *dns.Msg) (uint32, int, er
if count >= 500 {
send_count++
total_sent += len(rrs)
// fmt.Printf("Sending %d RRs\n", len(rrs))
outbound_xfr <- &dns.Envelope{RR: rrs}
// tmprrs := new([]dns.RR)
// rrs = *tmprrs
rrs = []dns.RR{}
// fmt.Printf("Sent %d RRs: done\n", len(rrs))
count = 0
}
}

rrs = append(rrs, dns.RR(&td.Rpz.Axfr.SOA)) // trailing SOA

total_sent += len(rrs)
// td.Logger.Printf("RpzAxfrOut: Zone %s: Sending final %d RRs (including trailing SOA, total sent %d). First is %s",
// zone, len(env.RR), total_sent, env.RR[0].String())
// td.Logger.Printf("RpzAxfrOut: Zone %s: Sending final %d RRs (including trailing SOA, total sent %d)\n",
// zone, len(rrs), total_sent)
outbound_xfr <- &dns.Envelope{RR: rrs}
td.Logger.Printf("RpzAxfrOut: Sent final %d RRs: done. Last was %s", len(rrs), rrs[len(rrs)-1].String())

close(outbound_xfr)
wg.Wait() // wait until everything is written out
Expand Down Expand Up @@ -217,12 +216,12 @@ func (td *TemData) RpzIxfrOut(w dns.ResponseWriter, r *dns.Msg) (uint32, int, er
wg.Done()
}()

env := dns.Envelope{}
rrs := []dns.RR{}

var total_sent int

td.Rpz.Axfr.SOA.Serial = td.Rpz.CurrentSerial
env.RR = append(env.RR, dns.RR(&td.Rpz.Axfr.SOA))
rrs = append(rrs, dns.RR(&td.Rpz.Axfr.SOA))

var totcount, count int
var finalSerial uint32
Expand All @@ -238,23 +237,23 @@ func (td *TemData) RpzIxfrOut(w dns.ResponseWriter, r *dns.Msg) (uint32, int, er
if td.Debug {
td.Logger.Printf("IxfrOut: adding FROMSOA to output: %s", fromsoa.String())
}
env.RR = append(env.RR, fromsoa)
rrs = append(rrs, fromsoa)
count++
td.Logger.Printf("RpzIxfrOut: IXFR[%d,%d] has %d RRs in the removal list",
ixfr.FromSerial, ixfr.ToSerial, len(ixfr.Removed))
for _, tn := range ixfr.Removed {
if td.Debug {
td.Logger.Printf("DEL: adding RR to ixfr output: %s", tn.Name)
}
env.RR = append(env.RR, *tn.RR) // should do proper slice magic instead
rrs = append(rrs, *tn.RR) // should do proper slice magic instead
count++
if count >= 500 {
td.Logger.Printf("Sending %d RRs\n", len(env.RR))
for _, rr := range env.RR {
td.Logger.Printf("Sending %d RRs\n", len(rrs))
for _, rr := range rrs {
td.Logger.Printf("SEND DELS: %s", rr.String())
}
outbound_xfr <- &env
env = dns.Envelope{}
outbound_xfr <- &dns.Envelope{RR: rrs}
rrs = []dns.RR{}
totcount += count
count = 0
}
Expand All @@ -264,42 +263,42 @@ func (td *TemData) RpzIxfrOut(w dns.ResponseWriter, r *dns.Msg) (uint32, int, er
if td.Debug {
td.Logger.Printf("RpzIxfrOut: adding TOSOA to output: %s", tosoa.String())
}
env.RR = append(env.RR, tosoa)
rrs = append(rrs, tosoa)
count++
td.Logger.Printf("RpzIxfrOut: IXFR[%d,%d] has %d RRs in the added list",
ixfr.FromSerial, ixfr.ToSerial, len(ixfr.Added))
for _, tn := range ixfr.Added {
if td.Debug {
td.Logger.Printf("ADD: adding RR to ixfr output: %s", tn.Name)
}
env.RR = append(env.RR, *tn.RR) // should do proper slice magic instead
rrs = append(rrs, *tn.RR) // should do proper slice magic instead
count++
if count >= 500 {
td.Logger.Printf("Sending %d RRs\n", len(env.RR))
for _, rr := range env.RR {
td.Logger.Printf("Sending %d RRs\n", len(rrs))
for _, rr := range rrs {
td.Logger.Printf("SEND ADDS: %s", rr.String())
}
outbound_xfr <- &env
// fmt.Printf("Sent %d RRs: done\n", len(env.RR))
env = dns.Envelope{}
outbound_xfr <- &dns.Envelope{RR: rrs}
// fmt.Printf("Sent %d RRs: done\n", len(rrs))
rrs = []dns.RR{}
totcount += count
count = 0
}
}
}
}

env.RR = append(env.RR, dns.RR(&td.Rpz.Axfr.SOA)) // trailing SOA
rrs = append(rrs, dns.RR(&td.Rpz.Axfr.SOA)) // trailing SOA

total_sent += len(env.RR)
total_sent += len(rrs)
td.Logger.Printf("RpzIxfrOut: Zone %s: Sending final %d RRs (including trailing SOA, total sent %d)\n",
zone, len(env.RR), total_sent)
zone, len(rrs), total_sent)

// td.Logger.Printf("Sending %d RRs\n", len(env.RR))
// for _, rr := range env.RR {
// td.Logger.Printf("Sending %d RRs\n", len(rrs))
// for _, rr := range rrs {
// td.Logger.Printf("SEND FINAL: %s", rr.String())
// }
outbound_xfr <- &env
outbound_xfr <- &dns.Envelope{RR: rrs}

close(outbound_xfr)
wg.Wait() // wait until everything is written out
Expand Down

0 comments on commit 8a765b6

Please sign in to comment.