default to smux version 2 for tunnel
This commit is contained in:
parent
1759c95e78
commit
0a565120df
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
defaultMuxVersion = 2
|
||||
defaultMuxVersion = 1
|
||||
)
|
||||
|
||||
type metadata struct {
|
||||
|
@ -21,7 +21,7 @@ func (c *tunnelConnector) Bind(ctx context.Context, conn net.Conn, network, addr
|
||||
}
|
||||
log.Infof("create tunnel on %s/%s OK, tunnel=%s, connector=%s", addr, network, c.md.tunnelID.String(), cid)
|
||||
|
||||
session, err := mux.ServerSession(conn, nil)
|
||||
session, err := mux.ServerSession(conn, c.md.muxCfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -7,9 +7,14 @@ import (
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
"github.com/go-gost/relay"
|
||||
"github.com/go-gost/x/internal/util/mux"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultMuxVersion = 2
|
||||
)
|
||||
|
||||
var (
|
||||
ErrInvalidTunnelID = errors.New("tunnel: invalid tunnel ID")
|
||||
)
|
||||
@ -18,14 +23,11 @@ type metadata struct {
|
||||
connectTimeout time.Duration
|
||||
tunnelID relay.TunnelID
|
||||
noDelay bool
|
||||
muxCfg *mux.Config
|
||||
}
|
||||
|
||||
func (c *tunnelConnector) parseMetadata(md mdata.Metadata) (err error) {
|
||||
const (
|
||||
connectTimeout = "connectTimeout"
|
||||
)
|
||||
|
||||
c.md.connectTimeout = mdutil.GetDuration(md, connectTimeout)
|
||||
c.md.connectTimeout = mdutil.GetDuration(md, "connectTimeout")
|
||||
c.md.noDelay = mdutil.GetBool(md, "nodelay")
|
||||
|
||||
if s := mdutil.GetString(md, "tunnelID", "tunnel.id"); s != "" {
|
||||
@ -39,5 +41,19 @@ func (c *tunnelConnector) parseMetadata(md mdata.Metadata) (err error) {
|
||||
if c.md.tunnelID.IsZero() {
|
||||
return ErrInvalidTunnelID
|
||||
}
|
||||
|
||||
c.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 c.md.muxCfg.Version == 0 {
|
||||
c.md.muxCfg.Version = defaultMuxVersion
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ func (h *relayHandler) bindTCP(ctx context.Context, conn net.Conn, network, addr
|
||||
}
|
||||
|
||||
// Upgrade connection to multiplex session.
|
||||
session, err := mux.ClientSession(conn, nil)
|
||||
session, err := mux.ClientSession(conn, h.md.muxCfg)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return err
|
||||
@ -219,7 +219,7 @@ func (h *relayHandler) handleBindTunnel(ctx context.Context, conn net.Conn, netw
|
||||
resp.WriteTo(conn)
|
||||
|
||||
// Upgrade connection to multiplex session.
|
||||
session, err := mux.ClientSession(conn, nil)
|
||||
session, err := mux.ClientSession(conn, h.md.muxCfg)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
mdata "github.com/go-gost/core/metadata"
|
||||
mdutil "github.com/go-gost/core/metadata/util"
|
||||
xingress "github.com/go-gost/x/ingress"
|
||||
"github.com/go-gost/x/internal/util/mux"
|
||||
"github.com/go-gost/x/registry"
|
||||
)
|
||||
|
||||
@ -23,6 +24,7 @@ type metadata struct {
|
||||
entryPoint string
|
||||
entryPointProxyProtocol int
|
||||
ingress ingress.Ingress
|
||||
muxCfg *mux.Config
|
||||
}
|
||||
|
||||
func (h *relayHandler) parseMetadata(md mdata.Metadata) (err error) {
|
||||
@ -76,5 +78,15 @@ func (h *relayHandler) 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"),
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user