mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-07-27 09:11:49 +03:00
Fix naive inbound QUIC ALPN race condition
This commit is contained in:
@@ -107,16 +107,16 @@ func (n *Inbound) Start(stage adapter.StartStage) error {
|
|||||||
return n.ctx
|
return n.ctx
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
go func() {
|
listener := net.Listener(tcpListener)
|
||||||
listener := net.Listener(tcpListener)
|
if n.tlsConfig != nil {
|
||||||
if n.tlsConfig != nil {
|
if len(n.tlsConfig.NextProtos()) == 0 {
|
||||||
if len(n.tlsConfig.NextProtos()) == 0 {
|
n.tlsConfig.SetNextProtos([]string{http2.NextProtoTLS, "http/1.1"})
|
||||||
n.tlsConfig.SetNextProtos([]string{http2.NextProtoTLS, "http/1.1"})
|
} else if !common.Contains(n.tlsConfig.NextProtos(), http2.NextProtoTLS) {
|
||||||
} else if !common.Contains(n.tlsConfig.NextProtos(), http2.NextProtoTLS) {
|
n.tlsConfig.SetNextProtos(append([]string{http2.NextProtoTLS}, n.tlsConfig.NextProtos()...))
|
||||||
n.tlsConfig.SetNextProtos(append([]string{http2.NextProtoTLS}, n.tlsConfig.NextProtos()...))
|
|
||||||
}
|
|
||||||
listener = aTLS.NewListener(tcpListener, n.tlsConfig)
|
|
||||||
}
|
}
|
||||||
|
listener = aTLS.NewListener(tcpListener, n.tlsConfig)
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
sErr := n.httpServer.Serve(listener)
|
sErr := n.httpServer.Serve(listener)
|
||||||
if sErr != nil && !errors.Is(sErr, http.ErrServerClosed) {
|
if sErr != nil && !errors.Is(sErr, http.ErrServerClosed) {
|
||||||
n.logger.Error("http server serve error: ", sErr)
|
n.logger.Error("http server serve error: ", sErr)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import (
|
|||||||
"github.com/sagernet/sing-quic/congestion_bbr2"
|
"github.com/sagernet/sing-quic/congestion_bbr2"
|
||||||
congestion_meta1 "github.com/sagernet/sing-quic/congestion_meta1"
|
congestion_meta1 "github.com/sagernet/sing-quic/congestion_meta1"
|
||||||
congestion_meta2 "github.com/sagernet/sing-quic/congestion_meta2"
|
congestion_meta2 "github.com/sagernet/sing-quic/congestion_meta2"
|
||||||
|
"github.com/sagernet/sing/common"
|
||||||
E "github.com/sagernet/sing/common/exceptions"
|
E "github.com/sagernet/sing/common/exceptions"
|
||||||
"github.com/sagernet/sing/common/logger"
|
"github.com/sagernet/sing/common/logger"
|
||||||
"github.com/sagernet/sing/common/ntp"
|
"github.com/sagernet/sing/common/ntp"
|
||||||
@@ -30,6 +31,9 @@ func init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if !common.Contains(tlsConfig.NextProtos(), http3.NextProtoH3) {
|
||||||
|
tlsConfig.SetNextProtos(append(append([]string{}, tlsConfig.NextProtos()...), http3.NextProtoH3))
|
||||||
|
}
|
||||||
|
|
||||||
udpConn, err := listener.ListenUDP()
|
udpConn, err := listener.ListenUDP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user