Fix: tls server name missing in vmess

This commit is contained in:
Dreamacro 2018-11-28 23:24:57 +08:00
parent a64cea5011
commit dc24dd4d89
2 changed files with 9 additions and 4 deletions

View file

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

View file

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