Skip to content

Commit

Permalink
Merge branch 'shadowsocks-android' github.com/shadowsocks/badvpn into…
Browse files Browse the repository at this point in the history
… shadowsocks-android
  • Loading branch information
Mygod committed Nov 2, 2024
2 parents dc99ade + 40a0e50 commit 27c25ae
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions tun2socks/tun2socks.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ LinkedList1 tcp_clients;
// number of clients
int num_clients;

#ifdef __ANDROID__
// Address of dnsgw
BAddr dnsgw;
#ifdef __ANDROID__
void terminate (void);
#else
static void terminate (void);
Expand Down Expand Up @@ -420,7 +420,7 @@ int wait_for_fd()
}
fcntl(sock, F_SETFL, flags | O_NONBLOCK);

char *path = "/data/data/com.github.shadowsocks/sock_path";
char *path = "./sock_path";
if (options.sock_path != NULL) {
path = options.sock_path;
}
Expand Down Expand Up @@ -494,12 +494,6 @@ 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();
Expand Down Expand Up @@ -1448,7 +1442,7 @@ int process_device_udp_packet (uint8_t *data, int data_len)

BAddr local_addr;
BAddr remote_addr;
int is_dns;
int is_dns = 0;

uint8_t ip_version = 0;
if (data_len > 0) {
Expand Down Expand Up @@ -1488,6 +1482,7 @@ int process_device_udp_packet (uint8_t *data, int data_len)
BAddr_InitIPv4(&local_addr, ipv4_header.source_address, udp_header.source_port);
BAddr_InitIPv4(&remote_addr, ipv4_header.destination_address, udp_header.dest_port);

#ifdef __ANDROID__
// if transparent DNS is enabled, any packet arriving at out netif
// address to port 53 is considered a DNS packet
is_dns = (options.dnsgw && udp_header.dest_port == hton16(53));
Expand All @@ -1504,6 +1499,7 @@ int process_device_udp_packet (uint8_t *data, int data_len)
is_dns = (header->qr == 0 && header->rcode == 0 && header->ans_count == 0 && header->auth_count == 0);
}
}
#endif
} break;

case 6: {
Expand Down

0 comments on commit 27c25ae

Please sign in to comment.