Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fully support UDP #20

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion android/java/org/uproxy/tun2socks/Tun2SocksJni.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ public static native int runTun2Socks(
int vpnInterfaceMTU,
String vpnIpAddress,
String vpnNetMask,
String vpnIpV6Address,
String socksServerAddress,
String udpRelayAddress,
String dnsResolverAddress,
int transparentDNS);
int transparentDNS,
int socks5UDP);

public static native int terminateTun2Socks();

Expand Down
13 changes: 10 additions & 3 deletions android/java/org/uproxy/tun2socks/Tunnel.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public synchronized void stop() {
//----------------------------------------------------------------------------

private static final String VPN_INTERFACE_NETMASK = "255.255.255.0";
private static final String VPN_IPV6_NULL = null; // No IPv6 support.
private static final int VPN_INTERFACE_MTU = 1500;
private static final String DNS_RESOLVER_IP = "8.8.8.8";
private static final int DNS_RESOLVER_PORT = 53;
Expand Down Expand Up @@ -199,10 +200,12 @@ private boolean routeThroughTunnel(String socksServerAddress) {
VPN_INTERFACE_MTU,
mPrivateAddress.mRouter,
VPN_INTERFACE_NETMASK,
VPN_IPV6_NULL,
socksServerAddress,
socksServerAddress, // The UDP relay has the same address and port as the SOCKS server.
String.format("%s:%d", DNS_RESOLVER_IP, DNS_RESOLVER_PORT),
true /* transparent DNS */);
true /* transparent DNS */,
true /* socks5 UDP Enabled */);

mHostService.onTunnelConnected();
mHostService.onDiagnosticMessage("routing through tunnel");
Expand Down Expand Up @@ -245,10 +248,12 @@ private void startTun2Socks(
final int vpnInterfaceMTU,
final String vpnIpAddress,
final String vpnNetMask,
final String vpnIpV6Address,
final String socksServerAddress,
final String udpRelayAddress,
final String dnsResolverAddress,
final boolean transparentDns) {
final boolean transparentDns,
final boolean socks5UdpEnabled) {
if (mTun2SocksThread != null) {
return;
}
Expand All @@ -262,10 +267,12 @@ public void run() {
vpnInterfaceMTU,
vpnIpAddress,
vpnNetMask,
vpnIpV6Address,
socksServerAddress,
udpRelayAddress,
dnsResolverAddress,
transparentDns ? 1 : 0);
transparentDns ? 1 : 0,
socks5UdpEnabled ? 1 : 0);
}
});
mTun2SocksThread.start();
Expand Down
9 changes: 9 additions & 0 deletions android/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ LOCAL_CFLAGS += -DBADVPN_USE_SELFPIPE -DBADVPN_USE_EPOLL
LOCAL_CFLAGS += -DBADVPN_LITTLE_ENDIAN
LOCAL_CFLAGS += -DPSIPHON

ifeq ($(NDK_DEBUG),1)
LOCAL_CFLAGS += -g -O0 -fno-omit-frame-pointer
LOCAL_SANITIZE := address
LOCAL_MODULE_RELATIVE_PATH := asan
cmd-strip :=
endif

LOCAL_C_INCLUDES:= \
$(LOCAL_PATH) \
$(LOCAL_PATH)/lwip/src/include/ipv4 \
Expand All @@ -19,6 +26,7 @@ LOCAL_C_INCLUDES:= \

LOCAL_SRC_FILES := \
base/BLog_syslog.c \
system/BDatagram_unix.c \
system/BReactor_badvpn.c \
system/BSignal.c \
system/BConnection_unix.c \
Expand Down Expand Up @@ -70,6 +78,7 @@ LOCAL_SRC_FILES := \
flowextra/PacketPassInactivityMonitor.c \
tun2socks/SocksUdpGwClient.c \
udpgw_client/UdpGwClient.c \
socks_udp_client/SocksUdpClient.c \
stringmap/BStringMap.c

include $(BUILD_SHARED_LIBRARY)
Expand Down
2 changes: 1 addition & 1 deletion android/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
APP_ABI := armeabi-v7a
APP_ABI := armeabi-v7a arm64-v8a
APP_PLATFORM := android-23
2 changes: 2 additions & 0 deletions android/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,10 @@ if (BUILD_NCD AND NOT EMSCRIPTEN)
endif ()
if (BUILD_TUN2SOCKS)
add_subdirectory(socksclient)
add_subdirectory(socks_udp_client)
add_subdirectory(udpgw_client)
add_subdirectory(lwip)
add_subdirectory(stringmap)
endif ()
if (BUILD_TUNCTL)
add_subdirectory(tunctl)
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions android/jni/blog_channels.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ NCDRfkillMonitor 4
udpgw 4
UdpGwClient 4
SocksUdpGwClient 4
SocksUdpClient 4
BNetwork 4
BConnection 4
BSSLConnection 4
Expand Down
4 changes: 4 additions & 0 deletions android/jni/generated/blog_channel_SocksUdpClient.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifdef BLOG_CURRENT_CHANNEL
#undef BLOG_CURRENT_CHANNEL
#endif
#define BLOG_CURRENT_CHANNEL BLOG_CHANNEL_SocksUdpClient
3 changes: 2 additions & 1 deletion android/jni/generated/blog_channels_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,5 @@
#define BLOG_CHANNEL_BThreadSignal 142
#define BLOG_CHANNEL_BLockReactor 143
#define BLOG_CHANNEL_ncd_load_module 144
#define BLOG_NUM_CHANNELS 145
#define BLOG_CHANNEL_SocksUdpClient 145
#define BLOG_NUM_CHANNELS 146
1 change: 1 addition & 0 deletions android/jni/generated/blog_channels_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,4 @@
{"BThreadSignal", 4},
{"BLockReactor", 4},
{"ncd_load_module", 4},
{"SocksUdpClient", 4},
Loading