fix quic config
This commit is contained in:
@ -86,6 +86,15 @@ func (d *http3Dialer) Dial(ctx context.Context, addr string, opts ...dialer.Dial
|
||||
|
||||
return quic.DialEarly(udpConn.(net.PacketConn), udpAddr, host, tlsCfg, cfg)
|
||||
},
|
||||
QuicConfig: &quic.Config{
|
||||
KeepAlivePeriod: d.md.keepAlivePeriod,
|
||||
HandshakeIdleTimeout: d.md.handshakeTimeout,
|
||||
MaxIdleTimeout: d.md.maxIdleTimeout,
|
||||
Versions: []quic.VersionNumber{
|
||||
quic.Version1,
|
||||
},
|
||||
MaxIncomingStreams: int64(d.md.maxStreams),
|
||||
},
|
||||
},
|
||||
},
|
||||
AuthorizePath: d.md.authorizePath,
|
||||
|
@ -9,22 +9,22 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
dialTimeout = "dialTimeout"
|
||||
defaultAuthorizePath = "/authorize"
|
||||
defaultPushPath = "/push"
|
||||
defaultPullPath = "/pull"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultDialTimeout = 5 * time.Second
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
dialTimeout time.Duration
|
||||
authorizePath string
|
||||
pushPath string
|
||||
pullPath string
|
||||
host string
|
||||
|
||||
// QUIC config options
|
||||
keepAlivePeriod time.Duration
|
||||
maxIdleTimeout time.Duration
|
||||
handshakeTimeout time.Duration
|
||||
maxStreams int
|
||||
}
|
||||
|
||||
func (d *http3Dialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
@ -33,6 +33,12 @@ func (d *http3Dialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
pushPath = "pushPath"
|
||||
pullPath = "pullPath"
|
||||
host = "host"
|
||||
|
||||
keepAlive = "keepAlive"
|
||||
keepAlivePeriod = "ttl"
|
||||
handshakeTimeout = "handshakeTimeout"
|
||||
maxIdleTimeout = "maxIdleTimeout"
|
||||
maxStreams = "maxStreams"
|
||||
)
|
||||
|
||||
d.md.authorizePath = mdutil.GetString(md, authorizePath)
|
||||
@ -49,5 +55,15 @@ func (d *http3Dialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
}
|
||||
|
||||
d.md.host = mdutil.GetString(md, host)
|
||||
if !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)
|
||||
d.md.maxStreams = mdutil.GetInt(md, maxStreams)
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-gost/core/dialer"
|
||||
"github.com/go-gost/core/logger"
|
||||
md "github.com/go-gost/core/metadata"
|
||||
pht_util "github.com/go-gost/x/internal/util/pht"
|
||||
"github.com/go-gost/x/registry"
|
||||
@ -24,7 +23,6 @@ type phtDialer struct {
|
||||
clientMutex sync.Mutex
|
||||
tlsEnabled bool
|
||||
md metadata
|
||||
logger logger.Logger
|
||||
options dialer.Options
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package pht
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
@ -15,12 +14,7 @@ const (
|
||||
defaultPullPath = "/pull"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultDialTimeout = 5 * time.Second
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
dialTimeout time.Duration
|
||||
authorizePath string
|
||||
pushPath string
|
||||
pullPath string
|
||||
|
@ -110,6 +110,7 @@ func (d *quicDialer) initSession(ctx context.Context, addr net.Addr, conn net.Pa
|
||||
quic.Version1,
|
||||
quic.VersionDraft29,
|
||||
},
|
||||
MaxIncomingStreams: int64(d.md.maxStreams),
|
||||
}
|
||||
|
||||
tlsCfg := d.options.TLSConfig
|
||||
|
@ -11,6 +11,7 @@ type metadata struct {
|
||||
keepAlivePeriod time.Duration
|
||||
maxIdleTimeout time.Duration
|
||||
handshakeTimeout time.Duration
|
||||
maxStreams int
|
||||
|
||||
cipherKey []byte
|
||||
}
|
||||
@ -21,6 +22,7 @@ func (d *quicDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
keepAlivePeriod = "ttl"
|
||||
handshakeTimeout = "handshakeTimeout"
|
||||
maxIdleTimeout = "maxIdleTimeout"
|
||||
maxStreams = "maxStreams"
|
||||
|
||||
cipherKey = "cipherKey"
|
||||
)
|
||||
@ -29,7 +31,7 @@ func (d *quicDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
d.md.cipherKey = []byte(key)
|
||||
}
|
||||
|
||||
if mdutil.GetBool(md, keepAlive) {
|
||||
if !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
|
||||
@ -37,6 +39,7 @@ func (d *quicDialer) parseMetadata(md mdata.Metadata) (err error) {
|
||||
}
|
||||
d.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
|
||||
d.md.maxIdleTimeout = mdutil.GetDuration(md, maxIdleTimeout)
|
||||
d.md.maxStreams = mdutil.GetInt(md, maxStreams)
|
||||
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user