diff --git a/go.mod b/go.mod index e1f6d806..a8e96efc 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/sagernet/sing v0.3.0-beta.7 github.com/sagernet/sing-dns v0.1.12-beta.1 github.com/sagernet/sing-mux v0.1.6-beta.3 - github.com/sagernet/sing-quic v0.1.6-beta.1 + github.com/sagernet/sing-quic v0.1.6-beta.2 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/sagernet/sing-shadowsocks2 v0.1.6-beta.1 github.com/sagernet/sing-shadowtls v0.1.4 diff --git a/go.sum b/go.sum index f8071a45..b3386465 100644 --- a/go.sum +++ b/go.sum @@ -115,8 +115,8 @@ github.com/sagernet/sing-dns v0.1.12-beta.1 h1:5J3VxSmz3ezVXYS0m8jce8jakbTiP8xiH github.com/sagernet/sing-dns v0.1.12-beta.1/go.mod h1:zJ/YjnYB61SYE+ubMcMqVdpaSvsyQ2iShQGO3vuLvvE= github.com/sagernet/sing-mux v0.1.6-beta.3 h1:Bcd89O0zgDNs/q6MJBS0EpgRvry9dB0VJ2FAL9Q2Mp8= github.com/sagernet/sing-mux v0.1.6-beta.3/go.mod h1:WWtRmrwCDgb+g+7Da6o62I9WiMNB0a3w6BJhEpNQlNA= -github.com/sagernet/sing-quic v0.1.6-beta.1 h1:OhNk0jxp7yZSvG/2Pg/gRLrhApqM1gFLB8LG2S4wSCc= -github.com/sagernet/sing-quic v0.1.6-beta.1/go.mod h1:+OLsIVPmgHzCqcF3lGBVngc7ItYM6v3T0rn6Qtd4T1g= +github.com/sagernet/sing-quic v0.1.6-beta.2 h1:u/tab4OB2IlEUxORJ0ncIWLemiJa2oQ/IonB1ysxHQo= +github.com/sagernet/sing-quic v0.1.6-beta.2/go.mod h1:+OLsIVPmgHzCqcF3lGBVngc7ItYM6v3T0rn6Qtd4T1g= github.com/sagernet/sing-shadowsocks v0.2.6 h1:xr7ylAS/q1cQYS8oxKKajhuQcchd5VJJ4K4UZrrpp0s= github.com/sagernet/sing-shadowsocks v0.2.6/go.mod h1:j2YZBIpWIuElPFL/5sJAj470bcn/3QQ5lxZUNKLDNAM= github.com/sagernet/sing-shadowsocks2 v0.1.6-beta.1 h1:0vbf4XA6QybVXhUqlmbceYWYpH96s4RRt6J+K+Xtr0A= diff --git a/inbound/hysteria.go b/inbound/hysteria.go index 29707f65..9cb2559d 100644 --- a/inbound/hysteria.go +++ b/inbound/hysteria.go @@ -5,6 +5,7 @@ package inbound import ( "context" "net" + "time" "github.com/sagernet/sing-box/adapter" "github.com/sagernet/sing-box/common/humanize" @@ -66,6 +67,12 @@ func NewHysteria(ctx context.Context, router adapter.Router, logger log.ContextL } else { receiveBps = uint64(options.DownMbps) * hysteria.MbpsToBps } + var udpTimeout time.Duration + if options.UDPTimeout != 0 { + udpTimeout = time.Duration(options.UDPTimeout) + } else { + udpTimeout = C.UDPTimeout + } service, err := hysteria.NewService[int](hysteria.ServiceOptions{ Context: ctx, Logger: logger, @@ -73,6 +80,7 @@ func NewHysteria(ctx context.Context, router adapter.Router, logger log.ContextL ReceiveBPS: receiveBps, XPlusPassword: options.Obfs, TLSConfig: tlsConfig, + UDPTimeout: udpTimeout, Handler: adapter.NewUpstreamHandler(adapter.InboundContext{}, inbound.newConnection, inbound.newPacketConnection, nil), // Legacy options diff --git a/inbound/hysteria2.go b/inbound/hysteria2.go index 5db881c3..0e49cca2 100644 --- a/inbound/hysteria2.go +++ b/inbound/hysteria2.go @@ -8,6 +8,7 @@ import ( "net/http" "net/http/httputil" "net/url" + "time" "github.com/sagernet/sing-box/adapter" "github.com/sagernet/sing-box/common/tls" @@ -87,6 +88,12 @@ func NewHysteria2(ctx context.Context, router adapter.Router, logger log.Context }, tlsConfig: tlsConfig, } + var udpTimeout time.Duration + if options.UDPTimeout != 0 { + udpTimeout = time.Duration(options.UDPTimeout) + } else { + udpTimeout = C.UDPTimeout + } service, err := hysteria2.NewService[int](hysteria2.ServiceOptions{ Context: ctx, Logger: logger, @@ -96,6 +103,7 @@ func NewHysteria2(ctx context.Context, router adapter.Router, logger log.Context SalamanderPassword: salamanderPassword, TLSConfig: tlsConfig, IgnoreClientBandwidth: options.IgnoreClientBandwidth, + UDPTimeout: udpTimeout, Handler: adapter.NewUpstreamHandler(adapter.InboundContext{}, inbound.newConnection, inbound.newPacketConnection, nil), MasqueradeHandler: masqueradeHandler, }) diff --git a/inbound/tuic.go b/inbound/tuic.go index ff9b9ce7..f0e2d8d1 100644 --- a/inbound/tuic.go +++ b/inbound/tuic.go @@ -52,6 +52,12 @@ func NewTUIC(ctx context.Context, router adapter.Router, logger log.ContextLogge }, tlsConfig: tlsConfig, } + var udpTimeout time.Duration + if options.UDPTimeout != 0 { + udpTimeout = time.Duration(options.UDPTimeout) + } else { + udpTimeout = C.UDPTimeout + } service, err := tuic.NewService[int](tuic.ServiceOptions{ Context: ctx, Logger: logger, @@ -60,6 +66,7 @@ func NewTUIC(ctx context.Context, router adapter.Router, logger log.ContextLogge AuthTimeout: time.Duration(options.AuthTimeout), ZeroRTTHandshake: options.ZeroRTTHandshake, Heartbeat: time.Duration(options.Heartbeat), + UDPTimeout: udpTimeout, Handler: adapter.NewUpstreamHandler(adapter.InboundContext{}, inbound.newConnection, inbound.newPacketConnection, nil), }) if err != nil {