Browse Source

Merge pull request #140 from madeye/v1.5.1

Fix a bug introduced by fast open.
pull/145/head v1.5.1
Max Lv 10 years ago
parent
commit
aeb6fcef04
7 changed files with 48 additions and 45 deletions
  1. 2
      README.md
  2. 20
      configure
  3. 2
      configure.ac
  4. 6
      debian/changelog
  5. 2
      openwrt/Makefile
  6. 59
      src/local.c
  7. 2
      src/local.h

2
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
--------

20
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 <max.c.lv@gmail.com>.
#
@ -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\\"

2
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)

6
debian/changelog

@ -1,3 +1,9 @@
shadowsocks (1.5.1-1) unstable; urgency=low
* Fix a bug of tcp fast open.
-- Max Lv <max.c.lv@gmail.com> Sat, 08 Nov 2014 19:45:37 +0900
shadowsocks (1.5.0-1) unstable; urgency=low
* Support to build static or shared library.

2
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

59
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);

2
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;

Loading…
Cancel
Save