UWNetworksLab / cordova-plugin-tun2socks

Cordova plugin to enable a system-wide VPN for Android devices.
Apache License 2.0
51 stars 24 forks source link

fully support UDP #20

Open Xmader opened 4 years ago

Xmader commented 4 years ago

merge code from Outline

iMrDJAi commented 3 years ago

Is that for UDP associate? actually it won't work.
I been testing it, the UDP associate will only work if you disable the UDP relay and the transparent DNS (See this comment by @bemasc https://github.com/ambrop72/badvpn/pull/71#issue-238833938): https://github.com/UWNetworksLab/cordova-plugin-tun2socks/blob/ab12b21ad3140efc08e7cd4d378a614e05704a79/android/java/org/uproxy/tun2socks/Tunnel.java#L205 https://github.com/UWNetworksLab/cordova-plugin-tun2socks/blob/ab12b21ad3140efc08e7cd4d378a614e05704a79/android/java/org/uproxy/tun2socks/Tunnel.java#L207 Just like that:

    startTun2Socks(
        tunFd,
        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.
+       null,
        String.format("%s:%d", DNS_RESOLVER_IP, DNS_RESOLVER_PORT),
-       true /* transparent DNS */,
+       false,
        true /* socks5 UDP Enabled */);
iMrDJAi commented 3 years ago

I have published a working version that supports SOCKS v5 UDP associate based on your implementation:
https://github.com/iMrDJAi/cordova-plugin-tun2socks-udp-associate

Thank you!