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

Commit 733f2a3

Browse files
committed
Merge branch 'develop', version 1.1.2
2 parents c33324b + fb3fcfa commit 733f2a3

20 files changed

+235
-117
lines changed

.travis.yml

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
language: go
22
go:
3-
- 1.1
3+
- 1.3
44
install:
5-
- go get github.com/cyfdecyf/leakybuf
65
- go get code.google.com/p/go.crypto/blowfish
76
- go get code.google.com/p/go.crypto/cast5
8-
- pushd $TRAVIS_BUILD_DIR
97
- go install ./cmd/shadowsocks-local
108
- go install ./cmd/shadowsocks-server
11-
- popd
129
script:
13-
- pushd $TRAVIS_BUILD_DIR
1410
- PATH=$PATH:$HOME/gopath/bin bash -x ./script/test.sh
15-
- popd

CHANGELOG

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.1.2 (2014-09-21)
2+
* Support new encryption method "rc4-md5"
3+
* Use aes-256-cfb as default encryption method for command line app
4+
15
1.1.1 (2013-07-12)
26
* Add -b option to limit listen address for client
37
* Fix can't override server address on command line

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# shadowsocks-go
22

3-
Current version: 1.1.1 [![Build Status](https://travis-ci.org/shadowsocks/shadowsocks-go.png?branch=master)](https://travis-ci.org/shadowsocks/shadowsocks-go)
3+
Current version: 1.1.2 [![Build Status](https://travis-ci.org/shadowsocks/shadowsocks-go.png?branch=master)](https://travis-ci.org/shadowsocks/shadowsocks-go)
44

55
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).
66

@@ -23,7 +23,7 @@ go get github.com/shadowsocks/shadowsocks-go/cmd/shadowsocks-server
2323
go get github.com/shadowsocks/shadowsocks-go/cmd/shadowsocks-local
2424
```
2525

26-
It's recommend to disable cgo when compiling shadowsocks-go. This will prevent the go runtime from creating too many threads for dns lookup.
26+
It's recommended to disable cgo when compiling shadowsocks-go. This will prevent the go runtime from creating too many threads for dns lookup.
2727

2828
# Usage
2929

@@ -35,8 +35,8 @@ Configuration file is in json format and has the same syntax with [shadowsocks-n
3535
server your server ip or hostname
3636
server_port server port
3737
local_port local socks5 proxy port
38-
method encryption method, null by default, the following methods are supported:
39-
aes-128-cfb, aes-192-cfb, aes-256-cfb, bf-cfb, cast5-cfb, des-cfb, rc4
38+
method encryption method, null by default (table), the following methods are supported:
39+
aes-128-cfb, aes-192-cfb, aes-256-cfb, bf-cfb, cast5-cfb, des-cfb, rc4-md5, rc4, table
4040
password a password used to encrypt transfer
4141
timeout server option, in seconds
4242
```
@@ -51,20 +51,20 @@ SOCKS5 127.0.0.1:local_port
5151

5252
## About encryption methods
5353

54-
AES is recommended for shadowsocks-go. ([Intel AES Instruction Set](http://en.wikipedia.org/wiki/AES_instruction_set) will be used if available and can make encryption/decryption fast.)
54+
AES is recommended for shadowsocks-go. [Intel AES Instruction Set](http://en.wikipedia.org/wiki/AES_instruction_set) will be used if available and can make encryption/decryption very fast. To be more specific, **`aes-128-cfb` is recommended as it is faster and [secure enough](https://www.schneier.com/blog/archives/2009/07/another_new_aes.html)**.
5555

56-
**rc4 and table encryption methods are deprecated because they are not secure**.
56+
**rc4 and table encryption methods are deprecated because they are not secure.**
5757

5858
## Command line options
5959

6060
Command line options can override settings from configuration files. Use `-h` option to see all available options.
6161

6262
```
6363
shadowsocks-local -s server_address -p server_port -k password
64-
-m rc4 -c config.json
64+
-m aes-128-cfb -c config.json
6565
-b local_address -l local_port
6666
shadowsocks-server -p server_port -k password
67-
-m rc4 -c config.json
67+
-m aes-128-cfb -c config.json
6868
-t timeout
6969
```
7070

cmd/shadowsocks-local/local.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func main() {
355355
flag.StringVar(&cmdConfig.Password, "k", "", "password")
356356
flag.IntVar(&cmdConfig.ServerPort, "p", 0, "server port")
357357
flag.IntVar(&cmdConfig.LocalPort, "l", 0, "local socks5 proxy port")
358-
flag.StringVar(&cmdConfig.Method, "m", "", "encryption method, use empty string or rc4")
358+
flag.StringVar(&cmdConfig.Method, "m", "aes-256-cfb", "encryption method")
359359
flag.BoolVar((*bool)(&debug), "d", false, "print debug message")
360360

361361
flag.Parse()

cmd/shadowsocks-server/server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func getRequest(conn *ss.Conn) (host string, extra []byte, err error) {
5757
case typeDm:
5858
reqLen = int(buf[idDmLen]) + lenDmBase
5959
default:
60-
err = errors.New(fmt.Sprintf("addr type %d not supported", buf[idType]))
60+
err = fmt.Errorf("addr type %d not supported", buf[idType])
6161
return
6262
}
6363

@@ -322,7 +322,7 @@ func main() {
322322
flag.StringVar(&cmdConfig.Password, "k", "", "password")
323323
flag.IntVar(&cmdConfig.ServerPort, "p", 0, "server port")
324324
flag.IntVar(&cmdConfig.Timeout, "t", 60, "connection timeout (in seconds)")
325-
flag.StringVar(&cmdConfig.Method, "m", "", "encryption method, use empty string or rc4")
325+
flag.StringVar(&cmdConfig.Method, "m", "aes-256-cfb", "encryption method")
326326
flag.IntVar(&core, "core", 0, "maximum number of CPU cores to use, default is determinied by Go runtime")
327327
flag.BoolVar((*bool)(&debug), "d", false, "print debug message")
328328

config.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"server_port":8388,
44
"local_port":1080,
55
"password":"barfoo!",
6+
"method": "aes-128-cfb",
67
"timeout":600
78
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"local_port":1081,
2+
"local_port": 1081,
33
"server_password": [
44
["127.0.0.1:8387", "foobar"],
5-
["127.0.0.1:8388", "barfoo", "rc4"]
5+
["127.0.0.1:8388", "barfoo", "aes-128-cfb"]
66
]
77
}

sample-config/server-multi-port.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"8387": "foobar",
44
"8388": "barfoo"
55
},
6-
"timeout": 600,
6+
"method": "aes-128-cfb",
7+
"timeout": 600
78
}

script/build.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ build windows 386 win32 local
5151

5252
build linux amd64 linux64 server
5353
build linux 386 linux32 server
54-
#build darwin amd64 mac64 server
54+
build darwin amd64 mac64 server
5555
build windows amd64 win64 server
5656
build windows 386 win32 server
5757

58-
script/createdeb.sh amd64
59-
script/createdeb.sh 386
60-
mv shadowsocks-go_$version-1-*.deb bin/
61-
rm -rf shadowsocks-go_$version-1*
58+
#script/createdeb.sh amd64
59+
#script/createdeb.sh i386
60+
#mv shadowsocks-go_$version-1-*.deb bin/
61+
#rm -rf shadowsocks-go_$version-1*

script/createdeb.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export GOOS=linux
1313

1414
arch=$1
1515
case $arch in
16-
386)
16+
i386)
1717
export GOARCH=386
1818
;;
1919
amd64)

script/http.go

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* Simple http server for testing. */
2+
package main
3+
4+
import (
5+
"fmt"
6+
"net/http"
7+
"os"
8+
)
9+
10+
func handler(w http.ResponseWriter, r *http.Request) {
11+
fmt.Fprintf(w, "Hello, shadowsocks-go!")
12+
}
13+
14+
func main() {
15+
if len(os.Args) != 2 {
16+
fmt.Println("Usage: http <port>")
17+
os.Exit(1)
18+
}
19+
http.HandleFunc("/", handler)
20+
http.ListenAndServe("127.0.0.1:"+os.Args[1], nil)
21+
}

script/test.sh

+48-26
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
#!/bin/bash
22

3+
# Run in the scripts directory.
4+
cd "$( dirname "${BASH_SOURCE[0]}" )"
5+
36
OPTION="-p 8389 -k foobar"
47
LOCAL_PORT="1090"
58
SOCKS="127.0.0.1:$LOCAL_PORT"
9+
HTTP_PORT="8123"
10+
11+
start_http_server() {
12+
go build http.go
13+
./http $HTTP_PORT &
14+
http_pid=$!
15+
}
16+
17+
stop_http_server() {
18+
kill -SIGTERM $http_pid
19+
}
620

721
test_get() {
822
local url
@@ -45,23 +59,36 @@ test_shadowsocks() {
4559
$LOCAL $OPTION -s 127.0.0.1 -l $LOCAL_PORT -m "$method" &
4660
local_pid=$!
4761

48-
# wait server and client finish startup
49-
sleep 1
62+
# Wait server and client finish startup.
63+
sleeptime=0.1
64+
if [ -n "$TRAVIS" ]; then
65+
# On Travis we need to wait a little longer.
66+
sleeptime=1
67+
elif echo $SERVER $LOCAL | grep 'py'; then
68+
# The python version is slow to start.
69+
if [[ $method == "table" ]]; then
70+
sleeptime=2
71+
else
72+
sleeptime=0.5
73+
fi
74+
fi
75+
echo $sleeptime
76+
sleep $sleeptime
5077

5178
for i in {1..3}; do
52-
if ! test_get $url "<html"; then
79+
if ! test_get $url "shadowsocks-go"; then
5380
kill -SIGTERM $server_pid
5481
kill -SIGTERM $local_pid
82+
stop_http_server
5583
exit 1
5684
fi
57-
sleep 0.3
5885
done
5986
echo "=============================="
6087
echo "GET $url $method passed"
6188
echo "=============================="
6289
kill -SIGTERM $server_pid
6390
kill -SIGTERM $local_pid
64-
sleep 1
91+
sleep 0.1
6592
}
6693

6794
test_server_local_pair() {
@@ -70,37 +97,32 @@ test_server_local_pair() {
7097
echo "============================================================"
7198

7299
local url
73-
if [[ -z "$TRAVIS" ]]; then
74-
url="www.baidu.com"
75-
else
76-
# on travis
77-
url="www.google.com"
78-
fi
79-
test_shadowsocks baidu.com table
80-
test_shadowsocks baidu.com rc4
81-
test_shadowsocks baidu.com aes-128-cfb
82-
test_shadowsocks baidu.com aes-192-cfb
83-
test_shadowsocks baidu.com aes-256-cfb
84-
test_shadowsocks baidu.com bf-cfb
85-
test_shadowsocks baidu.com des-cfb
86-
test_shadowsocks baidu.com cast5-cfb
100+
url=http://127.0.0.1:$HTTP_PORT/README.md
101+
test_shadowsocks $url table
102+
test_shadowsocks $url rc4
103+
test_shadowsocks $url rc4-md5
104+
test_shadowsocks $url aes-128-cfb
105+
test_shadowsocks $url aes-192-cfb
106+
test_shadowsocks $url aes-256-cfb
107+
test_shadowsocks $url bf-cfb
108+
test_shadowsocks $url des-cfb
109+
test_shadowsocks $url cast5-cfb
87110
}
88111

112+
start_http_server
113+
89114
SERVER="shadowsocks-server"
90115
LOCAL="shadowsocks-local"
91116
test_server_local_pair
92117

93-
if [[ -n $SS_NODEJS ]]; then
94-
pushd $SS_NODEJS
95-
96-
SERVER="node server.js"
118+
if [[ -n $SS_PYTHON ]]; then
119+
SERVER="$SS_PYTHON/server.py"
97120
LOCAL="shadowsocks-local"
98121
test_server_local_pair
99122

100123
SERVER="shadowsocks-server"
101-
LOCAL="node local.js"
124+
LOCAL="$SS_PYTHON/local.py"
102125
test_server_local_pair
103-
104-
popd $SS_NODEJS
105126
fi
106127

128+
stop_http_server

shadowsocks/config_test.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@ import (
55
)
66

77
func TestConfigJson(t *testing.T) {
8-
config, err := ParseConfig("testdata/config.json")
8+
config, err := ParseConfig("../config.json")
99
if err != nil {
1010
t.Fatal("error parsing config.json:", err)
1111
}
1212

1313
if config.Password != "barfoo!" {
1414
t.Error("wrong password from config")
1515
}
16-
if config.Timeout != 0 {
17-
t.Error("tiemout should default to 0")
16+
if config.Timeout != 600 {
17+
t.Error("timeout should be 600")
18+
}
19+
if config.Method != "aes-128-cfb" {
20+
t.Error("method should be aes-128-cfb")
1821
}
1922
srvArr := config.GetServerArray()
2023
if len(srvArr) != 1 || srvArr[0] != "127.0.0.1" {
@@ -25,7 +28,7 @@ func TestConfigJson(t *testing.T) {
2528
func TestServerMultiPort(t *testing.T) {
2629
config, err := ParseConfig("../sample-config/server-multi-port.json")
2730
if err != nil {
28-
t.Fatal("error parsing multi server-multi-port.json:", err)
31+
t.Fatal("error parsing ../sample-config/server-multi-port.json:", err)
2932
}
3033

3134
if config.PortPassword["8387"] != "foobar" {
@@ -85,7 +88,7 @@ func TestClientMultiServerArray(t *testing.T) {
8588
if sv[1] != "barfoo" {
8689
t.Error("server_password 2nd server passwd wrong")
8790
}
88-
if sv[2] != "rc4" {
91+
if sv[2] != "aes-128-cfb" {
8992
t.Error("server_password 2nd server enc method wrong")
9093
}
9194
}

0 commit comments

Comments
 (0)