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
c486fd75
Commit
c486fd75
authored
Jun 05, 2013
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update tun2socks
parent
b3e3cb07
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
68 deletions
+70
-68
src/main/assets/arm/shadowsocks
src/main/assets/arm/shadowsocks
+0
-0
src/main/assets/arm/tun2socks
src/main/assets/arm/tun2socks
+0
-0
src/main/assets/pdnsd.conf
src/main/assets/pdnsd.conf
+2
-2
src/main/assets/x86/shadowsocks
src/main/assets/x86/shadowsocks
+0
-0
src/main/assets/x86/tun2socks
src/main/assets/x86/tun2socks
+0
-0
src/main/jni/badvpn/tun2socks/tun2socks.c
src/main/jni/badvpn/tun2socks/tun2socks.c
+18
-17
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
+50
-49
No files found.
src/main/assets/arm/shadowsocks
View file @
c486fd75
No preview for this file type
src/main/assets/arm/tun2socks
View file @
c486fd75
No preview for this file type
src/main/assets/pdnsd.conf
View file @
c486fd75
global
{
global
{
perm_cache
=
2048
;
perm_cache
=
2048
;
cache_dir
=
"/data/data/com.github.shadowsocks"
;
cache_dir
=
"/data/data/com.github.shadowsocks"
;
server_ip
=
127
.
0
.
0
.
1
;
server_ip
=
0
.
0
.
0
.
0
;
server_port
=
8153
;
server_port
=
8153
;
query_method
=
tcp_only
;
query_method
=
tcp_only
;
run_ipv4
=
on
;
run_ipv4
=
on
;
...
...
src/main/assets/x86/shadowsocks
View file @
c486fd75
No preview for this file type
src/main/assets/x86/tun2socks
View file @
c486fd75
No preview for this file type
src/main/jni/badvpn/tun2socks/tun2socks.c
View file @
c486fd75
...
@@ -209,8 +209,8 @@ LinkedList1 tcp_clients;
...
@@ -209,8 +209,8 @@ LinkedList1 tcp_clients;
int
num_clients
;
int
num_clients
;
#ifdef ANDROID
#ifdef ANDROID
//
IP a
ddress of dnsgw
//
A
ddress of dnsgw
B
IP
Addr
dnsgw
;
BAddr
dnsgw
;
#endif
#endif
static
void
terminate
(
void
);
static
void
terminate
(
void
);
...
@@ -897,20 +897,6 @@ int process_arguments (void)
...
@@ -897,20 +897,6 @@ int process_arguments (void)
{
{
ASSERT
(
!
password_file_contents
)
ASSERT
(
!
password_file_contents
)
#ifdef ANDROID
// resolve dnsgw ipaddr
if
(
options
.
dnsgw
)
{
if
(
!
BIPAddr_Resolve
(
&
dnsgw
,
options
.
dnsgw
,
0
))
{
BLog
(
BLOG_ERROR
,
"dnsgw ipaddr: BIPAddr_Resolve failed"
);
return
0
;
}
if
(
dnsgw
.
type
!=
BADDR_TYPE_IPV4
)
{
BLog
(
BLOG_ERROR
,
"dnsgw ipaddr: must be an IPv4 address"
);
return
0
;
}
}
#endif
// resolve netif ipaddr
// resolve netif ipaddr
if
(
!
BIPAddr_Resolve
(
&
netif_ipaddr
,
options
.
netif_ipaddr
,
0
))
{
if
(
!
BIPAddr_Resolve
(
&
netif_ipaddr
,
options
.
netif_ipaddr
,
0
))
{
BLog
(
BLOG_ERROR
,
"netif ipaddr: BIPAddr_Resolve failed"
);
BLog
(
BLOG_ERROR
,
"netif ipaddr: BIPAddr_Resolve failed"
);
...
@@ -978,6 +964,20 @@ int process_arguments (void)
...
@@ -978,6 +964,20 @@ int process_arguments (void)
}
}
}
}
#ifdef ANDROID
// resolve dnsgw ipaddr
if
(
options
.
dnsgw
)
{
if
(
!
BAddr_Parse2
(
&
dnsgw
,
options
.
dnsgw
,
NULL
,
0
,
0
))
{
BLog
(
BLOG_ERROR
,
"dnsgw addr: BAddr_Parse2 failed"
);
return
0
;
}
if
(
dnsgw
.
type
!=
BADDR_TYPE_IPV4
)
{
BLog
(
BLOG_ERROR
,
"dnsgw addr: must be an IPv4 address"
);
return
0
;
}
}
#endif
return
1
;
return
1
;
}
}
...
@@ -1227,11 +1227,12 @@ int process_device_dns_packet (uint8_t *data, int data_len)
...
@@ -1227,11 +1227,12 @@ int process_device_dns_packet (uint8_t *data, int data_len)
}
}
// build IP header
// build IP header
ipv4_header
.
destination_address
=
dnsgw
.
ipv4
;
ipv4_header
.
destination_address
=
dnsgw
.
ipv4
.
ip
;
ipv4_header
.
checksum
=
hton16
(
0
);
ipv4_header
.
checksum
=
hton16
(
0
);
ipv4_header
.
checksum
=
ipv4_checksum
(
&
ipv4_header
,
NULL
,
0
);
ipv4_header
.
checksum
=
ipv4_checksum
(
&
ipv4_header
,
NULL
,
0
);
// build UDP header
// build UDP header
udp_header
.
dest_port
=
hton16
(
dnsgw
.
ipv4
.
port
);
udp_header
.
checksum
=
hton16
(
0
);
udp_header
.
checksum
=
hton16
(
0
);
udp_header
.
checksum
=
udp_checksum
(
&
udp_header
,
data
,
data_len
,
udp_header
.
checksum
=
udp_checksum
(
&
udp_header
,
data
,
data_len
,
ipv4_header
.
source_address
,
ipv4_header
.
destination_address
);
ipv4_header
.
source_address
,
ipv4_header
.
destination_address
);
...
...
src/main/scala/com/github/shadowsocks/ShadowVpnService.scala
View file @
c486fd75
...
@@ -50,6 +50,7 @@ import android.net.VpnService
...
@@ -50,6 +50,7 @@ import android.net.VpnService
import
org.apache.http.conn.util.InetAddressUtils
import
org.apache.http.conn.util.InetAddressUtils
import
android.os.Message
import
android.os.Message
import
scala.Some
import
scala.Some
import
scala.concurrent.ops._
object
ShadowVpnService
{
object
ShadowVpnService
{
def
isServiceStarted
(
context
:
Context
)
:
Boolean
=
{
def
isServiceStarted
(
context
:
Context
)
:
Boolean
=
{
...
@@ -136,18 +137,20 @@ class ShadowVpnService extends VpnService {
...
@@ -136,18 +137,20 @@ class ShadowVpnService extends VpnService {
}
}
def
startShadowsocksDaemon
()
{
def
startShadowsocksDaemon
()
{
new
Thread
{
spawn
{
override
def
run
()
{
val
cmd
:
String
=
(
BASE
+
val
cmd
:
String
=
(
BASE
+
"shadowsocks -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" -m \"%s\" -f "
+
"shadowsocks -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" -m \"%s\" -f "
+
BASE
+
BASE
+
"shadowsocks.pid"
)
"shadowsocks.pid"
)
.
format
(
config
.
proxy
,
config
.
remotePort
,
config
.
localPort
,
config
.
sitekey
,
.
format
(
config
.
proxy
,
config
.
remotePort
,
config
.
localPort
,
config
.
sitekey
,
config
.
encMethod
)
config
.
encMethod
)
Log
.
d
(
TAG
,
cmd
)
Log
.
d
(
TAG
,
cmd
)
System
.
exec
(
cmd
)
System
.
exec
(
cmd
)
}
}
}.
start
()
}
def
startDnsDaemon
()
{
val
cmd
:
String
=
BASE
+
"pdnsd -c "
+
BASE
+
"pdnsd.conf"
Utils
.
runCommand
(
cmd
)
}
}
def
getVersionName
:
String
=
{
def
getVersionName
:
String
=
{
...
@@ -182,9 +185,8 @@ class ShadowVpnService extends VpnService {
...
@@ -182,9 +185,8 @@ class ShadowVpnService extends VpnService {
config
=
Extra
.
get
(
intent
)
config
=
Extra
.
get
(
intent
)
new
Thread
(
new
Runnable
{
def
run
()
{
spawn
{
killProcesses
()
killProcesses
()
// Resolve server address
// Resolve server address
...
@@ -218,7 +220,6 @@ class ShadowVpnService extends VpnService {
...
@@ -218,7 +220,6 @@ class ShadowVpnService extends VpnService {
}
}
handler
.
sendEmptyMessageDelayed
(
MSG_CONNECT_FINISH
,
300
)
handler
.
sendEmptyMessageDelayed
(
MSG_CONNECT_FINISH
,
300
)
}
}
}).
start
()
}
}
def
waitForProcess
(
name
:
String
)
:
Boolean
=
{
def
waitForProcess
(
name
:
String
)
:
Boolean
=
{
...
@@ -310,19 +311,21 @@ class ShadowVpnService extends VpnService {
...
@@ -310,19 +311,21 @@ class ShadowVpnService extends VpnService {
val
cmd
=
(
BASE
+
val
cmd
=
(
BASE
+
"tun2socks --netif-ipaddr %s "
"tun2socks --netif-ipaddr %s "
+
"--udpgw-remote-server-addr %s:7300 "
// + "--udpgw-remote-server-addr %s:7300 "
+
"--dnsgw 127.0.0.1:8153 "
+
"--netif-netmask 255.255.255.0 "
+
"--netif-netmask 255.255.255.0 "
+
"--socks-server-addr 127.0.0.1:%d "
+
"--socks-server-addr 127.0.0.1:%d "
+
"--tunfd %d "
+
"--tunfd %d "
+
"--tunmtu %d "
+
"--tunmtu %d "
+
"--pid %stun2socks.pid"
)
+
"--pid %stun2socks.pid"
)
.
format
(
localAddress
.
format
(
2
),
udpgw
,
config
.
localPort
,
fd
,
VPN_MTU
,
BASE
)
.
format
(
localAddress
.
format
(
2
),
config
.
localPort
,
fd
,
VPN_MTU
,
BASE
)
Log
.
d
(
TAG
,
cmd
)
Log
.
d
(
TAG
,
cmd
)
System
.
exec
(
cmd
)
System
.
exec
(
cmd
)
}
}
/** Called when the activity is first created. */
/** Called when the activity is first created. */
def
handleConnection
:
Boolean
=
{
def
handleConnection
:
Boolean
=
{
startDnsDaemon
()
startShadowsocksDaemon
()
startShadowsocksDaemon
()
startVpn
()
startVpn
()
true
true
...
@@ -384,11 +387,9 @@ class ShadowVpnService extends VpnService {
...
@@ -384,11 +387,9 @@ class ShadowVpnService extends VpnService {
unregisterReceiver
(
receiver
)
unregisterReceiver
(
receiver
)
receiver
=
null
receiver
=
null
}
}
new
Thread
{
spawn
{
override
def
run
()
{
killProcesses
()
killProcesses
()
}
}
}.
start
()
if
(
conn
!=
null
)
{
if
(
conn
!=
null
)
{
conn
.
close
()
conn
.
close
()
conn
=
null
conn
=
null
...
...
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