Skip to content

Commit

Permalink
set smux version to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
ginuerzh committed Oct 24, 2023
1 parent 1801d85 commit 5b11836
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
10 changes: 9 additions & 1 deletion connector/tunnel/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@ import (

// Bind implements connector.Binder.
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)
if err != nil {
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)

session, err := mux.ServerSession(conn, c.md.muxCfg)
Expand Down
3 changes: 3 additions & 0 deletions connector/tunnel/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func (c *tunnelConnector) parseMetadata(md mdata.Metadata) (err error) {
MaxReceiveBuffer: mdutil.GetInt(md, "mux.maxReceiveBuffer"),
MaxStreamBuffer: mdutil.GetInt(md, "mux.maxStreamBuffer"),
}
if c.md.muxCfg.Version == 0 {
c.md.muxCfg.Version = 2
}

return
}
3 changes: 3 additions & 0 deletions dialer/mtcp/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ func (d *mtcpDialer) parseMetadata(md mdata.Metadata) (err error) {
MaxReceiveBuffer: mdutil.GetInt(md, "mux.maxReceiveBuffer"),
MaxStreamBuffer: mdutil.GetInt(md, "mux.maxStreamBuffer"),
}
if d.md.muxCfg.Version == 0 {
d.md.muxCfg.Version = 2
}

return
}
3 changes: 3 additions & 0 deletions handler/tunnel/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ func (h *tunnelHandler) parseMetadata(md mdata.Metadata) (err error) {
MaxReceiveBuffer: mdutil.GetInt(md, "mux.maxReceiveBuffer"),
MaxStreamBuffer: mdutil.GetInt(md, "mux.maxStreamBuffer"),
}
if h.md.muxCfg.Version == 0 {
h.md.muxCfg.Version = 2
}

h.md.hash = mdutil.GetString(md, "hash")

Expand Down
2 changes: 1 addition & 1 deletion internal/util/mux/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

const (
defaultVersion = 2
defaultVersion = 1
)

type Config struct {
Expand Down
3 changes: 3 additions & 0 deletions listener/mtcp/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func (l *mtcpListener) parseMetadata(md md.Metadata) (err error) {
MaxReceiveBuffer: mdutil.GetInt(md, "mux.maxReceiveBuffer"),
MaxStreamBuffer: mdutil.GetInt(md, "mux.maxStreamBuffer"),
}
if l.md.muxCfg.Version == 0 {
l.md.muxCfg.Version = 2
}

l.md.backlog = mdutil.GetInt(md, "backlog")
if l.md.backlog <= 0 {
Expand Down

0 comments on commit 5b11836

Please sign in to comment.