Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Commit

Permalink
respect timeout value in config file
Browse files Browse the repository at this point in the history
  • Loading branch information
ayanamist committed Jul 2, 2019
1 parent 6a03846 commit a161fcb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cmd/shadowsocks-local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ var (
const (
socksVer5 = 5
socksCmdConnect = 1

defaultTimeout = 300
)

func init() {
Expand Down Expand Up @@ -414,7 +416,7 @@ func main() {
flag.StringVar(&cmdConfig.LocalAddress, "b", "", "local address, listen only to this address if specified")
flag.StringVar(&cmdConfig.Password, "k", "", "password")
flag.IntVar(&cmdConfig.ServerPort, "p", 0, "server port")
flag.IntVar(&cmdConfig.Timeout, "t", 300, "timeout in seconds")
flag.IntVar(&cmdConfig.Timeout, "t", 0, "timeout in seconds")
flag.IntVar(&cmdConfig.LocalPort, "l", 0, "local socks5 proxy port")
flag.StringVar(&cmdConfig.Method, "m", "", "encryption method, default: aes-256-cfb")
flag.BoolVar((*bool)(&debug), "d", false, "print debug message")
Expand Down Expand Up @@ -456,6 +458,9 @@ func main() {
os.Exit(1)
}
} else {
if config.Timeout == 0 && cmdConfig.Timeout == 0 {
cmdConfig.Timeout = defaultTimeout
}
ss.UpdateConfig(config, &cmdConfig)
}
if config.Method == "" {
Expand Down
7 changes: 6 additions & 1 deletion cmd/shadowsocks-server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const (
lenIPv6 = net.IPv6len + 2 // ipv6 + 2port
lenDmBase = 2 // 1addrLen + 2port, plus addrLen
// lenHmacSha1 = 10

defaultTimeout = 300
)

var debug ss.DebugLog
Expand Down Expand Up @@ -437,7 +439,7 @@ func main() {
flag.StringVar(&configFile, "c", "config.json", "specify config file")
flag.StringVar(&cmdConfig.Password, "k", "", "password")
flag.IntVar(&cmdConfig.ServerPort, "p", 0, "server port")
flag.IntVar(&cmdConfig.Timeout, "t", 300, "timeout in seconds")
flag.IntVar(&cmdConfig.Timeout, "t", 0, "timeout in seconds")
flag.StringVar(&cmdConfig.Method, "m", "", "encryption method, default: aes-256-cfb")
flag.IntVar(&core, "core", 0, "maximum number of CPU cores to use, default is determinied by Go runtime")
flag.BoolVar((*bool)(&debug), "d", false, "print debug message")
Expand All @@ -463,6 +465,9 @@ func main() {
config = &cmdConfig
ss.UpdateConfig(config, config)
} else {
if config.Timeout == 0 && cmdConfig.Timeout == 0 {
cmdConfig.Timeout = defaultTimeout
}
ss.UpdateConfig(config, &cmdConfig)
}
if config.Method == "" {
Expand Down

0 comments on commit a161fcb

Please sign in to comment.