diff --git a/src/main/jni/badvpn/tun2socks/tun2socks.c b/src/main/jni/badvpn/tun2socks/tun2socks.c index 2a9ef44f..1818630e 100644 --- a/src/main/jni/badvpn/tun2socks/tun2socks.c +++ b/src/main/jni/badvpn/tun2socks/tun2socks.c @@ -192,6 +192,7 @@ struct { #ifdef ANDROID int tun_fd; int tun_mtu; + int fake_proc; char *pid; char *dnsgw; #else @@ -391,10 +392,6 @@ int main (int argc, char **argv) return 1; } - // Fake process name to cheat on Lollipop - strcpy(argv[0], "com.github.shadowsocks"); - prctl(PR_SET_NAME, "com.github.shadowsocks"); - // open standard streams open_standard_streams(); @@ -405,6 +402,13 @@ int main (int argc, char **argv) goto fail0; } + if (options.fake_proc) { + // Fake process name to cheat on Lollipop + strcpy(argv[0], "com.github.shadowsocks"); + prctl(PR_SET_NAME, "com.github.shadowsocks"); + } + + // handle --help and --version if (options.help) { print_version(); @@ -664,6 +668,7 @@ void print_help (const char *name) " [--loglevel <0-5/none/error/warning/notice/info/debug>]\n" " [--channel-loglevel <0-5/none/error/warning/notice/info/debug>] ...\n" #ifdef ANDROID + " [--fake-proc]\n" " [--tunfd ]\n" " [--tunmtu ]\n" " [--dnsgw ]\n" @@ -718,6 +723,7 @@ int parse_arguments (int argc, char *argv[]) #ifdef ANDROID options.tun_fd = -1; options.tun_mtu = 1500; + options.fake_proc = 0; options.pid = NULL; #else options.tundev = NULL; @@ -812,6 +818,9 @@ int parse_arguments (int argc, char *argv[]) i += 2; } #ifdef ANDROID + else if (!strcmp(arg, "--fake-proc")) { + options.fake_proc = 1; + } else if (!strcmp(arg, "--tunfd")) { if (1 >= argc - i) { fprintf(stderr, "%s: requires an argument\n", arg); diff --git a/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala b/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala index 17511542..c2412aa8 100644 --- a/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala +++ b/src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala @@ -320,6 +320,10 @@ class ShadowsocksVpnService extends VpnService with BaseService { else cmd += " --dnsgw %s:8153".format(PRIVATE_VLAN.format("1")) + if (Utils.isLollipopOrAbove) { + cmd += " --fake-proc"; + } + if (BuildConfig.DEBUG) Log.d(TAG, cmd) System.exec(cmd);