fix: Preserve TrustTunnel streams after sniff timeout

This commit is contained in:
Shtorm
2026-11-30 23:50:55 +03:00
parent 07041e7768
commit fce1f854f2
2 changed files with 13 additions and 4 deletions
+9 -4
View File
@@ -27,7 +27,6 @@ import (
aTLS "github.com/sagernet/sing/common/tls"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
)
func RegisterInbound(registry *inbound.Registry) {
@@ -104,8 +103,13 @@ func (h *Inbound) Start(stage adapter.StartStage, scope *adapter.Scope) error {
if err != nil {
return err
}
protocols := new(http.Protocols)
protocols.SetHTTP1(true)
protocols.SetUnencryptedHTTP2(true)
h.httpServer = &http.Server{
Handler: h2c.NewHandler(h.service, &http2.Server{}),
Handler: h.service,
IdleTimeout: trusttunnel.DefaultSessionTimeout,
Protocols: protocols,
BaseContext: func(net.Listener) context.Context {
return h.ctx
},
@@ -150,14 +154,15 @@ func (h *Inbound) Start(stage adapter.StartStage, scope *adapter.Scope) error {
return err
}
h.http3Server = &http3.Server{
Handler: h.service,
Handler: h.service,
IdleTimeout: trusttunnel.DefaultSessionTimeout,
ConnContext: func(ctx context.Context, conn *quic.Conn) context.Context {
conn.SetCongestionControl(congestionControlFactory(conn))
return ctx
},
}
quicListener, err := qtls.ListenEarly(udpConn, h.http3TLSConfig, &quic.Config{
MaxIdleTimeout: trusttunnel.DefaultSessionTimeout * 2,
MaxIdleTimeout: 2 * (trusttunnel.DefaultConnectionTimeout + trusttunnel.DefaultHealthCheckTimeout),
MaxIncomingStreams: 1 << 60,
Allow0RTT: true,
DisablePathMTUDiscovery: h.options.DisablePathMTUDiscovery,
+4
View File
@@ -223,3 +223,7 @@ func (w *h2ConnWrapper) CloseWrapper() {
defer w.access.Unlock()
w.closed = true
}
func (w *h2ConnWrapper) NeedAdditionalReadDeadline() bool {
return true
}