mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 03:16:53 +00:00
结构调整、kcp支持
This commit is contained in:
@@ -3,8 +3,9 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"github.com/cnlh/nps/client"
|
||||
"github.com/cnlh/nps/lib"
|
||||
_ "github.com/cnlh/nps/lib"
|
||||
"github.com/cnlh/nps/lib/daemon"
|
||||
"github.com/cnlh/nps/lib/lg"
|
||||
"github.com/cnlh/nps/lib/common"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -14,20 +15,21 @@ var (
|
||||
serverAddr = flag.String("server", "", "服务器地址ip:端口")
|
||||
verifyKey = flag.String("vkey", "", "验证密钥")
|
||||
logType = flag.String("log", "stdout", "日志输出方式(stdout|file)")
|
||||
connType = flag.String("type", "tcp", "与服务端建立连接方式(kcp|tcp)")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
lib.InitDaemon("npc")
|
||||
daemon.InitDaemon("npc", common.GetRunPath(), common.GetPidPath())
|
||||
if *logType == "stdout" {
|
||||
lib.InitLogFile("npc", true)
|
||||
lg.InitLogFile("npc", true, common.GetLogPath())
|
||||
} else {
|
||||
lib.InitLogFile("npc", false)
|
||||
lg.InitLogFile("npc", false, common.GetLogPath())
|
||||
}
|
||||
stop := make(chan int)
|
||||
for _, v := range strings.Split(*verifyKey, ",") {
|
||||
lib.Println("客户端启动,连接:", *serverAddr, " 验证令牌:", v)
|
||||
go client.NewRPClient(*serverAddr, v).Start()
|
||||
lg.Println("客户端启动,连接:", *serverAddr, " 验证令牌:", v)
|
||||
go client.NewRPClient(*serverAddr, v, *connType).Start()
|
||||
}
|
||||
<-stop
|
||||
}
|
||||
|
Reference in New Issue
Block a user