diff --git a/README.md b/README.md index 9223c63b..377f7bca 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ It is a port of [shadowsocks](https://github.com/clowwindy/shadowsocks) created by [@clowwindy](https://github.com/clowwindy) maintained by [@madeye](https://github.com/madeye) and [@linusyang](https://github.com/linusyang). -Current version: 1.5.0 | [![Build Status](https://travis-ci.org/madeye/shadowsocks-libev.png?branch=master)](https://travis-ci.org/madeye/shadowsocks-libev) | [Changelog](Changes) +Current version: 1.5.1 | [![Build Status](https://travis-ci.org/madeye/shadowsocks-libev.png?branch=master)](https://travis-ci.org/madeye/shadowsocks-libev) | [Changelog](Changes) Features -------- diff --git a/configure b/configure index 43352d04..bbcb728f 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for shadowsocks 1.5.0. +# Generated by GNU Autoconf 2.69 for shadowsocks 1.5.1. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='shadowsocks' PACKAGE_TARNAME='shadowsocks' -PACKAGE_VERSION='1.5.0' -PACKAGE_STRING='shadowsocks 1.5.0' +PACKAGE_VERSION='1.5.1' +PACKAGE_STRING='shadowsocks 1.5.1' PACKAGE_BUGREPORT='max.c.lv@gmail.com' PACKAGE_URL='' @@ -1325,7 +1325,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures shadowsocks 1.5.0 to adapt to many kinds of systems. +\`configure' configures shadowsocks 1.5.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1395,7 +1395,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of shadowsocks 1.5.0:";; + short | recursive ) echo "Configuration of shadowsocks 1.5.1:";; esac cat <<\_ACEOF @@ -1512,7 +1512,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -shadowsocks configure 1.5.0 +shadowsocks configure 1.5.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2035,7 +2035,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by shadowsocks $as_me 1.5.0, which was +It was created by shadowsocks $as_me 1.5.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2856,7 +2856,7 @@ fi # Define the identity of the package. PACKAGE='shadowsocks' - VERSION='1.5.0' + VERSION='1.5.1' cat >>confdefs.h <<_ACEOF @@ -15526,7 +15526,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by shadowsocks $as_me 1.5.0, which was +This file was extended by shadowsocks $as_me 1.5.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -15592,7 +15592,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -shadowsocks config.status 1.5.0 +shadowsocks config.status 1.5.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index c79692b9..36830520 100755 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl -*- Autoconf -*- dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.67]) -AC_INIT([shadowsocks], [1.5.0], [max.c.lv@gmail.com]) +AC_INIT([shadowsocks], [1.5.1], [max.c.lv@gmail.com]) AC_CONFIG_SRCDIR([src/encrypt.c]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_AUX_DIR(auto) diff --git a/debian/changelog b/debian/changelog index 5842af30..76a30af7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +shadowsocks (1.5.1-1) unstable; urgency=low + + * Fix a bug of tcp fast open. + + -- Max Lv Sat, 08 Nov 2014 19:45:37 +0900 + shadowsocks (1.5.0-1) unstable; urgency=low * Support to build static or shared library. diff --git a/openwrt/Makefile b/openwrt/Makefile index 334bff7b..263b7187 100644 --- a/openwrt/Makefile +++ b/openwrt/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=shadowsocks-libev -PKG_VERSION:=1.5.0 +PKG_VERSION:=1.5.1 PKG_RELEASE=$(PKG_SOURCE_VERSION) PKG_SOURCE_URL:=https://github.com/madeye/shadowsocks-libev/archive diff --git a/src/local.c b/src/local.c index e28db052..3eb14484 100644 --- a/src/local.c +++ b/src/local.c @@ -203,7 +203,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) } } - while (r > 0) + while (1) { // local socks5 server if (server->stage == 5) @@ -215,27 +215,9 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) return; } - // Copy to remote->buf - if (buf != remote->buf) { - memcpy(remote->buf, buf, r); - } - // insert shadowsocks header if (!remote->direct) { - if (!remote->send_ctx->connected) - { - char *tmp = malloc(max(BUF_SIZE, r + server->addr_len)); - - memcpy(tmp, server->addr_to_send, server->addr_len); - memcpy(tmp + server->addr_len, remote->buf, r); - r += server->addr_len; - - // deallocate - free(remote->buf); - remote->buf = tmp; - } - remote->buf = ss_encrypt(BUF_SIZE, remote->buf, &r, server->e_ctx); if (remote->buf == NULL) @@ -342,7 +324,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) } // all processed - r = 0; + return; } else if (server->stage == 0) { @@ -352,8 +334,6 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) char *send_buf = (char *)&response; send(server->fd, send_buf, sizeof(response), 0); server->stage = 1; - r -= 3; - buf += 3; return; } else if (server->stage == 1) @@ -452,12 +432,10 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) return; } - server->addr_to_send = ss_addr_to_send; - server->addr_len = addr_len; server->stage = 5; - r -= (4 + addr_len); - buf += (4 + addr_len); + r -= (3 + addr_len); + buf += (3 + addr_len); if (verbose) { @@ -486,6 +464,23 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) return; } + if (!remote->direct) + { + memcpy(remote->buf, ss_addr_to_send, addr_len); + if (r > 0) + { + memcpy(remote->buf + addr_len, buf, r); + } + r += addr_len; + } + else + { + if (r > 0) + { + memcpy(remote->buf, buf, r); + } + } + server->remote = remote; remote->server = server; } @@ -675,6 +670,14 @@ static void remote_send_cb (EV_P_ ev_io *w, int revents) ev_timer_stop(EV_A_ &remote_send_ctx->watcher); ev_timer_start(EV_A_ &remote->recv_ctx->watcher); ev_io_start(EV_A_ &remote->recv_ctx->io); + + // no need to send any data + if (remote->buf_len == 0) + { + ev_io_stop(EV_A_ &remote_send_ctx->io); + ev_io_start(EV_A_ &server->recv_ctx->io); + return; + } } else { @@ -838,10 +841,6 @@ static void free_server(struct server *server) { free(server->buf); } - if (server->addr_to_send != NULL) - { - free(server->addr_to_send); - } free(server->recv_ctx); free(server->send_ctx); free(server); diff --git a/src/local.h b/src/local.h index 11198075..f213befa 100644 --- a/src/local.h +++ b/src/local.h @@ -54,8 +54,6 @@ struct server ssize_t buf_len; ssize_t buf_idx; char *buf; // server send from, remote recv into - int addr_len; - char *addr_to_send; char stage; struct enc_ctx *e_ctx; struct enc_ctx *d_ctx;