"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xfr.go" between
dns-1.1.45.tar.gz and dns-1.1.46.tar.gz

About: GO DNS implements a DNS library in Go.

xfr.go  (dns-1.1.45):xfr.go  (dns-1.1.46)
skipping to change at line 20 skipping to change at line 20
RR []RR // The set of RRs in the answer section of the xfr reply mess age. RR []RR // The set of RRs in the answer section of the xfr reply mess age.
Error error // If something went wrong, this contains the error. Error error // If something went wrong, this contains the error.
} }
// A Transfer defines parameters that are used during a zone transfer. // A Transfer defines parameters that are used during a zone transfer.
type Transfer struct { type Transfer struct {
*Conn *Conn
DialTimeout time.Duration // net.DialTimeout, defaults to 2 second s DialTimeout time.Duration // net.DialTimeout, defaults to 2 second s
ReadTimeout time.Duration // net.Conn.SetReadTimeout value for con nections, defaults to 2 seconds ReadTimeout time.Duration // net.Conn.SetReadTimeout value for con nections, defaults to 2 seconds
WriteTimeout time.Duration // net.Conn.SetWriteTimeout value for co nnections, defaults to 2 seconds WriteTimeout time.Duration // net.Conn.SetWriteTimeout value for co nnections, defaults to 2 seconds
TsigProvider TsigProvider // An implementation of the TsigProvider interface. If defined it replaces TsigSecret and is used for all TSIG operation s.
TsigSecret map[string]string // Secret(s) for Tsig map[<zonename>]<ba se64 secret>, zonename must be in canonical form (lowercase, fqdn, see RFC 4034 Section 6.2) TsigSecret map[string]string // Secret(s) for Tsig map[<zonename>]<ba se64 secret>, zonename must be in canonical form (lowercase, fqdn, see RFC 4034 Section 6.2)
tsigTimersOnly bool tsigTimersOnly bool
} }
// Think we need to away to stop the transfer func (t *Transfer) tsigProvider() TsigProvider {
if t.TsigProvider != nil {
return t.TsigProvider
}
if t.TsigSecret != nil {
return tsigSecretProvider(t.TsigSecret)
}
return nil
}
// TODO: Think we need to away to stop the transfer
// In performs an incoming transfer with the server in a. // In performs an incoming transfer with the server in a.
// If you would like to set the source IP, or some other attribute // If you would like to set the source IP, or some other attribute
// of a Dialer for a Transfer, you can do so by specifying the attributes // of a Dialer for a Transfer, you can do so by specifying the attributes
// in the Transfer.Conn: // in the Transfer.Conn:
// //
// d := net.Dialer{LocalAddr: transfer_source} // d := net.Dialer{LocalAddr: transfer_source}
// con, err := d.Dial("tcp", master) // con, err := d.Dial("tcp", master)
// dnscon := &dns.Conn{Conn:con} // dnscon := &dns.Conn{Conn:con}
// transfer = &dns.Transfer{Conn: dnscon} // transfer = &dns.Transfer{Conn: dnscon}
skipping to change at line 227 skipping to change at line 238
m := new(Msg) m := new(Msg)
p := make([]byte, MaxMsgSize) p := make([]byte, MaxMsgSize)
n, err := t.Read(p) n, err := t.Read(p)
if err != nil && n == 0 { if err != nil && n == 0 {
return nil, err return nil, err
} }
p = p[:n] p = p[:n]
if err := m.Unpack(p); err != nil { if err := m.Unpack(p); err != nil {
return nil, err return nil, err
} }
if ts := m.IsTsig(); ts != nil && t.TsigSecret != nil { if ts, tp := m.IsTsig(), t.tsigProvider(); ts != nil && tp != nil {
if _, ok := t.TsigSecret[ts.Hdr.Name]; !ok {
return m, ErrSecret
}
// Need to work on the original message p, as that was used to ca lculate the tsig. // Need to work on the original message p, as that was used to ca lculate the tsig.
err = TsigVerify(p, t.TsigSecret[ts.Hdr.Name], t.tsigRequestMAC, t.tsigTimersOnly) err = tsigVerifyProvider(p, tp, t.tsigRequestMAC, t.tsigTimersOnl y)
t.tsigRequestMAC = ts.MAC t.tsigRequestMAC = ts.MAC
} }
return m, err return m, err
} }
// WriteMsg writes a message through the transfer connection t. // WriteMsg writes a message through the transfer connection t.
func (t *Transfer) WriteMsg(m *Msg) (err error) { func (t *Transfer) WriteMsg(m *Msg) (err error) {
var out []byte var out []byte
if ts := m.IsTsig(); ts != nil && t.TsigSecret != nil { if ts, tp := m.IsTsig(), t.tsigProvider(); ts != nil && tp != nil {
if _, ok := t.TsigSecret[ts.Hdr.Name]; !ok { out, t.tsigRequestMAC, err = tsigGenerateProvider(m, tp, t.tsigRe
return ErrSecret questMAC, t.tsigTimersOnly)
}
out, t.tsigRequestMAC, err = TsigGenerate(m, t.TsigSecret[ts.Hdr.
Name], t.tsigRequestMAC, t.tsigTimersOnly)
} else { } else {
out, err = m.Pack() out, err = m.Pack()
} }
if err != nil { if err != nil {
return err return err
} }
_, err = t.Write(out) _, err = t.Write(out)
return err return err
} }
 End of changes. 5 change blocks. 
12 lines changed or deleted 17 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)