nps/cmd/npc/npc.go
2019-02-09 17:07:47 +08:00

36 lines
968 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"flag"
"github.com/cnlh/nps/client"
"github.com/cnlh/nps/lib/daemon"
"github.com/cnlh/nps/lib/lg"
"github.com/cnlh/nps/lib/common"
"strings"
)
const VERSION = "v0.0.13"
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()
daemon.InitDaemon("npc", common.GetRunPath(), common.GetPidPath())
if *logType == "stdout" {
lg.InitLogFile("npc", true, common.GetLogPath())
} else {
lg.InitLogFile("npc", false, common.GetLogPath())
}
stop := make(chan int)
for _, v := range strings.Split(*verifyKey, ",") {
lg.Println("客户端启动,连接:", *serverAddr, " 验证令牌:", v)
go client.NewRPClient(*serverAddr, v, *connType).Start()
}
<-stop
}