udprelay works now!
This commit is contained in:
@@ -222,6 +222,7 @@ TUN2SOCKS_SOURCES := \
|
||||
base/DebugObject.c \
|
||||
base/BLog.c \
|
||||
base/BPending.c \
|
||||
system/BDatagram_unix.c \
|
||||
flowextra/PacketPassInactivityMonitor.c \
|
||||
tun2socks/SocksUdpGwClient.c \
|
||||
udpgw_client/UdpGwClient.c
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#define UDPGW_CLIENT_FLAG_DNS (1 << 2)
|
||||
#define UDPGW_CLIENT_FLAG_IPV6 (1 << 3)
|
||||
|
||||
#ifdef BADVPN_SOCKS_UDP_RELAY
|
||||
#ifdef ANDROID
|
||||
B_START_PACKED
|
||||
struct socks_udp_header {
|
||||
uint16_t rsv;
|
||||
@@ -73,7 +73,7 @@ B_END_PACKED
|
||||
static int udpgw_compute_mtu (int dgram_mtu)
|
||||
{
|
||||
bsize_t bs = bsize_add(
|
||||
#ifdef BADVPN_SOCKS_UDP_RELAY
|
||||
#ifdef ANDROID
|
||||
bsize_fromsize(sizeof(struct socks_udp_header)),
|
||||
#else
|
||||
bsize_fromsize(sizeof(struct udpgw_header)),
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#include <generated/blog_channel_SocksUdpGwClient.h>
|
||||
|
||||
#ifdef BADVPN_SOCKS_UDP_RELAY
|
||||
#ifdef ANDROID
|
||||
|
||||
#include <misc/socks_proto.h>
|
||||
#define CONNECTION_UDP_BUFFER_SIZE 1
|
||||
@@ -49,7 +49,7 @@ static void udpgw_handler_received (SocksUdpGwClient *o, BAddr local_addr, BAddr
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BADVPN_SOCKS_UDP_RELAY
|
||||
#ifdef ANDROID
|
||||
static void dgram_handler (SocksUdpGwClient_connection *o, int event);
|
||||
static void dgram_handler_received (SocksUdpGwClient_connection *o, uint8_t *data, int data_len);
|
||||
static int conaddr_comparator (void *unused, SocksUdpGwClient_conaddr *v1, SocksUdpGwClient_conaddr *v2);
|
||||
@@ -485,7 +485,7 @@ int SocksUdpGwClient_Init (SocksUdpGwClient *o, int udp_mtu, int max_connections
|
||||
{
|
||||
// see asserts in UdpGwClient_Init
|
||||
ASSERT(!BAddr_IsInvalid(&socks_server_addr))
|
||||
#ifndef BADVPN_SOCKS_UDP_RELAY
|
||||
#ifndef ANDROID
|
||||
ASSERT(remote_udpgw_addr.type == BADDR_TYPE_IPV4 || remote_udpgw_addr.type == BADDR_TYPE_IPV6)
|
||||
#endif
|
||||
|
||||
@@ -499,7 +499,7 @@ int SocksUdpGwClient_Init (SocksUdpGwClient *o, int udp_mtu, int max_connections
|
||||
o->user = user;
|
||||
o->handler_received = handler_received;
|
||||
|
||||
#ifdef BADVPN_SOCKS_UDP_RELAY
|
||||
#ifdef ANDROID
|
||||
// compute MTUs
|
||||
o->udpgw_mtu = udpgw_compute_mtu(o->udp_mtu);
|
||||
o->max_connections = max_connections;
|
||||
@@ -544,7 +544,7 @@ void SocksUdpGwClient_Free (SocksUdpGwClient *o)
|
||||
{
|
||||
DebugObject_Free(&o->d_obj);
|
||||
|
||||
#ifdef BADVPN_SOCKS_UDP_RELAY
|
||||
#ifdef ANDROID
|
||||
// free connections
|
||||
while (!LinkedList1_IsEmpty(&o->connections_list)) {
|
||||
SocksUdpGwClient_connection *con = UPPER_OBJECT(LinkedList1_GetFirst(&o->connections_list), SocksUdpGwClient_connection, connections_list_node);
|
||||
@@ -569,7 +569,7 @@ void SocksUdpGwClient_SubmitPacket (SocksUdpGwClient *o, BAddr local_addr, BAddr
|
||||
DebugObject_Access(&o->d_obj);
|
||||
// see asserts in UdpGwClient_SubmitPacket
|
||||
|
||||
#ifdef BADVPN_SOCKS_UDP_RELAY
|
||||
#ifdef ANDROID
|
||||
ASSERT(local_addr.type == BADDR_TYPE_IPV4 || local_addr.type == BADDR_TYPE_IPV6)
|
||||
ASSERT(remote_addr.type == BADDR_TYPE_IPV4 || remote_addr.type == BADDR_TYPE_IPV6)
|
||||
ASSERT(data_len >= 0)
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <misc/debug.h>
|
||||
#include <base/DebugObject.h>
|
||||
#include <system/BReactor.h>
|
||||
#ifdef BADVPN_SOCKS_UDP_RELAY
|
||||
#ifdef ANDROID
|
||||
#include <protocol/udpgw_proto.h>
|
||||
#include <protocol/packetproto.h>
|
||||
#include <system/BDatagram.h>
|
||||
@@ -58,7 +58,7 @@ typedef struct {
|
||||
BReactor *reactor;
|
||||
void *user;
|
||||
SocksUdpGwClient_handler_received handler_received;
|
||||
#ifdef BADVPN_SOCKS_UDP_RELAY
|
||||
#ifdef ANDROID
|
||||
int udpgw_mtu;
|
||||
int num_connections;
|
||||
int max_connections;
|
||||
@@ -74,7 +74,7 @@ typedef struct {
|
||||
DebugObject d_obj;
|
||||
} SocksUdpGwClient;
|
||||
|
||||
#ifdef BADVPN_SOCKS_UDP_RELAY
|
||||
#ifdef ANDROID
|
||||
typedef struct {
|
||||
BAddr local_addr;
|
||||
BAddr remote_addr;
|
||||
|
||||
@@ -77,7 +77,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
|
||||
def startShadowsocksDaemon() {
|
||||
val cmd: String = (Path.BASE +
|
||||
"ss-local -b 127.0.0.1 -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" -m \"%s\" -u -f " +
|
||||
"ss-local -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" -m \"%s\" -u -f " +
|
||||
Path.BASE + "ss-local.pid")
|
||||
.format(config.proxy, config.remotePort, config.localPort, config.sitekey, config.encMethod)
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, cmd)
|
||||
@@ -85,18 +85,11 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
}
|
||||
|
||||
def startDnsDaemon() {
|
||||
val cmd = if (config.isUdpDns) {
|
||||
(Path.BASE +
|
||||
"ss-tunnel -b 0.0.0.0 -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" -m \"%s\" -L 8.8.8.8:53 -u -f " +
|
||||
Path.BASE + "ss-tunnel.pid")
|
||||
.format(config.proxy, config.remotePort, 8153, config.sitekey, config.encMethod)
|
||||
} else {
|
||||
val conf = ConfigUtils.PDNSD.format("0.0.0.0")
|
||||
ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => {
|
||||
p.println(conf)
|
||||
})
|
||||
Path.BASE + "pdnsd -c " + Path.BASE + "pdnsd.conf"
|
||||
}
|
||||
val conf = ConfigUtils.PDNSD.format("0.0.0.0")
|
||||
ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => {
|
||||
p.println(conf)
|
||||
})
|
||||
val cmd = Path.BASE + "pdnsd -c " + Path.BASE + "pdnsd.conf"
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, cmd)
|
||||
System.exec(cmd)
|
||||
}
|
||||
@@ -192,7 +185,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
+ "--socks-server-addr 127.0.0.1:%d "
|
||||
+ "--tunfd %d "
|
||||
+ "--tunmtu %d "
|
||||
+ "--loglevel 5 "
|
||||
+ "--loglevel 3 "
|
||||
+ "--pid %stun2socks.pid")
|
||||
.format(PRIVATE_VLAN.format("2"), config.localPort, fd, VPN_MTU, Path.BASE)
|
||||
|
||||
@@ -260,8 +253,6 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
|
||||
ab.append("kill -9 `cat " + Path.BASE + "ss-local.pid`")
|
||||
ab.append("killall -9 ss-local")
|
||||
ab.append("kill -9 `cat " + Path.BASE + "ss-tunnel.pid`")
|
||||
ab.append("killall -9 ss-tunnel")
|
||||
ab.append("kill -9 `cat " + Path.BASE + "tun2socks.pid`")
|
||||
ab.append("killall -9 tun2socks")
|
||||
ab.append("kill -9 `cat " + Path.BASE + "pdnsd.pid`")
|
||||
|
||||
Reference in New Issue
Block a user