Https kcp

This commit is contained in:
刘河
2019-03-19 22:41:40 +08:00
parent 7ec3e82b0f
commit a66b465046
13 changed files with 129 additions and 74 deletions

View File

@@ -4,7 +4,6 @@ import (
"github.com/cnlh/nps/lib/mux"
"github.com/cnlh/nps/vender/github.com/astaxie/beego"
"github.com/cnlh/nps/vender/github.com/astaxie/beego/logs"
"github.com/cnlh/nps/vender/github.com/xtaci/kcp"
"net"
"os"
"strconv"
@@ -32,7 +31,7 @@ func InitConnectionService() {
}
}
func GetBridgeListener(tp string) (interface{}, error) {
func GetBridgeListener(tp string) (net.Listener, error) {
logs.Info("server start, the bridge type is %s, the bridge port is %s", tp, bridgePort)
var p int
var err error
@@ -41,13 +40,6 @@ func GetBridgeListener(tp string) (interface{}, error) {
}
if pMux != nil {
return pMux.GetClientListener(), nil
} else if tp == "udp" {
if p, err = beego.AppConfig.Int("bridge_port"); err != nil {
logs.Error(err)
os.Exit(0)
} else {
return kcp.ListenWithOptions(":"+strconv.Itoa(p), nil, 150, 3)
}
}
return net.ListenTCP("tcp", &net.TCPAddr{net.ParseIP(beego.AppConfig.String("bridge_ip")), p, ""})
}