Skip to content

Commit

Permalink
Fix method overridden by default command option.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyfdecyf committed Sep 27, 2014
1 parent fb3fcfa commit 83788b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cmd/shadowsocks-local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func main() {
flag.StringVar(&cmdConfig.Password, "k", "", "password")
flag.IntVar(&cmdConfig.ServerPort, "p", 0, "server port")
flag.IntVar(&cmdConfig.LocalPort, "l", 0, "local socks5 proxy port")
flag.StringVar(&cmdConfig.Method, "m", "aes-256-cfb", "encryption method")
flag.StringVar(&cmdConfig.Method, "m", "", "encryption method, default: aes-256-cfb")
flag.BoolVar((*bool)(&debug), "d", false, "print debug message")

flag.Parse()
Expand Down Expand Up @@ -388,7 +388,9 @@ func main() {
} else {
ss.UpdateConfig(config, &cmdConfig)
}

if config.Method == "" {
config.Method = "aes-256-cfb"
}
if len(config.ServerPassword) == 0 {
if !enoughOptions(config) {
fmt.Fprintln(os.Stderr, "must specify server address, password and both server/local port")
Expand Down
5 changes: 4 additions & 1 deletion cmd/shadowsocks-server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func main() {
flag.StringVar(&cmdConfig.Password, "k", "", "password")
flag.IntVar(&cmdConfig.ServerPort, "p", 0, "server port")
flag.IntVar(&cmdConfig.Timeout, "t", 60, "connection timeout (in seconds)")
flag.StringVar(&cmdConfig.Method, "m", "aes-256-cfb", "encryption method")
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 @@ -346,6 +346,9 @@ func main() {
} else {
ss.UpdateConfig(config, &cmdConfig)
}
if config.Method == "" {
config.Method = "aes-256-cfb"
}
if err = ss.CheckCipherMethod(config.Method); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
Expand Down

0 comments on commit 83788b0

Please sign in to comment.