From 54f7a59a917d3b16b25340b62294b969e28d3f10 Mon Sep 17 00:00:00 2001 From: lanrenwo Date: Tue, 14 Jun 2022 14:40:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0mtu=E7=9A=84=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/base/cfg.go | 1 + server/base/config.go | 1 + server/conf/server-sample.toml | 4 ++++ server/sessdata/session.go | 5 ++++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/server/base/cfg.go b/server/base/cfg.go index 49a9c92..5690f08 100644 --- a/server/base/cfg.go +++ b/server/base/cfg.go @@ -66,6 +66,7 @@ type ServerConfig struct { CstpDpd int `json:"cstp_dpd"` // Dead peer detection in seconds MobileKeepalive int `json:"mobile_keepalive"` MobileDpd int `json:"mobile_dpd"` + Mtu int `json:"mtu"` SessionTimeout int `json:"session_timeout"` // in seconds // AuthTimeout int `json:"auth_timeout"` // in seconds diff --git a/server/base/config.go b/server/base/config.go index b7edc7b..bdb6dc1 100644 --- a/server/base/config.go +++ b/server/base/config.go @@ -54,6 +54,7 @@ var configs = []config{ {Typ: cfgInt, Name: "cstp_dpd", Usage: "死链接检测时间(秒)", ValInt: 30}, {Typ: cfgInt, Name: "mobile_keepalive", Usage: "移动端keepalive接检测时间(秒)", ValInt: 50}, {Typ: cfgInt, Name: "mobile_dpd", Usage: "移动端死链接检测时间(秒)", ValInt: 60}, + {Typ: cfgInt, Name: "mtu", Usage: "最大传输单元MTU", ValInt: 1460}, {Typ: cfgInt, Name: "session_timeout", Usage: "session过期时间(秒)", ValInt: 3600}, // {Typ: cfgInt, Name: "auth_timeout", Usage: "auth_timeout", ValInt: 0}, {Typ: cfgInt, Name: "audit_interval", Usage: "审计去重间隔(秒),-1关闭", ValInt: -1}, diff --git a/server/conf/server-sample.toml b/server/conf/server-sample.toml index 402e03f..13a8835 100644 --- a/server/conf/server-sample.toml +++ b/server/conf/server-sample.toml @@ -60,6 +60,10 @@ cstp_keepalive = 20 cstp_dpd = 30 mobile_keepalive = 40 mobile_dpd = 50 + +#设置最大传输单元 +mtu = 1460 + #session过期时间,用于断线重连,0永不过期 session_timeout = 3600 auth_timeout = 0 diff --git a/server/sessdata/session.go b/server/sessdata/session.go index 97d6e3e..f165247 100644 --- a/server/sessdata/session.go +++ b/server/sessdata/session.go @@ -294,9 +294,12 @@ func (cs *ConnSession) ratePeriod() { } } -const MaxMtu = 1460 +var MaxMtu = 1460 func (cs *ConnSession) SetMtu(mtu string) { + if base.Cfg.Mtu > 0 { + MaxMtu = base.Cfg.Mtu + } cs.Mtu = MaxMtu mi, err := strconv.Atoi(mtu)