fix quic config

This commit is contained in:
ginuerzh
2022-11-03 21:30:01 +08:00
parent 76fbcb2046
commit 30d44c7376
31 changed files with 218 additions and 138 deletions

View File

@ -2,6 +2,7 @@ package http3
import (
"strings"
"time"
mdata "github.com/go-gost/core/metadata"
mdutil "github.com/go-gost/core/metadata/util"
@ -19,6 +20,12 @@ type metadata struct {
pushPath string
pullPath string
backlog int
// QUIC config options
keepAlivePeriod time.Duration
maxIdleTimeout time.Duration
handshakeTimeout time.Duration
maxStreams int
}
func (l *http3Listener) parseMetadata(md mdata.Metadata) (err error) {
@ -27,6 +34,12 @@ func (l *http3Listener) parseMetadata(md mdata.Metadata) (err error) {
pushPath = "pushPath"
pullPath = "pullPath"
keepAlive = "keepAlive"
keepAlivePeriod = "ttl"
handshakeTimeout = "handshakeTimeout"
maxIdleTimeout = "maxIdleTimeout"
maxStreams = "maxStreams"
backlog = "backlog"
)
@ -48,5 +61,15 @@ func (l *http3Listener) parseMetadata(md mdata.Metadata) (err error) {
l.md.backlog = defaultBacklog
}
if mdutil.GetBool(md, keepAlive) {
l.md.keepAlivePeriod = mdutil.GetDuration(md, keepAlivePeriod)
if l.md.keepAlivePeriod <= 0 {
l.md.keepAlivePeriod = 10 * time.Second
}
}
l.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
l.md.maxIdleTimeout = mdutil.GetDuration(md, maxIdleTimeout)
l.md.maxStreams = mdutil.GetInt(md, maxStreams)
return
}