diff --git a/src/common.h b/src/common.h index f7ab3d95..3738da3b 100644 --- a/src/common.h +++ b/src/common.h @@ -45,7 +45,7 @@ int init_udprelay(const char *server_host, const char *server_port, void free_udprelay(void); -#ifdef ANDROID +#ifdef __ANDROID__ int protect_socket(int fd); int send_traffic_stat(uint64_t tx, uint64_t rx); #endif diff --git a/src/local.c b/src/local.c index db95b149..0ae0be89 100644 --- a/src/local.c +++ b/src/local.c @@ -89,7 +89,7 @@ int verbose = 0; int reuse_port = 0; int keep_resolving = 1; -#ifdef ANDROID +#ifdef __ANDROID__ int vpn = 0; uint64_t tx = 0; uint64_t rx = 0; @@ -312,7 +312,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents) // insert shadowsocks header if (!remote->direct) { -#ifdef ANDROID +#ifdef __ANDROID__ tx += remote->buf->len; #endif int err = crypto->encrypt(remote->buf, server->e_ctx, BUF_SIZE); @@ -333,7 +333,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents) } if (!remote->send_ctx->connected) { -#ifdef ANDROID +#ifdef __ANDROID__ if (vpn) { int not_protect = 0; if (remote->addr.ss_family == AF_INET) { @@ -682,7 +682,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents) } if (acl -#ifdef ANDROID +#ifdef __ANDROID__ && !(vpn && strcmp(port, "53") == 0) #endif ) { @@ -698,7 +698,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents) else if (host_match < 0) bypass = 0; // proxy hostnames in white list else { -#ifndef ANDROID +#ifndef __ANDROID__ if (atyp == 3) { // resolve domain so we can bypass domain with geoip err = get_sockaddr(host, port, &storage, 0, ipv6first); if (err != -1) { @@ -743,7 +743,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents) else if (atyp == 4) LOGI("bypass [%s]:%s", ip, port); } -#ifndef ANDROID +#ifndef __ANDROID__ if (atyp == 3 && resolved != 1) err = get_sockaddr(host, port, &storage, 0, ipv6first); else @@ -831,7 +831,7 @@ server_send_cb(EV_P_ ev_io *w, int revents) } } -#ifdef ANDROID +#ifdef __ANDROID__ void stat_update_cb() { @@ -893,7 +893,7 @@ remote_recv_cb(EV_P_ ev_io *w, int revents) server->buf->len = r; if (!remote->direct) { -#ifdef ANDROID +#ifdef __ANDROID__ rx += server->buf->len; stat_update_cb(); #endif @@ -1295,7 +1295,7 @@ main(int argc, char **argv) USE_TTY(); -#ifdef ANDROID +#ifdef __ANDROID__ while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:a:n:huUvV6A", long_options, NULL)) != -1) { #else @@ -1389,7 +1389,7 @@ main(int argc, char **argv) case '6': ipv6first = 1; break; -#ifdef ANDROID +#ifdef __ANDROID__ case 'V': vpn = 1; break; diff --git a/src/tunnel.c b/src/tunnel.c index b40096dd..77c73802 100644 --- a/src/tunnel.c +++ b/src/tunnel.c @@ -80,7 +80,7 @@ static void close_and_free_remote(EV_P_ remote_t *remote); static void free_server(server_t *server); static void close_and_free_server(EV_P_ server_t *server); -#ifdef ANDROID +#ifdef __ANDROID__ int vpn = 0; #endif @@ -662,7 +662,7 @@ accept_cb(EV_P_ ev_io *w, int revents) return; } -#ifdef ANDROID +#ifdef __ANDROID__ if (vpn) { int not_protect = 0; if (remote_addr->sa_family == AF_INET) { @@ -803,7 +803,7 @@ main(int argc, char **argv) USE_TTY(); -#ifdef ANDROID +#ifdef __ANDROID__ while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:L:a:n:huUvV6A", long_options, NULL)) != -1) { #else @@ -893,7 +893,7 @@ main(int argc, char **argv) case '6': ipv6first = 1; break; -#ifdef ANDROID +#ifdef __ANDROID__ case 'V': vpn = 1; break; diff --git a/src/udprelay.c b/src/udprelay.c index e3470e72..9690fa10 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -85,7 +85,7 @@ static void query_resolve_cb(struct sockaddr *addr, void *data); static void close_and_free_remote(EV_P_ remote_ctx_t *ctx); static remote_ctx_t *new_remote(int fd, server_ctx_t *server_ctx); -#ifdef ANDROID +#ifdef __ANDROID__ extern uint64_t tx; extern uint64_t rx; extern int vpn; @@ -736,7 +736,7 @@ remote_recv_cb(EV_P_ ev_io *w, int revents) buf->len -= len; memmove(buf->data, buf->data + len, buf->len); #else -#ifdef ANDROID +#ifdef __ANDROID__ rx += buf->len; stat_update_cb(); #endif @@ -924,7 +924,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents) #ifdef MODULE_LOCAL #if !defined(MODULE_TUNNEL) && !defined(MODULE_REDIR) -#ifdef ANDROID +#ifdef __ANDROID__ tx += buf->len; #endif uint8_t frag = *(uint8_t *)(buf->data + 2); @@ -1150,7 +1150,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents) } #endif -#ifdef ANDROID +#ifdef __ANDROID__ if (vpn) { if (protect_socket(remotefd) == -1) { ERROR("protect_socket"); diff --git a/src/utils.h b/src/utils.h index 6ec04073..3997e9d7 100644 --- a/src/utils.h +++ b/src/utils.h @@ -46,7 +46,7 @@ #define PORTSTRLEN 16 #define SS_ADDRSTRLEN (INET6_ADDRSTRLEN + PORTSTRLEN + 1) -#ifdef ANDROID +#ifdef __ANDROID__ #include #define USE_TTY() @@ -58,7 +58,7 @@ ((void)__android_log_print(ANDROID_LOG_ERROR, "shadowsocks", \ __VA_ARGS__)) -#else // not ANDROID +#else // not __ANDROID__ #define STR(x) # x #define TOSTR(x) STR(x) @@ -159,7 +159,7 @@ extern int use_syslog; #endif // if LIB_ONLY -#endif // if ANDROID +#endif // if __ANDROID__ void ERROR(const char *s);