2018-12-05 21:13:29 +08:00
|
|
|
package dns
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
D "github.com/miekg/dns"
|
|
|
|
)
|
|
|
|
|
2019-06-28 12:29:08 +08:00
|
|
|
type client struct {
|
|
|
|
*D.Client
|
2018-12-05 21:13:29 +08:00
|
|
|
Address string
|
|
|
|
}
|
|
|
|
|
2019-06-28 12:29:08 +08:00
|
|
|
func (c *client) Exchange(m *D.Msg) (msg *D.Msg, err error) {
|
|
|
|
return c.ExchangeContext(context.Background(), m)
|
2018-12-05 21:13:29 +08:00
|
|
|
}
|
|
|
|
|
2019-06-28 12:29:08 +08:00
|
|
|
func (c *client) ExchangeContext(ctx context.Context, m *D.Msg) (msg *D.Msg, err error) {
|
2020-01-10 14:13:44 +08:00
|
|
|
// Please note that miekg/dns ExchangeContext doesn't respond to context cancel.
|
2019-06-28 12:29:08 +08:00
|
|
|
msg, _, err = c.Client.ExchangeContext(ctx, m, c.Address)
|
|
|
|
return
|
2018-12-05 21:13:29 +08:00
|
|
|
}
|