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 <phuslu@hotmail.com>
This commit is contained in:
Phus Lu
2017-06-17 20:54:49 +08:00
parent f9659428c7
commit 25f901bee3

View File

@@ -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)