Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Commit 42eb6b0

Browse files
committed
remove superfluous SmuxConfigParams
1 parent 7779642 commit 42eb6b0

File tree

3 files changed

+20
-29
lines changed

3 files changed

+20
-29
lines changed

client/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,13 @@ func createConn(config *Config, block kcp.BlockCrypt) (*smux.Session, error) {
475475
log.Println("SetWriteBuffer:", err)
476476
}
477477
log.Println("smux version:", config.SmuxVer, "on connection:", kcpconn.LocalAddr(), "->", kcpconn.RemoteAddr())
478-
smuxConfig, err := std.BuildSmuxConfig(std.SmuxConfigParams{
479-
Version: config.SmuxVer,
480-
MaxReceiveBuffer: config.SmuxBuf,
481-
MaxStreamBuffer: config.StreamBuf,
482-
MaxFrameSize: config.FrameSize,
483-
KeepAliveSeconds: config.KeepAlive,
484-
})
478+
smuxConfig, err := std.BuildSmuxConfig(
479+
config.SmuxVer,
480+
config.SmuxBuf,
481+
config.StreamBuf,
482+
config.FrameSize,
483+
config.KeepAlive,
484+
)
485485
if err != nil {
486486
log.Fatalf("%+v", err)
487487
}

server/main.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,13 +451,13 @@ func handleMux(_Q_ *qpp.QuantumPermutationPad, conn net.Conn, config *Config) {
451451
}
452452
log.Println("smux version:", config.SmuxVer, "on connection:", conn.LocalAddr(), "->", conn.RemoteAddr())
453453

454-
smuxConfig, err := std.BuildSmuxConfig(std.SmuxConfigParams{
455-
Version: config.SmuxVer,
456-
MaxReceiveBuffer: config.SmuxBuf,
457-
MaxStreamBuffer: config.StreamBuf,
458-
MaxFrameSize: config.FrameSize,
459-
KeepAliveSeconds: config.KeepAlive,
460-
})
454+
smuxConfig, err := std.BuildSmuxConfig(
455+
config.SmuxVer,
456+
config.SmuxBuf,
457+
config.StreamBuf,
458+
config.FrameSize,
459+
config.KeepAlive,
460+
)
461461
if err != nil {
462462
log.Println(err)
463463
conn.Close()

std/smuxcfg.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,15 @@ import (
2828
"github.com/xtaci/smux"
2929
)
3030

31-
// SmuxConfigParams organizes the dials that shape a smux session.
32-
type SmuxConfigParams struct {
33-
Version int
34-
MaxReceiveBuffer int
35-
MaxStreamBuffer int
36-
MaxFrameSize int
37-
KeepAliveSeconds int
38-
}
39-
4031
// BuildSmuxConfig constructs a smux.Config from CLI parameters and verifies the
4132
// result. Callers can log or wrap the returned error for better diagnostics.
42-
func BuildSmuxConfig(p SmuxConfigParams) (*smux.Config, error) {
33+
func BuildSmuxConfig(version, maxReceiveBuffer, maxStreamBuffer, maxFrameSize, keepAliveSeconds int) (*smux.Config, error) {
4334
cfg := smux.DefaultConfig()
44-
cfg.Version = p.Version
45-
cfg.MaxReceiveBuffer = p.MaxReceiveBuffer
46-
cfg.MaxStreamBuffer = p.MaxStreamBuffer
47-
cfg.MaxFrameSize = p.MaxFrameSize
48-
cfg.KeepAliveInterval = time.Duration(p.KeepAliveSeconds) * time.Second
35+
cfg.Version = version
36+
cfg.MaxReceiveBuffer = maxReceiveBuffer
37+
cfg.MaxStreamBuffer = maxStreamBuffer
38+
cfg.MaxFrameSize = maxFrameSize
39+
cfg.KeepAliveInterval = time.Duration(keepAliveSeconds) * time.Second
4940

5041
return cfg, smux.VerifyConfig(cfg)
5142
}

0 commit comments

Comments
 (0)