From 71873e490960d2471e70f62b847a6d5a6d968338 Mon Sep 17 00:00:00 2001 From: KernelPanic Jack Date: Sat, 28 Apr 2018 18:17:05 +0200 Subject: [PATCH] ARM toolchain statically linked binds /bin/sh, which is not present in Android, so you have to handle iptables manually as described in https://github.com/wangyu-/udp2raw-tunnel/blob/master/doc/android_guide.md By applying this patch I've been able to compile and run natively in android using termux g++ using dynamic linking, so I have -a flag working on Android --- common.cpp | 2 +- main.cpp | 4 ++-- network.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common.cpp b/common.cpp index c50d5d3..13c1906 100644 --- a/common.cpp +++ b/common.cpp @@ -306,7 +306,7 @@ void myexit(int a) printf("%s\n",RESET); if(keep_thread_running) { - if(pthread_cancel(keep_thread)) + if(pthread_kill(keep_thread,SIGUSR1)) { mylog(log_warn,"pthread_cancel failed\n"); } diff --git a/main.cpp b/main.cpp index 98c93b1..4cd9e54 100755 --- a/main.cpp +++ b/main.cpp @@ -1192,7 +1192,7 @@ int client_event_loop() local_me.sin_addr.s_addr = local_ip_uint32; - if (bind(udp_fd, (struct sockaddr*) &local_me, slen) == -1) { + if (::bind(udp_fd, (struct sockaddr*) &local_me, slen) == -1) { mylog(log_fatal,"socket bind error\n"); //perror("socket bind error"); myexit(1); @@ -1436,7 +1436,7 @@ int server_event_loop() temp_bind_addr.sin_port = htons(local_port); temp_bind_addr.sin_addr.s_addr = local_ip_uint32; - if (bind(bind_fd, (struct sockaddr*)&temp_bind_addr, sizeof(temp_bind_addr)) !=0) + if (::bind(bind_fd, (struct sockaddr*)&temp_bind_addr, sizeof(temp_bind_addr)) !=0) { mylog(log_fatal,"bind fail\n"); myexit(-1); diff --git a/network.cpp b/network.cpp index 825b596..81b28b5 100644 --- a/network.cpp +++ b/network.cpp @@ -1887,7 +1887,7 @@ int try_to_list_and_bind(int &fd,u32_t local_ip_uint32,int port) //try to bind temp_bind_addr.sin_port = htons(port); temp_bind_addr.sin_addr.s_addr = local_ip_uint32; - if (bind(fd, (struct sockaddr*)&temp_bind_addr, sizeof(temp_bind_addr)) !=0) + if (::bind(fd, (struct sockaddr*)&temp_bind_addr, sizeof(temp_bind_addr)) !=0) { mylog(log_debug,"bind fail\n"); return -1;