add timeout for dial

master
Dingjun 7 years ago
parent 07994fed98
commit ec0ef06f7e

@ -7,8 +7,11 @@ import (
"io"
"log"
"net"
"time"
)
var dialer = &net.Dialer{Timeout: 10 * time.Second}
func main() {
var configfile string
@ -79,9 +82,9 @@ func handleConn(conn net.Conn, b backend) {
ServerName: hostname,
InsecureSkipVerify: b.Insecure,
}
c, err = tls.Dial("tcp", host, config)
c, err = tls.DialWithDialer(dialer, "tcp", host, config)
} else {
c, err = net.Dial("tcp", host)
c, err = dialer.Dial("tcp", host)
}
if err != nil {

Loading…
Cancel
Save