diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 64ea5396..cc408aa3 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="17" + android:versionName="1.3.5"> diff --git a/assets/arm/ip6tables b/assets/arm/ip6tables index 154127fb..453b7824 100755 Binary files a/assets/arm/ip6tables and b/assets/arm/ip6tables differ diff --git a/assets/arm/iptables b/assets/arm/iptables index a127b4a3..fe59486c 100755 Binary files a/assets/arm/iptables and b/assets/arm/iptables differ diff --git a/assets/arm/obfsproxy b/assets/arm/obfsproxy index 88bcfe18..0deae1b4 100755 Binary files a/assets/arm/obfsproxy and b/assets/arm/obfsproxy differ diff --git a/assets/arm/pdnsd b/assets/arm/pdnsd index 6eab9734..5ff36b2e 100755 Binary files a/assets/arm/pdnsd and b/assets/arm/pdnsd differ diff --git a/assets/arm/polipo b/assets/arm/polipo index 9c473340..aeb92e52 100755 Binary files a/assets/arm/polipo and b/assets/arm/polipo differ diff --git a/assets/arm/redsocks b/assets/arm/redsocks index 7aee5c7f..00428179 100755 Binary files a/assets/arm/redsocks and b/assets/arm/redsocks differ diff --git a/assets/arm/shadowsocks b/assets/arm/shadowsocks index f9f6da3f..1b39f135 100755 Binary files a/assets/arm/shadowsocks and b/assets/arm/shadowsocks differ diff --git a/assets/x86/ip6tables b/assets/x86/ip6tables index 30368191..622badd0 100755 Binary files a/assets/x86/ip6tables and b/assets/x86/ip6tables differ diff --git a/assets/x86/iptables b/assets/x86/iptables index 03267385..2fec82c4 100755 Binary files a/assets/x86/iptables and b/assets/x86/iptables differ diff --git a/assets/x86/obfsproxy b/assets/x86/obfsproxy index 55465f45..c0551538 100755 Binary files a/assets/x86/obfsproxy and b/assets/x86/obfsproxy differ diff --git a/assets/x86/pdnsd b/assets/x86/pdnsd index 68aac107..c2b1ad09 100755 Binary files a/assets/x86/pdnsd and b/assets/x86/pdnsd differ diff --git a/assets/x86/polipo b/assets/x86/polipo index 0d85572f..4fdf0410 100755 Binary files a/assets/x86/polipo and b/assets/x86/polipo differ diff --git a/assets/x86/redsocks b/assets/x86/redsocks index 2135c75c..99f2a51b 100755 Binary files a/assets/x86/redsocks and b/assets/x86/redsocks differ diff --git a/assets/x86/shadowsocks b/assets/x86/shadowsocks index 6da8431b..a2e14756 100755 Binary files a/assets/x86/shadowsocks and b/assets/x86/shadowsocks differ diff --git a/build-ndk.sh b/build-ndk.sh new file mode 100755 index 00000000..cbf2dbad --- /dev/null +++ b/build-ndk.sh @@ -0,0 +1,7 @@ +#!/bin/bash +ndk-build +for app in ip6tables iptables obfsproxy pdnsd polipo redsocks shadowsocks +do + cp libs/armeabi/$app assets/arm/ + cp libs/x86/$app assets/x86/ +done diff --git a/jni/shadowsocks/local.c b/jni/shadowsocks/local.c index 2bda00f2..472e995b 100644 --- a/jni/shadowsocks/local.c +++ b/jni/shadowsocks/local.c @@ -29,14 +29,14 @@ static char *_server; static char *_remote_port; static int _timeout; -static int setnonblocking(int fd) { +int setnonblocking(int fd) { int flags; if (-1 ==(flags = fcntl(fd, F_GETFL, 0))) flags = 0; return fcntl(fd, F_SETFL, flags | O_NONBLOCK); } -static int create_and_bind(const char *port) { +int create_and_bind(const char *port) { struct addrinfo hints; struct addrinfo *result, *rp; int s, listen_sock; @@ -83,7 +83,7 @@ static int create_and_bind(const char *port) { return listen_sock; } -static void server_recv_cb (EV_P_ ev_io *w, int revents) { +void server_recv_cb (EV_P_ ev_io *w, int revents) { struct server_ctx *server_recv_ctx = (struct server_ctx *)w; struct server *server = server_recv_ctx->server; struct remote *remote = server->remote; @@ -237,7 +237,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) { } } -static void server_send_cb (EV_P_ ev_io *w, int revents) { +void server_send_cb (EV_P_ ev_io *w, int revents) { struct server_ctx *server_send_ctx = (struct server_ctx *)w; struct server *server = server_send_ctx->server; struct remote *remote = server->remote; @@ -284,7 +284,7 @@ static void server_send_cb (EV_P_ ev_io *w, int revents) { } -static void remote_timeout_cb(EV_P_ ev_timer *watcher, int revents) { +void remote_timeout_cb(EV_P_ ev_timer *watcher, int revents) { struct remote_ctx *remote_ctx = (struct remote_ctx *) (((void*)watcher) - sizeof(ev_io)); struct remote *remote = remote_ctx->remote; @@ -302,7 +302,7 @@ static void remote_timeout_cb(EV_P_ ev_timer *watcher, int revents) { close_and_free_server(EV_A_ server); } -static void remote_recv_cb (EV_P_ ev_io *w, int revents) { +void remote_recv_cb (EV_P_ ev_io *w, int revents) { struct remote_ctx *remote_recv_ctx = (struct remote_ctx *)w; struct remote *remote = remote_recv_ctx->remote; struct server *server = remote->server; @@ -362,7 +362,7 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents) { } } -static void remote_send_cb (EV_P_ ev_io *w, int revents) { +void remote_send_cb (EV_P_ ev_io *w, int revents) { struct remote_ctx *remote_send_ctx = (struct remote_ctx *)w; struct remote *remote = remote_send_ctx->remote; struct server *server = remote->server; @@ -520,60 +520,55 @@ void close_and_free_server(EV_P_ struct server *server) { } } -static void accept_cb (EV_P_ ev_io *w, int revents) -{ +void accept_cb (EV_P_ ev_io *w, int revents) { struct listen_ctx *listener = (struct listen_ctx *)w; int serverfd; - while (1) { - serverfd = accept(listener->fd, NULL, NULL); - if (serverfd < 0) { - perror("accept"); - break; - } - setnonblocking(serverfd); - struct server *server = new_server(serverfd); - struct addrinfo hints, *res; - int sockfd; - memset(&hints, 0, sizeof hints); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - int err = getaddrinfo(_server, _remote_port, &hints, &res); - if (err) { - perror("getaddrinfo"); - close_and_free_server(EV_A_ server); - break; - } - - sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); - if (sockfd < 0) { - perror("socket"); - close(sockfd); - close_and_free_server(EV_A_ server); - freeaddrinfo(res); - break; - } - - struct timeval timeout; - timeout.tv_sec = _timeout; - timeout.tv_usec = 0; - err = setsockopt(sockfd, SOL_SOCKET, - SO_RCVTIMEO, (char *)&timeout, sizeof(timeout)); - if (err) perror("setsockopt"); - err = setsockopt(sockfd, SOL_SOCKET, - SO_SNDTIMEO, (char *)&timeout, sizeof(timeout)); - if (err) perror("setsockopt"); - - setnonblocking(sockfd); - struct remote *remote = new_remote(sockfd); - server->remote = remote; - remote->server = server; - connect(sockfd, res->ai_addr, res->ai_addrlen); - freeaddrinfo(res); - // listen to remote connected event - ev_io_start(EV_A_ &remote->send_ctx->io); - ev_timer_start(EV_A_ &remote->send_ctx->watcher); - break; + serverfd = accept(listener->fd, NULL, NULL); + if (serverfd < 0) { + perror("accept"); + return; } + setnonblocking(serverfd); + + struct addrinfo hints, *res; + int sockfd; + memset(&hints, 0, sizeof hints); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + int err = getaddrinfo(_server, _remote_port, &hints, &res); + if (err) { + perror("getaddrinfo"); + return; + } + + sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol); + if (sockfd < 0) { + perror("socket"); + close(sockfd); + freeaddrinfo(res); + return; + } + + struct timeval timeout; + timeout.tv_sec = _timeout; + timeout.tv_usec = 0; + err = setsockopt(sockfd, SOL_SOCKET, + SO_RCVTIMEO, (char *)&timeout, sizeof(timeout)); + if (err) perror("setsockopt"); + err = setsockopt(sockfd, SOL_SOCKET, + SO_SNDTIMEO, (char *)&timeout, sizeof(timeout)); + if (err) perror("setsockopt"); + + setnonblocking(sockfd); + struct server *server = new_server(serverfd); + struct remote *remote = new_remote(sockfd); + server->remote = remote; + remote->server = server; + connect(sockfd, res->ai_addr, res->ai_addrlen); + freeaddrinfo(res); + // listen to remote connected event + ev_io_start(EV_A_ &remote->send_ctx->io); + ev_timer_start(EV_A_ &remote->send_ctx->watcher); } static void print_usage() { diff --git a/libs/armeabi/libexec.so b/libs/armeabi/libexec.so index fe3c9fb3..2ab07b41 100755 Binary files a/libs/armeabi/libexec.so and b/libs/armeabi/libexec.so differ diff --git a/libs/armeabi/libsystem.so b/libs/armeabi/libsystem.so index 4ab8fd1a..b1a8c27d 100755 Binary files a/libs/armeabi/libsystem.so and b/libs/armeabi/libsystem.so differ diff --git a/libs/x86/libexec.so b/libs/x86/libexec.so index 1fc0b2d3..426904dd 100755 Binary files a/libs/x86/libexec.so and b/libs/x86/libexec.so differ diff --git a/libs/x86/libsystem.so b/libs/x86/libsystem.so index 4a47875e..5fbb1986 100755 Binary files a/libs/x86/libsystem.so and b/libs/x86/libsystem.so differ diff --git a/pom.xml b/pom.xml index dc5656f9..7d638554 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.shadowsocks shadowsocks - 1.3.4 + 1.3.5 apk Shadowsocks