update kcp mode

This commit is contained in:
fatedier
2017-06-13 23:36:10 +08:00
parent 32f8745d61
commit a2c318d24c
2 changed files with 21 additions and 20 deletions

View File

@ -27,9 +27,10 @@ var ServerCommonCfg *ServerCommonConf
// common config
type ServerCommonConf struct {
ConfigFile string
BindAddr string
BindPort int64
ConfigFile string
BindAddr string
BindPort int64
KcpBindPort int64
// If VhostHttpPort equals 0, don't listen a public port for http protocol.
VhostHttpPort int64
@ -51,7 +52,6 @@ type ServerCommonConf struct {
AuthTimeout int64
SubDomainHost string
TcpMux bool
SupportKcp bool
// if PrivilegeAllowPorts is not nil, tcp proxies which remote port exist in this map can be connected
PrivilegeAllowPorts [][2]int64
@ -65,6 +65,7 @@ func GetDefaultServerCommonConf() *ServerCommonConf {
ConfigFile: "./frps.ini",
BindAddr: "0.0.0.0",
BindPort: 7000,
KcpBindPort: 0,
VhostHttpPort: 0,
VhostHttpsPort: 0,
DashboardPort: 0,
@ -80,7 +81,6 @@ func GetDefaultServerCommonConf() *ServerCommonConf {
AuthTimeout: 900,
SubDomainHost: "",
TcpMux: true,
SupportKcp: true,
MaxPoolCount: 5,
HeartBeatTimeout: 90,
UserConnTimeout: 10,
@ -109,6 +109,14 @@ func LoadServerCommonConf(conf ini.File) (cfg *ServerCommonConf, err error) {
}
}
tmpStr, ok = conf.Get("common", "kcp_bind_port")
if ok {
v, err = strconv.ParseInt(tmpStr, 10, 64)
if err == nil && v > 0 {
cfg.KcpBindPort = v
}
}
tmpStr, ok = conf.Get("common", "vhost_http_port")
if ok {
cfg.VhostHttpPort, err = strconv.ParseInt(tmpStr, 10, 64)
@ -233,13 +241,6 @@ func LoadServerCommonConf(conf ini.File) (cfg *ServerCommonConf, err error) {
cfg.TcpMux = true
}
tmpStr, ok = conf.Get("common", "support_kcp")
if ok && tmpStr == "false" {
cfg.SupportKcp = false
} else {
cfg.SupportKcp = true
}
tmpStr, ok = conf.Get("common", "heartbeat_timeout")
if ok {
v, errRet := strconv.ParseInt(tmpStr, 10, 64)