From 25f901bee3155435b1a1a72a72e7dccef6c5b8fe Mon Sep 17 00:00:00 2001 From: Phus Lu Date: Sat, 17 Jun 2017 20:54:49 +0800 Subject: [PATCH] use Config.TLSConfig.ServerName as client hostname if provided Currently quic client always parse `hostname` from the addr. It prevent us to specific a different `hostname` to the client. This PR is to enable this by the `TLSConfig.ServerName` field. Thanks. Signed-off-by: Phus Lu --- client.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 221c3385d..9e6ae0ad2 100644 --- a/client.go +++ b/client.go @@ -73,9 +73,16 @@ func DialNonFWSecure(pconn net.PacketConn, remoteAddr net.Addr, host string, con return nil, err } - hostname, _, err := net.SplitHostPort(host) - if err != nil { - return nil, err + var hostname string + if config.TLSConfig != nil { + hostname = config.TLSConfig.ServerName + } + + if hostname == "" { + hostname, _, err = net.SplitHostPort(host) + if err != nil { + return nil, err + } } clientConfig := populateClientConfig(config)