Allow supplying a Conn in Transfer struct
- This allows a user to call `Dial` before they call `Transfer.In`, thus specifying the attributes of a [Dialer](https://golang.org/src/net/dial.go?s=5630:5708#L17) before their AXFR - Add some docs to Transfer.in to show the functionality closes #264
This commit is contained in:
parent
60a765d35b
commit
0eeb50cbb8
18
xfr.go
18
xfr.go
|
@ -23,14 +23,26 @@ type Transfer struct {
|
||||||
// Think we need to away to stop the transfer
|
// 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
|
||||||
|
// of a Dialer for a Transfer, you can do so by specifying the attributes
|
||||||
|
// in the Transfer.Conn:
|
||||||
|
//
|
||||||
|
// d := net.Dialer{LocalAddr: transfer_source}
|
||||||
|
// con, _ := d.Dial("tcp", *master)
|
||||||
|
// dnscon := &dns.Conn{Conn:con}
|
||||||
|
// transfer = &dns.Transfer{Conn: dnscon}
|
||||||
|
// channel, err := transfer.In(message, *master)
|
||||||
|
//
|
||||||
func (t *Transfer) In(q *Msg, a string) (env chan *Envelope, err error) {
|
func (t *Transfer) In(q *Msg, a string) (env chan *Envelope, err error) {
|
||||||
timeout := dnsTimeout
|
timeout := dnsTimeout
|
||||||
if t.DialTimeout != 0 {
|
if t.DialTimeout != 0 {
|
||||||
timeout = t.DialTimeout
|
timeout = t.DialTimeout
|
||||||
}
|
}
|
||||||
t.Conn, err = DialTimeout("tcp", a, timeout)
|
if t.Conn == nil {
|
||||||
if err != nil {
|
t.Conn, err = DialTimeout("tcp", a, timeout)
|
||||||
return nil, err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err := t.WriteMsg(q); err != nil {
|
if err := t.WriteMsg(q); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in New Issue