Update sing-box core, refactor MASQUE, update XHTTP

This commit is contained in:
Shtorm
2026-05-29 01:31:57 +03:00
parent 1cb7950810
commit b953954b60
111 changed files with 1291 additions and 1660 deletions

View File

@@ -192,6 +192,8 @@ func (c *Client) DialContext(ctx context.Context) (net.Conn, error) {
go func() {
var seq int64
var lastWrite time.Time
dynamicHTTPClient := httpClient
dynamicXmuxClient := xmuxClient
for {
// by offloading the uploads into a buffered pipe, multiple conn.Write
// calls get automatically batched together into larger POST requests.
@@ -219,12 +221,12 @@ func (c *Client) DialContext(ctx context.Context) (net.Conn, error) {
time.Sleep(time.Duration(scMinPostsIntervalMs.Rand())*time.Millisecond - time.Since(lastWrite))
}
lastWrite = time.Now()
if xmuxClient != nil && (xmuxClient.LeftRequests.Add(-1) <= 0 ||
(xmuxClient.UnreusableAt != time.Time{} && lastWrite.After(xmuxClient.UnreusableAt))) {
httpClient, xmuxClient = c.getHTTPClient()
if dynamicXmuxClient != nil && (dynamicXmuxClient.LeftRequests.Add(-1) <= 0 ||
(dynamicXmuxClient.UnreusableAt != time.Time{} && lastWrite.After(dynamicXmuxClient.UnreusableAt))) {
dynamicHTTPClient, dynamicXmuxClient = c.getHTTPClient()
}
go func() {
err := httpClient.PostPacket(
go func(hClient DialerClient) {
err := hClient.PostPacket(
ctx,
requestURL.String(),
sessionId,
@@ -236,8 +238,8 @@ func (c *Client) DialContext(ctx context.Context) (net.Conn, error) {
uploadPipeReader.Interrupt()
doSplit.Store(false)
}
}()
if _, ok := httpClient.(*DefaultDialerClient); ok {
}(dynamicHTTPClient)
if _, ok := dynamicHTTPClient.(*DefaultDialerClient); ok {
<-wroteRequest.Wait()
}
}

View File

@@ -70,12 +70,14 @@ func (c *DefaultDialerClient) OpenStream(ctx context.Context, url string, sessio
c.closed = true
}
gotConn.Close()
common.Close(body)
wrc.Close()
return
}
if resp.StatusCode != 200 || uploadOnly { // stream-up
io.Copy(io.Discard, resp.Body)
resp.Body.Close() // if it is called immediately, the upload will be interrupted also
common.Close(body)
wrc.Close()
return
}