set smux version to 1

This commit is contained in:
ginuerzh 2023-10-24 20:45:19 +08:00
parent 1801d855c5
commit 5b1183661f
6 changed files with 22 additions and 2 deletions

View File

@ -13,12 +13,20 @@ import (
// Bind implements connector.Binder. // Bind implements connector.Binder.
func (c *tunnelConnector) Bind(ctx context.Context, conn net.Conn, network, address string, opts ...connector.BindOption) (net.Listener, error) { func (c *tunnelConnector) Bind(ctx context.Context, conn net.Conn, network, address string, opts ...connector.BindOption) (net.Listener, error) {
log := c.options.Logger
addr, cid, err := c.initTunnel(conn, network, address) addr, cid, err := c.initTunnel(conn, network, address)
if err != nil { if err != nil {
return nil, err return nil, err
} }
endpoint := addr.String()
if v, _, _ := net.SplitHostPort(addr.String()); v != "" {
endpoint = v
}
log := c.options.Logger.WithFields(map[string]any{
"endpoint": endpoint,
"tunnel": c.md.tunnelID.String(),
})
log.Infof("create tunnel on %s/%s OK, tunnel=%s, connector=%s", addr, network, c.md.tunnelID.String(), cid) log.Infof("create tunnel on %s/%s OK, tunnel=%s, connector=%s", addr, network, c.md.tunnelID.String(), cid)
session, err := mux.ServerSession(conn, c.md.muxCfg) session, err := mux.ServerSession(conn, c.md.muxCfg)

View File

@ -51,6 +51,9 @@ func (c *tunnelConnector) parseMetadata(md mdata.Metadata) (err error) {
MaxReceiveBuffer: mdutil.GetInt(md, "mux.maxReceiveBuffer"), MaxReceiveBuffer: mdutil.GetInt(md, "mux.maxReceiveBuffer"),
MaxStreamBuffer: mdutil.GetInt(md, "mux.maxStreamBuffer"), MaxStreamBuffer: mdutil.GetInt(md, "mux.maxStreamBuffer"),
} }
if c.md.muxCfg.Version == 0 {
c.md.muxCfg.Version = 2
}
return return
} }

View File

@ -25,6 +25,9 @@ func (d *mtcpDialer) parseMetadata(md mdata.Metadata) (err error) {
MaxReceiveBuffer: mdutil.GetInt(md, "mux.maxReceiveBuffer"), MaxReceiveBuffer: mdutil.GetInt(md, "mux.maxReceiveBuffer"),
MaxStreamBuffer: mdutil.GetInt(md, "mux.maxStreamBuffer"), MaxStreamBuffer: mdutil.GetInt(md, "mux.maxStreamBuffer"),
} }
if d.md.muxCfg.Version == 0 {
d.md.muxCfg.Version = 2
}
return return
} }

View File

@ -67,6 +67,9 @@ func (h *tunnelHandler) parseMetadata(md mdata.Metadata) (err error) {
MaxReceiveBuffer: mdutil.GetInt(md, "mux.maxReceiveBuffer"), MaxReceiveBuffer: mdutil.GetInt(md, "mux.maxReceiveBuffer"),
MaxStreamBuffer: mdutil.GetInt(md, "mux.maxStreamBuffer"), MaxStreamBuffer: mdutil.GetInt(md, "mux.maxStreamBuffer"),
} }
if h.md.muxCfg.Version == 0 {
h.md.muxCfg.Version = 2
}
h.md.hash = mdutil.GetString(md, "hash") h.md.hash = mdutil.GetString(md, "hash")

View File

@ -8,7 +8,7 @@ import (
) )
const ( const (
defaultVersion = 2 defaultVersion = 1
) )
type Config struct { type Config struct {

View File

@ -28,6 +28,9 @@ func (l *mtcpListener) parseMetadata(md md.Metadata) (err error) {
MaxReceiveBuffer: mdutil.GetInt(md, "mux.maxReceiveBuffer"), MaxReceiveBuffer: mdutil.GetInt(md, "mux.maxReceiveBuffer"),
MaxStreamBuffer: mdutil.GetInt(md, "mux.maxStreamBuffer"), MaxStreamBuffer: mdutil.GetInt(md, "mux.maxStreamBuffer"),
} }
if l.md.muxCfg.Version == 0 {
l.md.muxCfg.Version = 2
}
l.md.backlog = mdutil.GetInt(md, "backlog") l.md.backlog = mdutil.GetInt(md, "backlog")
if l.md.backlog <= 0 { if l.md.backlog <= 0 {