support protocol kcp

This commit is contained in:
fatedier
2017-06-04 19:56:21 +08:00
parent 74cf57feb3
commit 80ba931326
9 changed files with 202 additions and 5 deletions

View File

@@ -41,6 +41,7 @@ type ClientCommonConf struct {
User string
LoginFailExit bool
Start map[string]struct{}
Protocol string
HeartBeatInterval int64
HeartBeatTimeout int64
}
@@ -61,6 +62,7 @@ func GetDeaultClientCommonConf() *ClientCommonConf {
User: "",
LoginFailExit: true,
Start: make(map[string]struct{}),
Protocol: "tcp",
HeartBeatInterval: 30,
HeartBeatTimeout: 90,
}
@@ -154,6 +156,15 @@ func LoadClientCommonConf(conf ini.File) (cfg *ClientCommonConf, err error) {
cfg.LoginFailExit = true
}
tmpStr, ok = conf.Get("common", "protocol")
if ok {
// Now it only support tcp and kcp.
if tmpStr != "kcp" {
tmpStr = "tcp"
}
cfg.Protocol = tmpStr
}
tmpStr, ok = conf.Get("common", "heartbeat_timeout")
if ok {
v, err = strconv.ParseInt(tmpStr, 10, 64)

View File

@@ -51,6 +51,7 @@ 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
@@ -79,6 +80,7 @@ func GetDefaultServerCommonConf() *ServerCommonConf {
AuthTimeout: 900,
SubDomainHost: "",
TcpMux: true,
SupportKcp: true,
MaxPoolCount: 5,
HeartBeatTimeout: 90,
UserConnTimeout: 10,
@@ -231,6 +233,13 @@ 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)