Specify stat_path on Android

This commit is contained in:
Mygod
2019-01-12 18:23:08 +08:00
parent bbc420611a
commit 7fc05dcd9d
2 changed files with 10 additions and 2 deletions
+5 -1
View File
@@ -92,9 +92,12 @@ protect_socket(int fd)
return ret;
}
extern char *stat_path;
int
send_traffic_stat(uint64_t tx, uint64_t rx)
{
if (!stat_path) return 0;
int sock;
struct sockaddr_un addr;
@@ -112,7 +115,7 @@ send_traffic_stat(uint64_t tx, uint64_t rx)
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, "stat_path", sizeof(addr.sun_path) - 1);
strncpy(addr.sun_path, stat_path, sizeof(addr.sun_path) - 1);
if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
LOGE("[android] connect() failed for stat_path: %s (socket fd = %d)\n",
@@ -130,4 +133,5 @@ send_traffic_stat(uint64_t tx, uint64_t rx)
}
close(sock);
return 0;
}
+5 -1
View File
@@ -93,6 +93,7 @@ uint64_t rx = 0;
ev_tstamp last = 0;
int is_remote_dns = 0;
char *stat_path = NULL;
#endif
static crypto_t *crypto;
@@ -1498,7 +1499,7 @@ 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:huUvV6AD",
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:a:n:S:huUvV6AD",
long_options, NULL)) != -1) {
#else
while ((c = getopt_long(argc, argv, "f:s:p:l:k:t:m:i:c:b:a:n:huUv6A",
@@ -1596,6 +1597,9 @@ main(int argc, char **argv)
ipv6first = 1;
break;
#ifdef __ANDROID__
case 'S':
stat_path = optarg;
break;
case 'D':
is_remote_dns = 1;
break;