mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-16 06:22:21 +08:00
Cleanup vmessws
This commit is contained in:
parent
f841459004
commit
07a0381f8b
|
@ -70,7 +70,7 @@ func (c *Client) DialContext(ctx context.Context) (net.Conn, error) {
|
||||||
}
|
}
|
||||||
return nil, wrapDialError(response, err)
|
return nil, wrapDialError(response, err)
|
||||||
} else {
|
} else {
|
||||||
return &EarlyWebsocketConn{Client: c, create: make(chan struct{})}, nil
|
return &EarlyWebsocketConn{Client: c, ctx: ctx, create: make(chan struct{})}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package v2raywebsocket
|
package v2raywebsocket
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
@ -68,6 +69,7 @@ func (c *WebsocketConn) SetDeadline(t time.Time) error {
|
||||||
|
|
||||||
type EarlyWebsocketConn struct {
|
type EarlyWebsocketConn struct {
|
||||||
*Client
|
*Client
|
||||||
|
ctx context.Context
|
||||||
conn *WebsocketConn
|
conn *WebsocketConn
|
||||||
create chan struct{}
|
create chan struct{}
|
||||||
}
|
}
|
||||||
|
@ -98,14 +100,14 @@ func (c *EarlyWebsocketConn) Write(b []byte) (n int, err error) {
|
||||||
if len(earlyData) > 0 {
|
if len(earlyData) > 0 {
|
||||||
earlyDataString := base64.RawURLEncoding.EncodeToString(earlyData)
|
earlyDataString := base64.RawURLEncoding.EncodeToString(earlyData)
|
||||||
if c.earlyDataHeaderName == "" {
|
if c.earlyDataHeaderName == "" {
|
||||||
conn, response, err = c.dialer.Dial(c.uri+earlyDataString, c.headers)
|
conn, response, err = c.dialer.DialContext(c.ctx, c.uri+earlyDataString, c.headers)
|
||||||
} else {
|
} else {
|
||||||
headers := c.headers.Clone()
|
headers := c.headers.Clone()
|
||||||
headers.Set(c.earlyDataHeaderName, earlyDataString)
|
headers.Set(c.earlyDataHeaderName, earlyDataString)
|
||||||
conn, response, err = c.dialer.Dial(c.uri, headers)
|
conn, response, err = c.dialer.DialContext(c.ctx, c.uri, headers)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
conn, response, err = c.dialer.Dial(c.uri, c.headers)
|
conn, response, err = c.dialer.DialContext(c.ctx, c.uri, c.headers)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, wrapDialError(response, err)
|
return 0, wrapDialError(response, err)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user