mirror of https://github.com/v2ray/v2ray-core
parent
4ff26a36ad
commit
5ecec6afd8
|
@ -39,7 +39,6 @@ func removeInactiveSessions(sessions []*sessionContext) []*sessionContext {
|
||||||
activeSessions = append(activeSessions, s)
|
activeSessions = append(activeSessions, s)
|
||||||
} else {
|
} else {
|
||||||
s.rawConn.Close()
|
s.rawConn.Close()
|
||||||
s.session.Close()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +51,10 @@ func removeInactiveSessions(sessions []*sessionContext) []*sessionContext {
|
||||||
|
|
||||||
func openStream(sessions []*sessionContext) (quic.Stream, net.Addr) {
|
func openStream(sessions []*sessionContext) (quic.Stream, net.Addr) {
|
||||||
for _, s := range sessions {
|
for _, s := range sessions {
|
||||||
|
if !isActive(s.session) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
stream, err := s.session.OpenStream()
|
stream, err := s.session.OpenStream()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
newError("failed to create stream").Base(err).AtWarning().WriteToLog()
|
newError("failed to create stream").Base(err).AtWarning().WriteToLog()
|
||||||
|
@ -78,9 +81,7 @@ func (s *clientSessions) openConnection(destAddr net.Addr, config *Config, tlsCo
|
||||||
sessions = s
|
sessions = s
|
||||||
}
|
}
|
||||||
|
|
||||||
sessions = removeInactiveSessions(sessions)
|
{
|
||||||
s.sessions[dest] = sessions
|
|
||||||
|
|
||||||
stream, local := openStream(sessions)
|
stream, local := openStream(sessions)
|
||||||
if stream != nil {
|
if stream != nil {
|
||||||
return &interConn{
|
return &interConn{
|
||||||
|
@ -89,6 +90,9 @@ func (s *clientSessions) openConnection(destAddr net.Addr, config *Config, tlsCo
|
||||||
remote: destAddr,
|
remote: destAddr,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sessions = removeInactiveSessions(sessions)
|
||||||
|
|
||||||
rawConn, err := internet.ListenSystemPacket(context.Background(), &net.UDPAddr{
|
rawConn, err := internet.ListenSystemPacket(context.Background(), &net.UDPAddr{
|
||||||
IP: []byte{0, 0, 0, 0},
|
IP: []byte{0, 0, 0, 0},
|
||||||
|
@ -99,12 +103,13 @@ func (s *clientSessions) openConnection(destAddr net.Addr, config *Config, tlsCo
|
||||||
}
|
}
|
||||||
|
|
||||||
quicConfig := &quic.Config{
|
quicConfig := &quic.Config{
|
||||||
ConnectionIDLength: 12,
|
ConnectionIDLength: 8,
|
||||||
HandshakeTimeout: time.Second * 8,
|
HandshakeTimeout: time.Second * 8,
|
||||||
IdleTimeout: time.Second * 600,
|
IdleTimeout: time.Second * 30,
|
||||||
MaxReceiveStreamFlowControlWindow: 512 * 1024,
|
MaxReceiveStreamFlowControlWindow: 128 * 1024,
|
||||||
MaxReceiveConnectionFlowControlWindow: 2 * 1024 * 1024,
|
MaxReceiveConnectionFlowControlWindow: 2 * 1024 * 1024,
|
||||||
MaxIncomingUniStreams: -1,
|
MaxIncomingUniStreams: -1,
|
||||||
|
MaxIncomingStreams: 32,
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := wrapSysConn(rawConn, config)
|
conn, err := wrapSysConn(rawConn, config)
|
||||||
|
@ -123,7 +128,7 @@ func (s *clientSessions) openConnection(destAddr net.Addr, config *Config, tlsCo
|
||||||
session: session,
|
session: session,
|
||||||
rawConn: conn,
|
rawConn: conn,
|
||||||
})
|
})
|
||||||
stream, err = session.OpenStream()
|
stream, err := session.OpenStream()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,12 +101,12 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
|
||||||
}
|
}
|
||||||
|
|
||||||
quicConfig := &quic.Config{
|
quicConfig := &quic.Config{
|
||||||
ConnectionIDLength: 12,
|
ConnectionIDLength: 8,
|
||||||
HandshakeTimeout: time.Second * 8,
|
HandshakeTimeout: time.Second * 8,
|
||||||
IdleTimeout: time.Second * 600,
|
IdleTimeout: time.Second * 30,
|
||||||
MaxReceiveStreamFlowControlWindow: 512 * 1024,
|
MaxReceiveStreamFlowControlWindow: 128 * 1024,
|
||||||
MaxReceiveConnectionFlowControlWindow: 4 * 1024 * 1024,
|
MaxReceiveConnectionFlowControlWindow: 2 * 1024 * 1024,
|
||||||
MaxIncomingStreams: 8192,
|
MaxIncomingStreams: 32,
|
||||||
MaxIncomingUniStreams: -1,
|
MaxIncomingUniStreams: -1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue