fix quic config
This commit is contained in:
@ -55,7 +55,15 @@ func (l *http3Listener) Init(md md.Metadata) (err error) {
|
||||
|
||||
l.server = pht_util.NewHTTP3Server(
|
||||
l.options.Addr,
|
||||
&quic.Config{},
|
||||
&quic.Config{
|
||||
KeepAlivePeriod: l.md.keepAlivePeriod,
|
||||
HandshakeIdleTimeout: l.md.handshakeTimeout,
|
||||
MaxIdleTimeout: l.md.maxIdleTimeout,
|
||||
Versions: []quic.VersionNumber{
|
||||
quic.Version1,
|
||||
},
|
||||
MaxIncomingStreams: int64(l.md.maxStreams),
|
||||
},
|
||||
pht_util.TLSConfigServerOption(l.options.TLSConfig),
|
||||
pht_util.BacklogServerOption(l.md.backlog),
|
||||
pht_util.PathServerOption(l.md.authorizePath, l.md.pushPath, l.md.pullPath),
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ func (l *quicListener) Init(md md.Metadata) (err error) {
|
||||
quic.Version1,
|
||||
quic.VersionDraft29,
|
||||
},
|
||||
MaxIncomingStreams: int64(l.md.maxStreams),
|
||||
}
|
||||
|
||||
tlsCfg := l.options.TLSConfig
|
||||
|
@ -16,6 +16,7 @@ type metadata struct {
|
||||
keepAlivePeriod time.Duration
|
||||
handshakeTimeout time.Duration
|
||||
maxIdleTimeout time.Duration
|
||||
maxStreams int
|
||||
|
||||
cipherKey []byte
|
||||
backlog int
|
||||
@ -27,6 +28,7 @@ func (l *quicListener) parseMetadata(md mdata.Metadata) (err error) {
|
||||
keepAlivePeriod = "ttl"
|
||||
handshakeTimeout = "handshakeTimeout"
|
||||
maxIdleTimeout = "maxIdleTimeout"
|
||||
maxStreams = "maxStreams"
|
||||
|
||||
backlog = "backlog"
|
||||
cipherKey = "cipherKey"
|
||||
@ -49,6 +51,7 @@ func (l *quicListener) parseMetadata(md mdata.Metadata) (err error) {
|
||||
}
|
||||
l.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
|
||||
l.md.maxIdleTimeout = mdutil.GetDuration(md, maxIdleTimeout)
|
||||
l.md.maxStreams = mdutil.GetInt(md, maxStreams)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -50,7 +50,9 @@ func (l *tunListener) createTunDevice() (dev io.ReadWriteCloser, name string, er
|
||||
return
|
||||
}
|
||||
|
||||
dev = &tunDevice{dev: ifce}
|
||||
dev = &tunDevice{
|
||||
dev: ifce,
|
||||
}
|
||||
name, err = ifce.Name()
|
||||
|
||||
return
|
||||
|
Reference in New Issue
Block a user