add timeout for dial

master
Dingjun 7 years ago
parent 07994fed98
commit ec0ef06f7e

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

Loading…
Cancel
Save