Skip to content

Commit

Permalink
New func InTLS
Browse files Browse the repository at this point in the history
Perform zone transfer via TLS
  • Loading branch information
Cesar Kuroiwa committed Jan 31, 2024
1 parent 21ba49c commit 9a65062
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions xfr.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dns

import (
"crypto/tls"
"fmt"
"time"
)
Expand Down Expand Up @@ -78,6 +79,41 @@ func (t *Transfer) In(q *Msg, a string) (env chan *Envelope, err error) {
return env, nil
}

// Analogous to In, but perform a zone transfer via TLS
func (t *Transfer) InTLS(q *Msg, a string, tlsConfig *tls.Config) (env chan *Envelope, err error) {
switch q.Question[0].Qtype {
case TypeAXFR, TypeIXFR:
default:
return nil, &Error{"unsupported question type"}
}

timeout := dnsTimeout
if t.DialTimeout != 0 {
timeout = t.DialTimeout
}

if t.Conn == nil {
t.Conn, err = DialTimeoutWithTLS("tcp-tls", a, tlsConfig, timeout)
if err != nil {
return nil, err
}
}

if err := t.WriteMsg(q); err != nil {
return nil, err
}

env = make(chan *Envelope)
switch q.Question[0].Qtype {
case TypeAXFR:
go t.inAxfr(q, env)
case TypeIXFR:
go t.inIxfr(q, env)
}

return env, nil
}

func (t *Transfer) inAxfr(q *Msg, c chan *Envelope) {
first := true
defer func() {
Expand Down

0 comments on commit 9a65062

Please sign in to comment.