From db2a4508abe46701dc106b4de0611f030b0daa4b Mon Sep 17 00:00:00 2001 From: Chen Yufei Date: Wed, 29 May 2013 09:56:36 +0800 Subject: [PATCH 1/4] Store cipherInfo pointer in cipherMethod map. --- shadowsocks/encrypt.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/shadowsocks/encrypt.go b/shadowsocks/encrypt.go index 16261074..4294e38a 100644 --- a/shadowsocks/encrypt.go +++ b/shadowsocks/encrypt.go @@ -89,12 +89,6 @@ func newRC4Cipher(key []byte) (enc, dec cipher.Stream, err error) { return rc4Enc, &rc4Dec, nil } -type cipherInfo struct { - keyLen int - ivLen int - newBlock func([]byte) (cipher.Block, error) -} - // Ciphers from go.crypto has NewCipher returning specific type of cipher // instead of cipher.Block, so we need to have the following adapter // functions. @@ -109,7 +103,13 @@ func newCast5Cipher(key []byte) (cipher.Block, error) { return cast5.NewCipher(key) } -var cipherMethod = map[string]cipherInfo{ +type cipherInfo struct { + keyLen int + ivLen int + newBlock func([]byte) (cipher.Block, error) +} + +var cipherMethod = map[string]*cipherInfo{ "aes-128-cfb": {16, 16, aes.NewCipher}, "aes-192-cfb": {24, 16, aes.NewCipher}, "aes-256-cfb": {32, 16, aes.NewCipher}, @@ -149,7 +149,7 @@ func NewCipher(method, password string) (c *Cipher, err error) { key := evpBytesToKey(password, mi.keyLen) - c = &Cipher{key: key, info: &mi} + c = &Cipher{key: key, info: mi} if mi.newBlock == nil { if method == "" { From eac7fb97db52ce319299ae18097c2f0abbf16a52 Mon Sep 17 00:00:00 2001 From: Chen Yufei Date: Mon, 10 Jun 2013 13:27:58 +0800 Subject: [PATCH 2/4] Fix travis build. Travis is now using gvm, GOPATH changed. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 89d0689a..f07fc39f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,6 @@ install: - go install ./cmd/shadowsocks-server - popd script: - - pushd $GOPATH/src/github.com/shadowsocks/shadowsocks-go - - PATH=$PATH:$GOPATH/bin/ bash -x ./script/test.sh + - pushd $TRAVIS_BUILD_DIR + - PATH=$PATH:$HOME/gopath/bin bash -x ./script/test.sh - popd From b38d7e0a7bae94bc0e71757bc6f370ef8d1e4b2f Mon Sep 17 00:00:00 2001 From: Chen Yufei Date: Mon, 10 Jun 2013 13:42:05 +0800 Subject: [PATCH 3/4] Add note to send pull request on develop branch. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2384a61c..bc9f0f06 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ The protocol is compatible with the origin shadowsocks (if both have been upgrad **Note `server_password` option syntax changed in 0.6.2, the client now connects to servers in the order specified in the config.** +**Please develop on the latest develop branch if you want to send pull request.** + # Install Compiled client binaries can be download [here](http://dl.chenyufei.info/shadowsocks/). (All compiled with cgo disabled, except the mac version.) From 38a11213399f0ef59ff754ed7c416fc21f40c8b3 Mon Sep 17 00:00:00 2001 From: hugozhu Date: Mon, 10 Jun 2013 15:19:35 +0800 Subject: [PATCH 4/4] Added handler for fields of interface(), So we are able to update config field server from cmd --- shadowsocks/config.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shadowsocks/config.go b/shadowsocks/config.go index 273c0f42..f96ff504 100644 --- a/shadowsocks/config.go +++ b/shadowsocks/config.go @@ -108,6 +108,10 @@ func UpdateConfig(old, new *Config) { // log.Printf("%d: %s %s = %v\n", i, // typeOfT.Field(i).Name, newField.Type(), newField.Interface()) switch newField.Kind() { + case reflect.Interface: + if fmt.Sprintf("%v", newField.Interface()) != "" { + oldField.Set(newField) + } case reflect.String: s := newField.String() if s != "" {