From dc24dd4d8985b255984a79e477e6bbc5fe338e55 Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Wed, 28 Nov 2018 23:24:57 +0800 Subject: [PATCH] Fix: tls server name missing in vmess --- adapters/outbound/vmess.go | 3 ++- component/vmess/vmess.go | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/adapters/outbound/vmess.go b/adapters/outbound/vmess.go index 04f4b110..9894bf80 100644 --- a/adapters/outbound/vmess.go +++ b/adapters/outbound/vmess.go @@ -75,7 +75,8 @@ func NewVmess(option VmessOption) (*Vmess, error) { AlterID: uint16(option.AlterID), Security: security, TLS: option.TLS, - Host: net.JoinHostPort(option.Server, strconv.Itoa(option.Port)), + HostName: option.Server, + Port: strconv.Itoa(option.Port), NetWork: option.Network, WebSocketPath: option.WSPath, SkipCertVerify: option.SkipCertVerify, diff --git a/component/vmess/vmess.go b/component/vmess/vmess.go index 3356d8bc..8273ea87 100644 --- a/component/vmess/vmess.go +++ b/component/vmess/vmess.go @@ -79,7 +79,8 @@ type Config struct { AlterID uint16 Security string TLS bool - Host string + HostName string + Port string NetWork string WebSocketPath string SkipCertVerify bool @@ -129,9 +130,12 @@ func NewClient(config Config) (*Client, error) { return nil, fmt.Errorf("Unknown network type: %s", config.NetWork) } + host := net.JoinHostPort(config.HostName, config.Port) + var tlsConfig *tls.Config if config.TLS { tlsConfig = &tls.Config{ + ServerName: config.HostName, InsecureSkipVerify: config.SkipCertVerify, ClientSessionCache: config.SessionCacahe, } @@ -143,7 +147,7 @@ func NewClient(config Config) (*Client, error) { var wsConfig *websocketConfig if config.NetWork == "ws" { wsConfig = &websocketConfig{ - host: config.Host, + host: host, path: config.WebSocketPath, tls: config.TLS, tlsConfig: tlsConfig, @@ -155,7 +159,7 @@ func NewClient(config Config) (*Client, error) { uuid: &uid, security: security, tls: config.TLS, - host: config.Host, + host: host, wsConfig: wsConfig, tlsConfig: tlsConfig, }, nil