Skip to content

Commit

Permalink
Merge branch 'release/0.6.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
cyfdecyf committed Mar 4, 2013
2 parents 4a25aea + 979eefc commit 26da04e
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
@@ -1,5 +1,6 @@
language: go
install:
- go get github.com/cyfdecyf/leakybuf
- mkdir -p $GOPATH/src/github.com/shadowsocks/shadowsocks-go/shadowsocks
- mv * $GOPATH/src/github.com/shadowsocks/shadowsocks-go
- pushd $GOPATH/src/github.com/shadowsocks/shadowsocks-go
Expand All @@ -8,6 +9,5 @@ install:
- popd
script:
- pushd $GOPATH/src/github.com/shadowsocks/shadowsocks-go
- PATH=$PATH:$GOPATH/bin/ bash -x ./testscript/test.sh
- PATH=$PATH:$GOPATH/bin/ bash -x ./script/test.sh
- popd

5 changes: 5 additions & 0 deletions CHANGELOG
@@ -1,3 +1,8 @@
0.6.1 (2013-03-04)
* Small performance improvement
* For windows: provide shadowsocks-tray.exe to hide shadowsocks-local.exe in
system tray. (Thanks to phuslu's taskbar.)

0.6 (2013-01-23)

* Generate ciphers on demand (encryption table cache is removed)
Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,6 +1,6 @@
# shadowsocks-go

Current version: 0.6 [![Build Status](https://travis-ci.org/shadowsocks/shadowsocks-go.png)](https://travis-ci.org/shadowsocks/shadowsocks-go)
Current version: 0.6.1 [![Build Status](https://travis-ci.org/shadowsocks/shadowsocks-go.png)](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).

Expand Down
9 changes: 4 additions & 5 deletions cmd/shadowsocks-server/server.go
Expand Up @@ -14,7 +14,6 @@ import (
"runtime"
"strconv"
"sync"
"sync/atomic"
"syscall"
)

Expand Down Expand Up @@ -83,13 +82,13 @@ func getRequest(conn *ss.Conn) (host string, extra []byte, err error) {

const logCntDelta = 100

var connCnt int32
var nextLogConnCnt int32 = logCntDelta
var connCnt int
var nextLogConnCnt int = logCntDelta

func handleConnection(conn *ss.Conn) {
var host string

atomic.AddInt32(&connCnt, 1)
connCnt++ // this maybe not accurate, but should be enough
if connCnt-nextLogConnCnt >= 0 {
// XXX There's no xadd in the atomic package, so it's difficult to log
// the message only once with low cost. Also note nextLogConnCnt maybe
Expand All @@ -108,7 +107,7 @@ func handleConnection(conn *ss.Conn) {
if debug {
debug.Printf("closed pipe %s<->%s\n", conn.RemoteAddr(), host)
}
atomic.AddInt32(&connCnt, -1)
connCnt--
if !closed {
conn.Close()
}
Expand Down
2 changes: 1 addition & 1 deletion deb/DEBIAN/control
@@ -1,5 +1,5 @@
Package: shadowsocks-go
Version: 0.6-1
Version: 0.6.1-1
Section: net
Priority: optional
Architecture: any
Expand Down
50 changes: 50 additions & 0 deletions script/build.sh
@@ -0,0 +1,50 @@
#!/bin/bash

cd "$( dirname "${BASH_SOURCE[0]}" )/.."

version=`grep 'const version = ' ./shadowsocks/util.go | sed -e 's/.*= //' | sed -e 's/"//g'`
echo "creating shadowsocks binary version $version"

export CGO_ENABLED=0

ROOT=`pwd`
bindir=$ROOT/bin
mkdir -p $bindir

build() {
local name
local GOOS
local GOARCH

prog=shadowsocks-$4
pushd cmd/$prog
name=$prog-$3-$version
echo "building $name"
GOOS=$1 GOARCH=$2 go build -a || exit 1
if [[ $1 == "windows" ]]; then
mv $prog.exe $ROOT/script/
pushd $ROOT/script/
zip $name.zip $prog.exe shadowsocks-tray.exe
rm -f $prog.exe
mv $name.zip $bindir
popd
else
mv $prog $name
gzip -f $name
mv $name.gz $bindir
fi
popd
}

build darwin amd64 mac64 local
build linux amd64 linux64 local
build linux 386 linux32 local
build windows amd64 win64 local
build windows 386 win32 local

#build darwin amd64 mac64 server
#build linux amd64 linux64 server
#build linux 386 linux32 server
#build windows amd64 win64 server
#build windows 386 win32 server

6 changes: 5 additions & 1 deletion createdeb.sh → script/createdeb.sh
@@ -1,5 +1,8 @@
#!/bin/bash

cd "$( dirname "${BASH_SOURCE[0]}" )/.."
ver=$(awk '/\tconst version =/ { print $4 }' shadowsocks/util.go | sed -e 's/"//g')

if [[ $# != 1 ]]; then
echo "$0 <arch, i386 or amd64>"
exit 1
Expand Down Expand Up @@ -28,14 +31,15 @@ go build -a -v || exit 1
popd

# create debian package
DEBDIR=shadowsocks-go_0.6-1-$arch
DEBDIR=shadowsocks-go_$ver-1-$arch
rm -rf $DEBDIR
cp -r deb $DEBDIR

sed -i -e "s/^Architecture.*$/Architecture: $arch/" $DEBDIR/DEBIAN/control || exit 1

mkdir -p $DEBDIR/usr/bin
cp cmd/shadowsocks-server/shadowsocks-server $DEBDIR/usr/bin/shadowsocks
rm -f cmd/shadowsocks-server/shadowsocks-server

fakeroot dpkg-deb --build $DEBDIR

File renamed without changes.
Binary file added script/shadowsocks-tray.exe
Binary file not shown.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions shadowsocks/encrypt.go
Expand Up @@ -8,6 +8,8 @@ import (
"errors"
)

var errEmptyKey = errors.New("empty key")

type Cipher interface {
// Some ciphers maintains context (e.g. RC4), which means different
// connections need to use their own ciphers. Copy() will create an copy
Expand All @@ -27,6 +29,9 @@ type TableCipher struct {

// Creates a new table based cipher. err is always nil.
func NewTableCipher(key string) (c Cipher, err error) {
if key == "" {
return nil, errEmptyKey
}
const tbl_size = 256
tbl := TableCipher{
make([]byte, tbl_size),
Expand Down Expand Up @@ -83,6 +88,9 @@ type RC4Cipher struct {
}

func NewRC4Cipher(key string) (c Cipher, err error) {
if key == "" {
return nil, errEmptyKey
}
h := md5.New()
h.Write([]byte(key))
enc, err := rc4.NewCipher(h.Sum(nil))
Expand Down
9 changes: 8 additions & 1 deletion shadowsocks/pipe.go
Expand Up @@ -2,6 +2,7 @@ package shadowsocks

import (
// "io"
"github.com/cyfdecyf/leakybuf"
"net"
"time"
)
Expand All @@ -17,10 +18,16 @@ func SetReadTimeout(c net.Conn) {
}
}

const bufSize = 4096
const nBuf = 2048

var pipeBuf = leakybuf.NewLeakyBuf(nBuf, bufSize)

// PipeThenClose copies data from src to dst, closes dst when done.
func PipeThenClose(src, dst net.Conn, timeoutOpt int) {
defer dst.Close()
buf := make([]byte, 4096)
buf := pipeBuf.Get()
defer pipeBuf.Put(buf)
for {
if timeoutOpt == SET_TIMEOUT {
SetReadTimeout(src)
Expand Down
2 changes: 1 addition & 1 deletion shadowsocks/util.go
Expand Up @@ -7,7 +7,7 @@ import (
)

func PrintVersion() {
const version = "0.6"
const version = "0.6.1"
fmt.Println("shadowsocks-go version", version)
}

Expand Down

0 comments on commit 26da04e

Please sign in to comment.