Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
71203f71
Commit
71203f71
authored
Mar 19, 2014
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
udprelay works now!
parent
90b75009
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
27 deletions
+19
-27
src/main/jni/Android.mk
src/main/jni/Android.mk
+1
-0
src/main/jni/badvpn/protocol/udpgw_proto.h
src/main/jni/badvpn/protocol/udpgw_proto.h
+2
-2
src/main/jni/badvpn/tun2socks/SocksUdpGwClient.c
src/main/jni/badvpn/tun2socks/SocksUdpGwClient.c
+6
-6
src/main/jni/badvpn/tun2socks/SocksUdpGwClient.h
src/main/jni/badvpn/tun2socks/SocksUdpGwClient.h
+3
-3
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+7
-16
No files found.
src/main/jni/Android.mk
View file @
71203f71
...
...
@@ -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
...
...
src/main/jni/badvpn/protocol/udpgw_proto.h
View file @
71203f71
...
...
@@ -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
)),
...
...
src/main/jni/badvpn/tun2socks/SocksUdpGwClient.c
View file @
71203f71
...
...
@@ -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
)
...
...
src/main/jni/badvpn/tun2socks/SocksUdpGwClient.h
View file @
71203f71
...
...
@@ -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
;
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
71203f71
...
...
@@ -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`"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment