From 83788b0f17e6590cee20eecf3a8e0a70c6fc4b2b Mon Sep 17 00:00:00 2001 From: Chen Yufei Date: Sat, 27 Sep 2014 23:00:07 +0800 Subject: [PATCH 1/3] Fix method overridden by default command option. --- cmd/shadowsocks-local/local.go | 6 ++++-- cmd/shadowsocks-server/server.go | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/shadowsocks-local/local.go b/cmd/shadowsocks-local/local.go index e0336a4..78d0995 100644 --- a/cmd/shadowsocks-local/local.go +++ b/cmd/shadowsocks-local/local.go @@ -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() @@ -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") diff --git a/cmd/shadowsocks-server/server.go b/cmd/shadowsocks-server/server.go index 391d2b2..6962b0b 100644 --- a/cmd/shadowsocks-server/server.go +++ b/cmd/shadowsocks-server/server.go @@ -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") @@ -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) From b51b1ba2e743f97a558641d300dbe7edd5ecd926 Mon Sep 17 00:00:00 2001 From: Chen Yufei Date: Sun, 28 Sep 2014 09:49:26 +0800 Subject: [PATCH 2/3] Use netcat to wait server start. --- script/test.sh | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/script/test.sh b/script/test.sh index 4a28832..1e2cf76 100755 --- a/script/test.sh +++ b/script/test.sh @@ -1,16 +1,30 @@ #!/bin/bash +# Use [ -n "$TRAVIS" ] to test for running on Travis-CI. + # Run in the scripts directory. cd "$( dirname "${BASH_SOURCE[0]}" )" -OPTION="-p 8389 -k foobar" LOCAL_PORT="1090" +SERVER_PORT="8389" +OPTION="-p $SERVER_PORT -k foobar" SOCKS="127.0.0.1:$LOCAL_PORT" HTTP_PORT="8123" +wait_server() { + local port + port=$1 + for i in {1..20}; do + # sleep first because this maybe called immediately after server start + sleep 0.1 + nc -z -w 4 127.0.0.1 $port && break + done +} + start_http_server() { go build http.go ./http $HTTP_PORT & + wait_server $HTTP_PORT http_pid=$! } @@ -20,6 +34,8 @@ stop_http_server() { test_get() { local url + local target + local code url=$1 target=$2 code=$3 @@ -56,24 +72,11 @@ test_shadowsocks() { $SERVER $OPTION -m "$method" & server_pid=$! + wait_server $SERVER_PORT + $LOCAL $OPTION -s 127.0.0.1 -l $LOCAL_PORT -m "$method" & local_pid=$! - - # Wait server and client finish startup. - sleeptime=0.1 - if [ -n "$TRAVIS" ]; then - # On Travis we need to wait a little longer. - sleeptime=1 - elif echo $SERVER $LOCAL | grep 'py'; then - # The python version is slow to start. - if [[ $method == "table" ]]; then - sleeptime=2 - else - sleeptime=0.5 - fi - fi - echo $sleeptime - sleep $sleeptime + wait_server $LOCAL_PORT for i in {1..3}; do if ! test_get $url "shadowsocks-go"; then From 144fa0f0d18b1fafcd94852e448a25c202154e41 Mon Sep 17 00:00:00 2001 From: Chen Yufei Date: Sun, 28 Sep 2014 10:09:54 +0800 Subject: [PATCH 3/3] Bump version to 1.1.3 --- CHANGELOG | 3 +++ README.md | 2 +- shadowsocks/util.go | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 72826e9..07fb962 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +1.1.3 (2014-09-28) + * Fix can't specify encryption method in config file + 1.1.2 (2014-09-21) * Support new encryption method "rc4-md5" * Use aes-256-cfb as default encryption method for command line app diff --git a/README.md b/README.md index 7106909..4939dd0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # shadowsocks-go -Current version: 1.1.2 [![Build Status](https://travis-ci.org/shadowsocks/shadowsocks-go.png?branch=develop)](https://travis-ci.org/shadowsocks/shadowsocks-go) +Current version: 1.1.3 [![Build Status](https://travis-ci.org/shadowsocks/shadowsocks-go.png?branch=develop)](https://travis-ci.org/shadowsocks/shadowsocks-go) shadowsocks-go is a lightweight tunnel proxy which can help you get through firewalls. It is a port of [shadowsocks](https://github.com/clowwindy/shadowsocks). diff --git a/shadowsocks/util.go b/shadowsocks/util.go index a026e9f..732a5a5 100644 --- a/shadowsocks/util.go +++ b/shadowsocks/util.go @@ -7,7 +7,7 @@ import ( ) func PrintVersion() { - const version = "1.1.2" + const version = "1.1.3" fmt.Println("shadowsocks-go version", version) }