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)
|
||||
} else {
|
||||
s.rawConn.Close()
|
||||
s.session.Close()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,6 +51,10 @@ func removeInactiveSessions(sessions []*sessionContext) []*sessionContext {
|
|||
|
||||
func openStream(sessions []*sessionContext) (quic.Stream, net.Addr) {
|
||||
for _, s := range sessions {
|
||||
if !isActive(s.session) {
|
||||
continue
|
||||
}
|
||||
|
||||
stream, err := s.session.OpenStream()
|
||||
if err != nil {
|
||||
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 = removeInactiveSessions(sessions)
|
||||
s.sessions[dest] = sessions
|
||||
|
||||
{
|
||||
stream, local := openStream(sessions)
|
||||
if stream != nil {
|
||||
return &interConn{
|
||||
|
@ -89,6 +90,9 @@ func (s *clientSessions) openConnection(destAddr net.Addr, config *Config, tlsCo
|
|||
remote: destAddr,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
sessions = removeInactiveSessions(sessions)
|
||||
|
||||
rawConn, err := internet.ListenSystemPacket(context.Background(), &net.UDPAddr{
|
||||
IP: []byte{0, 0, 0, 0},
|
||||
|
@ -99,12 +103,13 @@ func (s *clientSessions) openConnection(destAddr net.Addr, config *Config, tlsCo
|
|||
}
|
||||
|
||||
quicConfig := &quic.Config{
|
||||
ConnectionIDLength: 12,
|
||||
ConnectionIDLength: 8,
|
||||
HandshakeTimeout: time.Second * 8,
|
||||
IdleTimeout: time.Second * 600,
|
||||
MaxReceiveStreamFlowControlWindow: 512 * 1024,
|
||||
IdleTimeout: time.Second * 30,
|
||||
MaxReceiveStreamFlowControlWindow: 128 * 1024,
|
||||
MaxReceiveConnectionFlowControlWindow: 2 * 1024 * 1024,
|
||||
MaxIncomingUniStreams: -1,
|
||||
MaxIncomingStreams: 32,
|
||||
}
|
||||
|
||||
conn, err := wrapSysConn(rawConn, config)
|
||||
|
@ -123,7 +128,7 @@ func (s *clientSessions) openConnection(destAddr net.Addr, config *Config, tlsCo
|
|||
session: session,
|
||||
rawConn: conn,
|
||||
})
|
||||
stream, err = session.OpenStream()
|
||||
stream, err := session.OpenStream()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -101,12 +101,12 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti
|
|||
}
|
||||
|
||||
quicConfig := &quic.Config{
|
||||
ConnectionIDLength: 12,
|
||||
ConnectionIDLength: 8,
|
||||
HandshakeTimeout: time.Second * 8,
|
||||
IdleTimeout: time.Second * 600,
|
||||
MaxReceiveStreamFlowControlWindow: 512 * 1024,
|
||||
MaxReceiveConnectionFlowControlWindow: 4 * 1024 * 1024,
|
||||
MaxIncomingStreams: 8192,
|
||||
IdleTimeout: time.Second * 30,
|
||||
MaxReceiveStreamFlowControlWindow: 128 * 1024,
|
||||
MaxReceiveConnectionFlowControlWindow: 2 * 1024 * 1024,
|
||||
MaxIncomingStreams: 32,
|
||||
MaxIncomingUniStreams: -1,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue