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

respect timeout value in config file #482

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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