Browse Source

fix a build issue

pull/359/head
Max Lv 9 years ago
parent
commit
680007589c
2 changed files with 13 additions and 12 deletions
  1. 12
      src/android.c
  2. 13
      src/udprelay.c

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

13
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

Loading…
Cancel
Save