dns: SetDeadline for all remote connection

This commit is contained in:
nadoo 2018-10-20 21:24:11 +08:00
parent 515a5dffa5
commit 14b072832d
4 changed files with 6 additions and 5 deletions

2
.gitignore vendored
View File

@ -15,6 +15,8 @@
.glide/ .glide/
# custom # custom
.idea
.vscode
*.zip *.zip
/*.conf /*.conf
/*.rule /*.rule

View File

@ -309,6 +309,5 @@ Examples:
## Links ## Links
- [go-ss2](https://github.com/shadowsocks/go-shadowsocks2): ss protocol support
- [conflag](https://github.com/nadoo/conflag): command line and config file parse support - [conflag](https://github.com/nadoo/conflag): command line and config file parse support
- [ArchLinux](https://www.archlinux.org/packages/community/x86_64/glider): a great linux distribution with glider pre-built package - [ArchLinux](https://www.archlinux.org/packages/community/x86_64/glider): a great linux distribution with glider pre-built package

View File

@ -149,9 +149,7 @@ func (c *Client) exchange(qname string, reqBytes []byte, preferTCP bool) (server
defer rc.Close() defer rc.Close()
// TODO: support timeout setting for different upstream server // TODO: support timeout setting for different upstream server
if len(servers) > 1 { rc.SetDeadline(time.Now().Add(time.Duration(c.config.Timeout) * time.Second))
rc.SetDeadline(time.Now().Add(time.Duration(c.config.Timeout) * time.Second))
}
switch network { switch network {
case "tcp": case "tcp":

View File

@ -208,7 +208,9 @@ func (c *Conn) DecodeRespHeader() error {
stream := cipher.NewCFBDecrypter(block, c.respBodyIV[:]) stream := cipher.NewCFBDecrypter(block, c.respBodyIV[:])
buf := make([]byte, 4) buf := make([]byte, 4)
io.ReadFull(c.Conn, buf) if _, err := io.ReadFull(c.Conn, buf); err != nil {
return err
}
stream.XORKeyStream(buf, buf) stream.XORKeyStream(buf, buf)
if buf[0] != c.reqRespV { if buf[0] != c.reqRespV {