mirror of
https://github.com/go-gost/x.git
synced 2026-10-21 03:31:59 +00:00
The issue #777 analysis was written against v3.2.4; commits5484717and9fab332already fixed the global mutex stall, the no-timeout OpenStreamSync, and the missing IsClosed reuse check. This addresses the remaining real problems: - P1 (HIGH): quicDialer.Dial received the Router's 15s-timeout ctx but GetConn built its own context.Background()+30s, dropping request cancellation/deadline. Thread ctx into GetConn so OpenStreamSync honors the upstream deadline. Mirrored to the icmp dialer (identical structure). - P2 (MEDIUM): listener QUIC keepalive defaulted OFF while the dialer defaulted ON, so a server behind NAT without an explicit keepalive=true could let its return-path mapping expire. Make the listener default ON like the dialer. - P3 (LOW): set an explicit MaxIdleTimeout default (90s) on both dialer and listener so dead sessions are detected sooner; still overridable via maxIdleTimeout=. Docs updated to mark the already-fixed root causes and rename the remaining items P1-P3. Fixes go-gost/gost#777
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package quic
|
|
|
|
import (
|
|
"time"
|
|
|
|
mdata "github.com/go-gost/core/metadata"
|
|
mdutil "github.com/go-gost/x/metadata/util"
|
|
)
|
|
|
|
type metadata struct {
|
|
keepAlivePeriod time.Duration
|
|
maxIdleTimeout time.Duration
|
|
handshakeTimeout time.Duration
|
|
maxStreams int
|
|
enableDatagram bool
|
|
|
|
cipherKey []byte
|
|
}
|
|
|
|
func (d *quicDialer) parseMetadata(md mdata.Metadata) (err error) {
|
|
const (
|
|
keepAlive = "keepAlive"
|
|
keepAlivePeriod = "ttl"
|
|
handshakeTimeout = "handshakeTimeout"
|
|
maxIdleTimeout = "maxIdleTimeout"
|
|
maxStreams = "maxStreams"
|
|
|
|
cipherKey = "cipherKey"
|
|
)
|
|
|
|
if key := mdutil.GetString(md, cipherKey); key != "" {
|
|
d.md.cipherKey = []byte(key)
|
|
}
|
|
|
|
if md == nil || !md.IsExists(keepAlive) || mdutil.GetBool(md, keepAlive) {
|
|
d.md.keepAlivePeriod = mdutil.GetDuration(md, keepAlivePeriod)
|
|
if d.md.keepAlivePeriod <= 0 {
|
|
d.md.keepAlivePeriod = 10 * time.Second
|
|
}
|
|
}
|
|
d.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
|
|
d.md.maxIdleTimeout = mdutil.GetDuration(md, maxIdleTimeout)
|
|
if d.md.maxIdleTimeout <= 0 {
|
|
d.md.maxIdleTimeout = 90 * time.Second
|
|
}
|
|
d.md.maxStreams = mdutil.GetInt(md, maxStreams)
|
|
d.md.enableDatagram = mdutil.GetBool(md, "quic.enableDatagram", "enableDatagram")
|
|
|
|
return
|
|
}
|