From 680007589c5aaafede801081e46b013b27c93939 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Fri, 24 Jul 2015 18:55:19 +0800 Subject: [PATCH] fix a build issue --- src/android.c | 12 +++++------- src/udprelay.c | 13 ++++++++----- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/android.c b/src/android.c index 639774dc..3283711b 100644 --- a/src/android.c +++ b/src/android.c @@ -190,21 +190,19 @@ int protect_socket(void (*protect_cb)(int ret, void *data), void *data, int fd) // Setup setnonblocking(remotefd); + const char path[] = "/data/data/com.github.shadowsocks/protect_path"; + memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; - strncpy(addr.sun_path, "/data/data/com.github.shadowsocks/protect_path", sizeof(addr.sun_path)-1); + strncpy(addr.sun_path, path, sizeof(addr.sun_path)-1); - struct remote *remote = new_remote(remotefd, 100); + struct remote *remote = new_remote(remotefd, 1); remote->protect_fd = fd; remote->protect_cb = protect_cb; remote->data = data; - if (connect(remotefd, (struct sockaddr*)&addr, sizeof(addr)) == -1) { - LOGE("[android] connect() failed: %s (fd = %d)\n", strerror(errno), remotefd); - close(remotefd); - return -1; - } + connect(remotefd, (struct sockaddr*)&addr, sizeof(addr)); // listen to remote connected event ev_io_start(EV_A_ & remote->send_ctx->io); diff --git a/src/udprelay.c b/src/udprelay.c index 15685d1e..7161fd37 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -86,7 +86,10 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents); static void remote_recv_cb(EV_P_ ev_io *w, int revents); static void remote_timeout_cb(EV_P_ ev_timer *watcher, int revents); + +#if defined(ANDROID) && !defined(UDPRELAY_TUNNEL) static void protect_cb(int ret, void *data); +#endif static char *hash_key(const int af, const struct sockaddr_storage *addr); #ifdef UDPRELAY_REMOTE @@ -100,9 +103,9 @@ extern int verbose; static int server_num = 0; static struct server_ctx *server_ctx_list[MAX_REMOTE_NUM] = { NULL }; -#ifdef ANDROID +#if defined(ANDROID) && !defined(UDPRELAY_TUNNEL) static struct protect_ctx *new_protect_ctx(char *buf, int buf_len, - struct sockaddr *addr, int addr_len) { + const struct sockaddr *addr, int addr_len) { struct protect_ctx *protect_ctx = (struct protect_ctx *)malloc(sizeof(struct protect_ctx)); memset(protect_ctx, 0, sizeof(struct protect_ctx)); @@ -127,7 +130,7 @@ static void protect_cb(int ret, void *data) { struct protect_ctx *protect_ctx = (struct protect_ctx*)data; if (ret != -1) { int s = sendto(protect_ctx->remote_ctx->fd, protect_ctx->buf, - protect_ctx->buf_len, 0, &protect_ctx->addr, protect_ctx->addr_len); + protect_ctx->buf_len, 0, (const struct sockaddr *)&protect_ctx->addr, protect_ctx->addr_len); if (s == -1) { ERROR("[udp] sendto_remote"); } @@ -1096,8 +1099,8 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents) buf = ss_encrypt_all(BUF_SIZE, buf, &buf_len, server_ctx->method); -#ifdef ANDROID - struct protect_ctx *protect_ctx = new_protect_ctx(buf, buf_len, &remote_addr, remote_addr_len); +#if defined(ANDROID) && !defined(UDPRELAY_TUNNEL) + struct protect_ctx *protect_ctx = new_protect_ctx(buf, buf_len, remote_addr, remote_addr_len); protect_ctx->remote_ctx = remote_ctx; protect_socket(protect_cb, (void*)protect_ctx, remote_ctx->fd); #else