Browse Source

Add prefix option for Android

pull/542/head
Max Lv 8 years ago
parent
commit
dbe1e01074
3 changed files with 16 additions and 4 deletions
  1. 8
      src/android.c
  2. 6
      src/local.c
  3. 6
      src/tunnel.c

8
src/android.c

@ -45,6 +45,8 @@
#include "netutils.h"
#include "utils.h"
extern char *prefix;
int protect_socket(int fd)
{
int sock;
@ -62,7 +64,8 @@ int protect_socket(int fd)
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval));
setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(struct timeval));
const char path[] = "/data/data/com.github.shadowsocks/protect_path";
char path[256];
sprintf(path, "%s/protect_path", prefix);
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
@ -109,7 +112,8 @@ int send_traffic_stat(uint64_t tx, uint64_t rx)
setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval));
setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(struct timeval));
const char path[] = "/data/data/com.github.shadowsocks/stat_path";
char path[256];
sprintf(path, "%s/protect_path", prefix);
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;

6
src/local.c

@ -85,6 +85,7 @@ int vpn = 0;
uint64_t tx = 0;
uint64_t rx = 0;
ev_tstamp last = 0;
char *prefix;
#endif
static int acl = 0;
@ -994,7 +995,7 @@ int main(int argc, char **argv)
USE_TTY();
#ifdef ANDROID
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:a:n:uvVA",
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:a:n:uvVAP",
long_options, &option_index)) != -1) {
#else
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:a:n:uvA",
@ -1064,6 +1065,9 @@ int main(int argc, char **argv)
case 'V':
vpn = 1;
break;
case 'P':
prefix = optarg;
break;
#endif
}
}

6
src/tunnel.c

@ -87,6 +87,7 @@ static void close_and_free_server(EV_P_ server_t *server);
#ifdef ANDROID
int vpn = 0;
char *prefix;
#endif
int verbose = 0;
@ -700,7 +701,7 @@ int main(int argc, char **argv)
USE_TTY();
#ifdef ANDROID
while ((c = getopt(argc, argv, "f:s:p:l:k:t:m:i:c:b:L:a:n:uUvVA")) != -1) {
while ((c = getopt(argc, argv, "f:s:p:l:k:t:m:i:c:b:L:a:n:uUvVAP")) != -1) {
#else
while ((c = getopt(argc, argv, "f:s:p:l:k:t:m:i:c:b:L:a:n:uUvA")) != -1) {
#endif
@ -766,6 +767,9 @@ int main(int argc, char **argv)
case 'V':
vpn = 1;
break;
case 'P':
prefix = optarg;
break;
#endif
}
}

Loading…
Cancel
Save