From a1577f80dff50f58d581ed63cb97bd456299a5ed Mon Sep 17 00:00:00 2001 From: fangdingjun Date: Thu, 19 Jul 2018 11:22:11 +0800 Subject: [PATCH] support nil cfg --- conn.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/conn.go b/conn.go index 866a7be..e439342 100644 --- a/conn.go +++ b/conn.go @@ -41,6 +41,14 @@ type Conn struct { // the Conn.Run have already called, should not call it again func Dial(network, addr string, cfg *tls.Config) (*Conn, error) { nextProto := []string{"h2"} + if cfg == nil { + _addr := addr + h, _, err := net.SplitHostPort(addr) + if err == nil { + _addr = h + } + cfg = &tls.Config{ServerName: _addr} + } cfg.NextProtos = nextProto conn, err := tls.Dial(network, addr, cfg) if err != nil {