From 872cd2c11e649079741275a504981e639897e31b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 25 Oct 2023 12:00:00 +0800 Subject: [PATCH] Fix UDP domain NAT --- transport/v2raywebsocket/client.go | 31 ------------------------------ 1 file changed, 31 deletions(-) diff --git a/transport/v2raywebsocket/client.go b/transport/v2raywebsocket/client.go index ecf85e6eba..54c4df0b6e 100644 --- a/transport/v2raywebsocket/client.go +++ b/transport/v2raywebsocket/client.go @@ -52,9 +52,6 @@ func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, opt if !strings.HasPrefix(requestURL.Path, "/") { requestURL.Path = "/" + requestURL.Path } - if !strings.HasPrefix(requestURL.Path, "/") { - requestURL.Path = "/" + requestURL.Path - } headers := make(http.Header) for key, value := range options.Headers { headers[key] = value @@ -68,9 +65,6 @@ func NewClient(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, opt if headers.Get("User-Agent") == "" { headers.Set("User-Agent", "Go-http-client/1.1") } - if headers.Get("User-Agent") == "" { - headers.Set("User-Agent", "Go-http-client/1.1") - } return &Client{ dialer, tlsConfig, @@ -107,31 +101,6 @@ func (c *Client) dialContext(ctx context.Context, requestURL *url.URL, headers h return NewConn(conn, reader, nil, ws.StateClientSide), nil } -func (c *Client) dialContext(ctx context.Context, requestURL *url.URL, headers http.Header) (*WebsocketConn, error) { - conn, err := c.dialer.DialContext(ctx, N.NetworkTCP, c.serverAddr) - if err != nil { - return nil, err - } - if c.tlsConfig != nil { - conn, err = tls.ClientHandshake(ctx, conn, c.tlsConfig) - if err != nil { - return nil, err - } - } - conn.SetDeadline(time.Now().Add(C.TCPTimeout)) - var protocols []string - if protocolHeader := headers.Get("Sec-WebSocket-Protocol"); protocolHeader != "" { - protocols = []string{protocolHeader} - headers.Del("Sec-WebSocket-Protocol") - } - reader, _, err := ws.Dialer{Header: ws.HandshakeHeaderHTTP(headers), Protocols: protocols}.Upgrade(conn, requestURL) - conn.SetDeadline(time.Time{}) - if err != nil { - return nil, err - } - return NewConn(conn, reader, nil, ws.StateClientSide), nil -} - func (c *Client) DialContext(ctx context.Context) (net.Conn, error) { if c.maxEarlyData <= 0 { conn, err := c.dialContext(ctx, &c.requestURL, c.headers)