1
0
Fork 0
mirror of https://github.com/SamTherapy/dnscrypt.git synced 2024-07-02 21:56:06 +00:00

fix timeout behavior

This commit is contained in:
Andrey Meshkov 2018-12-27 11:05:11 +03:00
parent 227ce1fa8f
commit 673d093636

View file

@ -57,7 +57,7 @@ const (
// Client contains parameters for a DNSCrypt client
type Client struct {
Proto string // Protocol ("udp" or "tcp"). Empty means "udp".
Timeout time.Duration // Timeout for read/write operations
Timeout time.Duration // Timeout for read/write operations (0 means infinite timeout)
AdjustPayloadSize bool // If true, the client will automatically add a EDNS0 RR that will advertise a larger buffer
}
@ -185,7 +185,9 @@ func (c *Client) ExchangeConn(m *dns.Msg, s *ServerInfo, conn net.Conn) (*dns.Ms
}
}
conn.SetDeadline(time.Now().Add(c.Timeout))
if c.Timeout > 0 {
conn.SetDeadline(time.Now().Add(c.Timeout))
}
conn.Write(encryptedQuery)
encryptedResponse := make([]byte, maxDNSPacketSize)