add mux config

This commit is contained in:
ginuerzh
2023-10-17 21:55:07 +08:00
parent bf5311ddc3
commit 1759c95e78
22 changed files with 805 additions and 23 deletions

View File

@ -10,9 +10,14 @@ import (
mdutil "github.com/go-gost/core/metadata/util"
"github.com/go-gost/relay"
xingress "github.com/go-gost/x/ingress"
"github.com/go-gost/x/internal/util/mux"
"github.com/go-gost/x/registry"
)
const (
defaultMuxVersion = 2
)
type metadata struct {
readTimeout time.Duration
noDelay bool
@ -20,6 +25,7 @@ type metadata struct {
directTunnel bool
entryPointID relay.TunnelID
ingress ingress.Ingress
muxCfg *mux.Config
}
func (h *tunnelHandler) parseMetadata(md mdata.Metadata) (err error) {
@ -54,5 +60,18 @@ func (h *tunnelHandler) parseMetadata(md mdata.Metadata) (err error) {
}
}
h.md.muxCfg = &mux.Config{
Version: mdutil.GetInt(md, "mux.version"),
KeepAliveInterval: mdutil.GetDuration(md, "mux.keepaliveInterval"),
KeepAliveDisabled: mdutil.GetBool(md, "mux.keepaliveDisabled"),
KeepAliveTimeout: mdutil.GetDuration(md, "mux.keepaliveTimeout"),
MaxFrameSize: mdutil.GetInt(md, "mux.maxFrameSize"),
MaxReceiveBuffer: mdutil.GetInt(md, "mux.maxReceiveBuffer"),
MaxStreamBuffer: mdutil.GetInt(md, "mux.maxStreamBuffer"),
}
if h.md.muxCfg.Version == 0 {
h.md.muxCfg.Version = defaultMuxVersion
}
return
}