dns: add length check to avoid panic

This commit is contained in:
nadoo committed 2020-05-05 01:30:57 +08:00
1 parent 665d722d2c
commit e3c57ba369
6 files changed
+20 -55

No files matched your search

+3 -1
View File
@@ -256,7 +256,9 @@ func checkWebSite(fwdr *Forwarder, website string, timeout time.Duration, buf []
}
defer rc.Close()
rc.SetDeadline(time.Now().Add(timeout))
if timeout > 0 {
rc.SetDeadline(time.Now().Add(timeout))
}
_, err = rc.Write([]byte("GET / HTTP/1.0\r\n\r\n"))
if err != nil {