diff --git a/adapter/outbound/vless.go b/adapter/outbound/vless.go index 2d5c51bb..51bf104e 100644 --- a/adapter/outbound/vless.go +++ b/adapter/outbound/vless.go @@ -70,30 +70,32 @@ func (v *Vless) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) { Path: v.option.WSOpts.Path, MaxEarlyData: v.option.WSOpts.MaxEarlyData, EarlyDataHeaderName: v.option.WSOpts.EarlyDataHeaderName, + Headers: http.Header{}, } if len(v.option.WSOpts.Headers) != 0 { - header := http.Header{} for key, value := range v.option.WSOpts.Headers { - header.Add(key, value) + wsOpts.Headers.Add(key, value) } - wsOpts.Headers = header } - - wsOpts.TLS = true - wsOpts.TLSConfig = &tls.Config{ - MinVersion: tls.VersionTLS12, - ServerName: host, - InsecureSkipVerify: v.option.SkipCertVerify, - NextProtos: []string{"http/1.1"}, - } - if v.option.ServerName != "" { - wsOpts.TLSConfig.ServerName = v.option.ServerName - } else if host := wsOpts.Headers.Get("Host"); host != "" { - wsOpts.TLSConfig.ServerName = host + if v.option.TLS { + wsOpts.TLS = true + wsOpts.TLSConfig = &tls.Config{ + MinVersion: tls.VersionTLS12, + ServerName: host, + InsecureSkipVerify: v.option.SkipCertVerify, + NextProtos: []string{"http/1.1"}, + } + if v.option.ServerName != "" { + wsOpts.TLSConfig.ServerName = v.option.ServerName + } else if host := wsOpts.Headers.Get("Host"); host != "" { + wsOpts.TLSConfig.ServerName = host + } } else { - wsOpts.Headers.Set("Host", convert.RandHost()) - convert.SetUserAgent(wsOpts.Headers) + if host := wsOpts.Headers.Get("Host"); host == "" { + wsOpts.Headers.Set("Host", convert.RandHost()) + convert.SetUserAgent(wsOpts.Headers) + } } c, err = vmess.StreamWebsocketConn(c, wsOpts) case "http": diff --git a/adapter/outbound/vmess.go b/adapter/outbound/vmess.go index c9b9852f..63ab4664 100644 --- a/adapter/outbound/vmess.go +++ b/adapter/outbound/vmess.go @@ -92,7 +92,7 @@ func (v *Vmess) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) { Path: v.option.WSOpts.Path, MaxEarlyData: v.option.WSOpts.MaxEarlyData, EarlyDataHeaderName: v.option.WSOpts.EarlyDataHeaderName, - Headers: make(http.Header), + Headers: http.Header{}, } if len(v.option.WSOpts.Headers) != 0 {