-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add custom client disconnect timeout option, close #485
- Loading branch information
Showing
15 changed files
with
89 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,23 +21,24 @@ import ( | |
) | ||
|
||
var ( | ||
serverAddr = flag.String("server", "", "Server addr (ip:port)") | ||
configPath = flag.String("config", "", "Configuration file path") | ||
verifyKey = flag.String("vkey", "", "Authentication key") | ||
logType = flag.String("log", "stdout", "Log output mode(stdout|file)") | ||
connType = flag.String("type", "tcp", "Connection type with the server(kcp|tcp)") | ||
proxyUrl = flag.String("proxy", "", "proxy socks5 url(eg:socks5://111:[email protected]:9007)") | ||
logLevel = flag.String("log_level", "7", "log level 0~7") | ||
registerTime = flag.Int("time", 2, "register time long /h") | ||
localPort = flag.Int("local_port", 2000, "p2p local port") | ||
password = flag.String("password", "", "p2p password flag") | ||
target = flag.String("target", "", "p2p target") | ||
localType = flag.String("local_type", "p2p", "p2p target") | ||
logPath = flag.String("log_path", "", "npc log path") | ||
debug = flag.Bool("debug", true, "npc debug") | ||
pprofAddr = flag.String("pprof", "", "PProf debug addr (ip:port)") | ||
stunAddr = flag.String("stun_addr", "stun.stunprotocol.org:3478", "stun server address (eg:stun.stunprotocol.org:3478)") | ||
ver = flag.Bool("version", false, "show current version") | ||
serverAddr = flag.String("server", "", "Server addr (ip:port)") | ||
configPath = flag.String("config", "", "Configuration file path") | ||
verifyKey = flag.String("vkey", "", "Authentication key") | ||
logType = flag.String("log", "stdout", "Log output mode(stdout|file)") | ||
connType = flag.String("type", "tcp", "Connection type with the server(kcp|tcp)") | ||
proxyUrl = flag.String("proxy", "", "proxy socks5 url(eg:socks5://111:[email protected]:9007)") | ||
logLevel = flag.String("log_level", "7", "log level 0~7") | ||
registerTime = flag.Int("time", 2, "register time long /h") | ||
localPort = flag.Int("local_port", 2000, "p2p local port") | ||
password = flag.String("password", "", "p2p password flag") | ||
target = flag.String("target", "", "p2p target") | ||
localType = flag.String("local_type", "p2p", "p2p target") | ||
logPath = flag.String("log_path", "", "npc log path") | ||
debug = flag.Bool("debug", true, "npc debug") | ||
pprofAddr = flag.String("pprof", "", "PProf debug addr (ip:port)") | ||
stunAddr = flag.String("stun_addr", "stun.stunprotocol.org:3478", "stun server address (eg:stun.stunprotocol.org:3478)") | ||
ver = flag.Bool("version", false, "show current version") | ||
disconnectTime = flag.Int("disconnect_timeout", 60, "not receiving check packet times, until timeout will disconnect the client") | ||
) | ||
|
||
func main() { | ||
|
@@ -231,7 +232,7 @@ func run() { | |
if *verifyKey != "" && *serverAddr != "" && *configPath == "" { | ||
go func() { | ||
for { | ||
client.NewRPClient(*serverAddr, *verifyKey, *connType, *proxyUrl, nil).Start() | ||
client.NewRPClient(*serverAddr, *verifyKey, *connType, *proxyUrl, nil, *disconnectTime).Start() | ||
logs.Info("It will be reconnected in five seconds") | ||
time.Sleep(time.Second * 5) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters