Skip to content

Commit

Permalink
remove client network
Browse files Browse the repository at this point in the history
  • Loading branch information
phuslu committed Oct 18, 2024
1 parent 7b60e95 commit 4bcf902
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 13 deletions.
7 changes: 2 additions & 5 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@ type Dialer interface {

// Client is an UDP client that supports DNS protocol.
type Client struct {
// AddrPort specifies the network of dns connection.
Network string

// Address specifies the address of dns server.
Addr string

// Timeout
Timeout time.Duration

// Dialer specifies the dialer for creating TCP/UDP connections.
// If it is set, Network, AddrPort and Timeout will be ignored.
// If it is set, Addr and Timeout will be ignored.
Dialer Dialer
}

Expand All @@ -42,7 +39,7 @@ func (c *Client) exchange(ctx context.Context, req, resp *Message) error {
dialer = &net.Dialer{Timeout: c.Timeout}
}

conn, err := dialer.DialContext(ctx, c.Network, c.Addr)
conn, err := dialer.DialContext(ctx, "udp", c.Addr)
if err != nil {
return err
}
Expand Down
5 changes: 0 additions & 5 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func TestClientExchange(t *testing.T) {
}

client := &Client{
Network: "udp",
Addr: "1.1.1.1:53",
Timeout: 1 * time.Second,
}
Expand Down Expand Up @@ -51,7 +50,6 @@ func TestLookupCNAME(t *testing.T) {
host := "abc.phus.lu"

client := &Client{
Network: "udp",
Addr: "1.1.1.1:53",
Timeout: 1 * time.Second,
Dialer: &HTTPDialer{
Expand All @@ -69,7 +67,6 @@ func TestLookupTXT(t *testing.T) {
host := "phus.lu"

client := &Client{
Network: "udp",
Addr: "1.1.1.1:53",
Timeout: 1 * time.Second,
Dialer: &HTTPDialer{
Expand All @@ -87,7 +84,6 @@ func TestLookupNetIP(t *testing.T) {
host := "cloud.phus.lu"

client := &Client{
Network: "udp",
Addr: "1.1.1.1:53",
Timeout: 1 * time.Second,
Dialer: &HTTPDialer{
Expand All @@ -105,7 +101,6 @@ func TestLookupHTTPS(t *testing.T) {
host := "cloud.phus.lu"

client := &Client{
Network: "udp",
Addr: "1.1.1.1:53",
Timeout: 1 * time.Second,
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/fastdig/fastdig.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ func main() {
domain, qtype, server, options := parse(os.Args[1:])

client := &fastdns.Client{
Network: "udp",
Addr: net.JoinHostPort(server, "53"),
Addr: net.JoinHostPort(server, "53"),
}
if strings.HasPrefix(server, "https://") {
endpoint, err := url.Parse(server)
Expand Down
1 change: 0 additions & 1 deletion cmd/fastdoh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func main() {
DNSQuery: "/dns-query",
DNSHandler: &DNSHandler{
DNSClient: &fastdns.Client{
Network: "udp",
Addr: "1.1.1.1:53",
Timeout: 3 * time.Second,
},
Expand Down

0 comments on commit 4bcf902

Please sign in to comment.