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
d337f0e2
Commit
d337f0e2
authored
Jan 24, 2016
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bump version
parent
713ff530
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
56 additions
and
54 deletions
+56
-54
src/main/AndroidManifest.xml
src/main/AndroidManifest.xml
+2
-2
src/main/java/com/github/shadowsocks/System.java
src/main/java/com/github/shadowsocks/System.java
+1
-1
src/main/jni/badvpn
src/main/jni/badvpn
+1
-1
src/main/jni/shadowsocks-libev
src/main/jni/shadowsocks-libev
+1
-1
src/main/jni/system.cpp
src/main/jni/system.cpp
+5
-3
src/main/res/values/strings.xml
src/main/res/values/strings.xml
+1
-1
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+10
-10
src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
...scala/com/github/shadowsocks/ShadowsocksApplication.scala
+1
-0
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
.../scala/com/github/shadowsocks/ShadowsocksNatService.scala
+16
-16
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+17
-14
src/main/scala/com/github/shadowsocks/ShadowsocksVpnThread.scala
...n/scala/com/github/shadowsocks/ShadowsocksVpnThread.scala
+1
-1
src/main/scala/com/github/shadowsocks/utils/Constants.scala
src/main/scala/com/github/shadowsocks/utils/Constants.scala
+0
-4
No files found.
src/main/AndroidManifest.xml
View file @
d337f0e2
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.github.shadowsocks"
package=
"com.github.shadowsocks"
android:versionCode=
"12
8
"
android:versionCode=
"12
9
"
android:versionName=
"2.9.
6
"
>
android:versionName=
"2.9.
7
"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
...
...
src/main/java/com/github/shadowsocks/System.java
View file @
d337f0e2
...
@@ -45,6 +45,6 @@ public class System {
...
@@ -45,6 +45,6 @@ public class System {
public
static
native
int
exec
(
String
cmd
);
public
static
native
int
exec
(
String
cmd
);
public
static
native
String
getABI
();
public
static
native
String
getABI
();
public
static
native
int
sendfd
(
int
fd
);
public
static
native
int
sendfd
(
int
fd
,
String
path
);
public
static
native
void
jniclose
(
int
fd
);
public
static
native
void
jniclose
(
int
fd
);
}
}
badvpn
@
057ed9f3
Subproject commit
f9a6a40758bb769e986e5dc0cbe452c4b0d53d1e
Subproject commit
057ed9f36490a9dccd5e7337fabcb142dd3afc0d
shadowsocks-libev
@
0d64f11f
Subproject commit
68eaf3b12d385381130c046547163b81e1807ba4
Subproject commit
0d64f11f47366a23397c96447ae1e22ead1781bb
src/main/jni/system.cpp
View file @
d337f0e2
...
@@ -64,9 +64,10 @@ void Java_com_github_shadowsocks_system_jniclose(JNIEnv *env, jobject thiz, jint
...
@@ -64,9 +64,10 @@ void Java_com_github_shadowsocks_system_jniclose(JNIEnv *env, jobject thiz, jint
close
(
fd
);
close
(
fd
);
}
}
jint
Java_com_github_shadowsocks_system_sendfd
(
JNIEnv
*
env
,
jobject
thiz
,
jint
tun_fd
)
{
jint
Java_com_github_shadowsocks_system_sendfd
(
JNIEnv
*
env
,
jobject
thiz
,
jint
tun_fd
,
jstring
path
)
{
int
fd
;
int
fd
;
struct
sockaddr_un
addr
;
struct
sockaddr_un
addr
;
const
char
*
sock_str
=
env
->
GetStringUTFChars
(
path
,
0
);
if
(
(
fd
=
socket
(
AF_UNIX
,
SOCK_STREAM
,
0
))
==
-
1
)
{
if
(
(
fd
=
socket
(
AF_UNIX
,
SOCK_STREAM
,
0
))
==
-
1
)
{
LOGE
(
"socket() failed: %s (socket fd = %d)
\n
"
,
strerror
(
errno
),
fd
);
LOGE
(
"socket() failed: %s (socket fd = %d)
\n
"
,
strerror
(
errno
),
fd
);
...
@@ -75,7 +76,7 @@ jint Java_com_github_shadowsocks_system_sendfd(JNIEnv *env, jobject thiz, jint t
...
@@ -75,7 +76,7 @@ jint Java_com_github_shadowsocks_system_sendfd(JNIEnv *env, jobject thiz, jint t
memset
(
&
addr
,
0
,
sizeof
(
addr
));
memset
(
&
addr
,
0
,
sizeof
(
addr
));
addr
.
sun_family
=
AF_UNIX
;
addr
.
sun_family
=
AF_UNIX
;
strncpy
(
addr
.
sun_path
,
"/data/data/com.github.shadowsocks/sock_path"
,
sizeof
(
addr
.
sun_path
)
-
1
);
strncpy
(
addr
.
sun_path
,
sock_str
,
sizeof
(
addr
.
sun_path
)
-
1
);
if
(
connect
(
fd
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
))
==
-
1
)
{
if
(
connect
(
fd
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
))
==
-
1
)
{
LOGE
(
"connect() failed: %s (fd = %d)
\n
"
,
strerror
(
errno
),
fd
);
LOGE
(
"connect() failed: %s (fd = %d)
\n
"
,
strerror
(
errno
),
fd
);
...
@@ -90,6 +91,7 @@ jint Java_com_github_shadowsocks_system_sendfd(JNIEnv *env, jobject thiz, jint t
...
@@ -90,6 +91,7 @@ jint Java_com_github_shadowsocks_system_sendfd(JNIEnv *env, jobject thiz, jint t
}
}
close
(
fd
);
close
(
fd
);
env
->
ReleaseStringUTFChars
(
path
,
sock_str
);
return
0
;
return
0
;
}
}
...
@@ -98,7 +100,7 @@ static const char *classPathName = "com/github/shadowsocks/System";
...
@@ -98,7 +100,7 @@ static const char *classPathName = "com/github/shadowsocks/System";
static
JNINativeMethod
method_table
[]
=
{
static
JNINativeMethod
method_table
[]
=
{
{
"jniclose"
,
"(I)V"
,
{
"jniclose"
,
"(I)V"
,
(
void
*
)
Java_com_github_shadowsocks_system_jniclose
},
(
void
*
)
Java_com_github_shadowsocks_system_jniclose
},
{
"sendfd"
,
"(I)I"
,
{
"sendfd"
,
"(I
Ljava/lang/String;
)I"
,
(
void
*
)
Java_com_github_shadowsocks_system_sendfd
},
(
void
*
)
Java_com_github_shadowsocks_system_sendfd
},
{
"exec"
,
"(Ljava/lang/String;)I"
,
{
"exec"
,
"(Ljava/lang/String;)I"
,
(
void
*
)
Java_com_github_shadowsocks_system_exec
},
(
void
*
)
Java_com_github_shadowsocks_system_exec
},
...
...
src/main/res/values/strings.xml
View file @
d337f0e2
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
</plurals>
</plurals>
<string
name=
"connection_test_pending"
>
Check Connectivity
</string>
<string
name=
"connection_test_pending"
>
Check Connectivity
</string>
<string
name=
"connection_test_testing"
>
Testing…
</string>
<string
name=
"connection_test_testing"
>
Testing…
</string>
<string
name=
"connection_test_available"
>
Success: %dms latency
to Internet
</string>
<string
name=
"connection_test_available"
>
Success: %dms latency
</string>
<string
name=
"connection_test_error"
>
Fail to detect internet connection: %s
</string>
<string
name=
"connection_test_error"
>
Fail to detect internet connection: %s
</string>
<string
name=
"connection_test_fail"
>
Internet Unavailable
</string>
<string
name=
"connection_test_fail"
>
Internet Unavailable
</string>
<string
name=
"connection_test_error_status_code"
>
Error code: #%d
</string>
<string
name=
"connection_test_error_status_code"
>
Error code: #%d
</string>
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
d337f0e2
...
@@ -262,7 +262,7 @@ class Shadowsocks
...
@@ -262,7 +262,7 @@ class Shadowsocks
}
else
{
}
else
{
in
=
assetManager
.
open
(
file
)
in
=
assetManager
.
open
(
file
)
}
}
out
=
new
FileOutputStream
(
Path
.
BASE
+
file
)
out
=
new
FileOutputStream
(
getApplicationInfo
().
dataDir
+
"/"
+
file
)
copyFile
(
in
,
out
)
copyFile
(
in
,
out
)
in
.
close
()
in
.
close
()
in
=
null
in
=
null
...
@@ -292,8 +292,8 @@ class Shadowsocks
...
@@ -292,8 +292,8 @@ class Shadowsocks
val
cmd
=
new
ArrayBuffer
[
String
]()
val
cmd
=
new
ArrayBuffer
[
String
]()
for
(
task
<-
Array
(
"ss-local"
,
"ss-tunnel"
,
"pdnsd"
,
"redsocks"
,
"tun2socks"
))
{
for
(
task
<-
Array
(
"ss-local"
,
"ss-tunnel"
,
"pdnsd"
,
"redsocks"
,
"tun2socks"
))
{
cmd
.
append
(
"chmod 666 %s
%s-nat.pid"
.
formatLocal
(
Locale
.
ENGLISH
,
Path
.
BASE
,
task
))
cmd
.
append
(
"chmod 666 %s
/%s-nat.pid"
.
formatLocal
(
Locale
.
ENGLISH
,
getApplicationInfo
().
dataDir
,
task
))
cmd
.
append
(
"chmod 666 %s
%s-vpn.pid"
.
formatLocal
(
Locale
.
ENGLISH
,
Path
.
BASE
,
task
))
cmd
.
append
(
"chmod 666 %s
/%s-vpn.pid"
.
formatLocal
(
Locale
.
ENGLISH
,
getApplicationInfo
().
dataDir
,
task
))
}
}
if
(
ShadowsocksApplication
.
isVpnEnabled
)
{
if
(
ShadowsocksApplication
.
isVpnEnabled
)
{
...
@@ -306,8 +306,8 @@ class Shadowsocks
...
@@ -306,8 +306,8 @@ class Shadowsocks
for
(
task
<-
Array
(
"ss-local"
,
"ss-tunnel"
,
"pdnsd"
,
"redsocks"
,
"tun2socks"
))
{
for
(
task
<-
Array
(
"ss-local"
,
"ss-tunnel"
,
"pdnsd"
,
"redsocks"
,
"tun2socks"
))
{
try
{
try
{
val
pid_nat
=
scala
.
io
.
Source
.
fromFile
(
Path
.
BASE
+
task
+
"-nat.pid"
).
mkString
.
trim
.
toInt
val
pid_nat
=
scala
.
io
.
Source
.
fromFile
(
getApplicationInfo
().
dataDir
+
"/"
+
task
+
"-nat.pid"
).
mkString
.
trim
.
toInt
val
pid_vpn
=
scala
.
io
.
Source
.
fromFile
(
Path
.
BASE
+
task
+
"-vpn.pid"
).
mkString
.
trim
.
toInt
val
pid_vpn
=
scala
.
io
.
Source
.
fromFile
(
getApplicationInfo
().
dataDir
+
"/"
+
task
+
"-vpn.pid"
).
mkString
.
trim
.
toInt
cmd
.
append
(
"kill -9 %d"
.
formatLocal
(
Locale
.
ENGLISH
,
pid_nat
))
cmd
.
append
(
"kill -9 %d"
.
formatLocal
(
Locale
.
ENGLISH
,
pid_nat
))
cmd
.
append
(
"kill -9 %d"
.
formatLocal
(
Locale
.
ENGLISH
,
pid_vpn
))
cmd
.
append
(
"kill -9 %d"
.
formatLocal
(
Locale
.
ENGLISH
,
pid_vpn
))
Process
.
killProcess
(
pid_nat
)
Process
.
killProcess
(
pid_nat
)
...
@@ -315,10 +315,10 @@ class Shadowsocks
...
@@ -315,10 +315,10 @@ class Shadowsocks
}
catch
{
}
catch
{
case
e
:
Throwable
=>
// Ignore
case
e
:
Throwable
=>
// Ignore
}
}
cmd
.
append
(
"rm -f %s
%s-nat.pid"
.
formatLocal
(
Locale
.
ENGLISH
,
Path
.
BASE
,
task
))
cmd
.
append
(
"rm -f %s
/%s-nat.pid"
.
formatLocal
(
Locale
.
ENGLISH
,
getApplicationInfo
().
dataDir
,
task
))
cmd
.
append
(
"rm -f %s
%s-nat.conf"
.
formatLocal
(
Locale
.
ENGLISH
,
Path
.
BASE
,
task
))
cmd
.
append
(
"rm -f %s
/%s-nat.conf"
.
formatLocal
(
Locale
.
ENGLISH
,
getApplicationInfo
().
dataDir
,
task
))
cmd
.
append
(
"rm -f %s
%s-vpn.pid"
.
formatLocal
(
Locale
.
ENGLISH
,
Path
.
BASE
,
task
))
cmd
.
append
(
"rm -f %s
/%s-vpn.pid"
.
formatLocal
(
Locale
.
ENGLISH
,
getApplicationInfo
().
dataDir
,
task
))
cmd
.
append
(
"rm -f %s
%s-vpn.conf"
.
formatLocal
(
Locale
.
ENGLISH
,
Path
.
BASE
,
task
))
cmd
.
append
(
"rm -f %s
/%s-vpn.conf"
.
formatLocal
(
Locale
.
ENGLISH
,
getApplicationInfo
().
dataDir
,
task
))
}
}
if
(
ShadowsocksApplication
.
isVpnEnabled
)
Console
.
runCommand
(
cmd
.
toArray
)
else
{
if
(
ShadowsocksApplication
.
isVpnEnabled
)
Console
.
runCommand
(
cmd
.
toArray
)
else
{
Console
.
runRootCommand
(
cmd
.
toArray
)
Console
.
runRootCommand
(
cmd
.
toArray
)
...
@@ -502,7 +502,7 @@ class Shadowsocks
...
@@ -502,7 +502,7 @@ class Shadowsocks
val
ab
=
new
ArrayBuffer
[
String
]
val
ab
=
new
ArrayBuffer
[
String
]
for
(
executable
<-
Shadowsocks
.
EXECUTABLES
)
{
for
(
executable
<-
Shadowsocks
.
EXECUTABLES
)
{
ab
.
append
(
"chmod 755 "
+
Path
.
BASE
+
executable
)
ab
.
append
(
"chmod 755 "
+
getApplicationInfo
().
dataDir
+
"/"
+
executable
)
}
}
Console
.
runCommand
(
ab
.
toArray
)
Console
.
runCommand
(
ab
.
toArray
)
}
}
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksApplication.scala
View file @
d337f0e2
...
@@ -60,6 +60,7 @@ object ShadowsocksApplication {
...
@@ -60,6 +60,7 @@ object ShadowsocksApplication {
lazy
val
tracker
=
GoogleAnalytics
.
getInstance
(
instance
).
newTracker
(
R
.
xml
.
tracker
)
lazy
val
tracker
=
GoogleAnalytics
.
getInstance
(
instance
).
newTracker
(
R
.
xml
.
tracker
)
lazy
val
settings
=
PreferenceManager
.
getDefaultSharedPreferences
(
instance
)
lazy
val
settings
=
PreferenceManager
.
getDefaultSharedPreferences
(
instance
)
lazy
val
profileManager
=
new
ProfileManager
(
settings
,
dbHelper
)
lazy
val
profileManager
=
new
ProfileManager
(
settings
,
dbHelper
)
lazy
val
dataDir
=
instance
.
getApplicationInfo
().
dataDir
def
isVpnEnabled
=
!
settings
.
getBoolean
(
Key
.
isNAT
,
false
)
def
isVpnEnabled
=
!
settings
.
getBoolean
(
Key
.
isNAT
,
false
)
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
View file @
d337f0e2
...
@@ -168,7 +168,7 @@ class ShadowsocksNatService extends BaseService {
...
@@ -168,7 +168,7 @@ class ShadowsocksNatService extends BaseService {
case
Route
.
BYPASS_LAN
=>
getResources
.
getStringArray
(
R
.
array
.
private_route
)
case
Route
.
BYPASS_LAN
=>
getResources
.
getStringArray
(
R
.
array
.
private_route
)
case
Route
.
BYPASS_CHN
=>
getResources
.
getStringArray
(
R
.
array
.
chn_route_full
)
case
Route
.
BYPASS_CHN
=>
getResources
.
getStringArray
(
R
.
array
.
chn_route_full
)
}
}
ConfigUtils
.
printToFile
(
new
File
(
Path
.
BASE
+
"
acl.list"
))(
p
=>
{
ConfigUtils
.
printToFile
(
new
File
(
getApplicationInfo
().
dataDir
+
"/
acl.list"
))(
p
=>
{
acl
.
foreach
(
item
=>
p
.
println
(
item
))
acl
.
foreach
(
item
=>
p
.
println
(
item
))
})
})
}
}
...
@@ -176,21 +176,21 @@ class ShadowsocksNatService extends BaseService {
...
@@ -176,21 +176,21 @@ class ShadowsocksNatService extends BaseService {
val
conf
=
ConfigUtils
val
conf
=
ConfigUtils
.
SHADOWSOCKS
.
formatLocal
(
Locale
.
ENGLISH
,
config
.
proxy
,
config
.
remotePort
,
config
.
localPort
,
.
SHADOWSOCKS
.
formatLocal
(
Locale
.
ENGLISH
,
config
.
proxy
,
config
.
remotePort
,
config
.
localPort
,
config
.
sitekey
,
config
.
encMethod
,
600
)
config
.
sitekey
,
config
.
encMethod
,
600
)
ConfigUtils
.
printToFile
(
new
File
(
Path
.
BASE
+
"
ss-local-nat.conf"
))(
p
=>
{
ConfigUtils
.
printToFile
(
new
File
(
getApplicationInfo
().
dataDir
+
"/
ss-local-nat.conf"
))(
p
=>
{
p
.
println
(
conf
)
p
.
println
(
conf
)
})
})
val
cmd
=
new
ArrayBuffer
[
String
]
val
cmd
=
new
ArrayBuffer
[
String
]
cmd
+=
(
Path
.
BASE
+
"
ss-local"
cmd
+=
(
getApplicationInfo
().
dataDir
+
"/
ss-local"
,
"-b"
,
"127.0.0.1"
,
"-b"
,
"127.0.0.1"
,
"-t"
,
"600"
,
"-t"
,
"600"
,
"-c"
,
Path
.
BASE
+
"
ss-local-nat.conf"
)
,
"-c"
,
getApplicationInfo
().
dataDir
+
"/
ss-local-nat.conf"
)
if
(
config
.
isAuth
)
cmd
+=
"-A"
if
(
config
.
isAuth
)
cmd
+=
"-A"
if
(
config
.
route
!=
Route
.
ALL
)
{
if
(
config
.
route
!=
Route
.
ALL
)
{
cmd
+=
"--acl"
cmd
+=
"--acl"
cmd
+=
(
Path
.
BASE
+
"
acl.list"
)
cmd
+=
(
getApplicationInfo
().
dataDir
+
"/
acl.list"
)
}
}
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
cmd
.
mkString
(
" "
))
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
cmd
.
mkString
(
" "
))
...
@@ -205,16 +205,16 @@ class ShadowsocksNatService extends BaseService {
...
@@ -205,16 +205,16 @@ class ShadowsocksNatService extends BaseService {
val
conf
=
ConfigUtils
val
conf
=
ConfigUtils
.
SHADOWSOCKS
.
formatLocal
(
Locale
.
ENGLISH
,
config
.
proxy
,
config
.
remotePort
,
8153
,
.
SHADOWSOCKS
.
formatLocal
(
Locale
.
ENGLISH
,
config
.
proxy
,
config
.
remotePort
,
8153
,
config
.
sitekey
,
config
.
encMethod
,
10
)
config
.
sitekey
,
config
.
encMethod
,
10
)
ConfigUtils
.
printToFile
(
new
File
(
Path
.
BASE
+
"
ss-tunnel-nat.conf"
))(
p
=>
{
ConfigUtils
.
printToFile
(
new
File
(
getApplicationInfo
().
dataDir
+
"/
ss-tunnel-nat.conf"
))(
p
=>
{
p
.
println
(
conf
)
p
.
println
(
conf
)
})
})
val
cmd
=
new
ArrayBuffer
[
String
]
val
cmd
=
new
ArrayBuffer
[
String
]
cmd
+=
(
Path
.
BASE
+
"
ss-tunnel"
cmd
+=
(
getApplicationInfo
().
dataDir
+
"/
ss-tunnel"
,
"-u"
,
"-u"
,
"-t"
,
"10"
,
"-t"
,
"10"
,
"-b"
,
"127.0.0.1"
,
"-b"
,
"127.0.0.1"
,
"-L"
,
"8.8.8.8:53"
,
"-L"
,
"8.8.8.8:53"
,
"-c"
,
Path
.
BASE
+
"
ss-tunnel-nat.conf"
)
,
"-c"
,
getApplicationInfo
().
dataDir
+
"/
ss-tunnel-nat.conf"
)
cmd
+=
(
"-l"
,
"8153"
)
cmd
+=
(
"-l"
,
"8153"
)
...
@@ -231,17 +231,17 @@ class ShadowsocksNatService extends BaseService {
...
@@ -231,17 +231,17 @@ class ShadowsocksNatService extends BaseService {
val
conf
=
ConfigUtils
val
conf
=
ConfigUtils
.
SHADOWSOCKS
.
formatLocal
(
Locale
.
ENGLISH
,
config
.
proxy
,
config
.
remotePort
,
8163
,
.
SHADOWSOCKS
.
formatLocal
(
Locale
.
ENGLISH
,
config
.
proxy
,
config
.
remotePort
,
8163
,
config
.
sitekey
,
config
.
encMethod
,
10
)
config
.
sitekey
,
config
.
encMethod
,
10
)
ConfigUtils
.
printToFile
(
new
File
(
Path
.
BASE
+
"
ss-tunnel-nat.conf"
))(
p
=>
{
ConfigUtils
.
printToFile
(
new
File
(
getApplicationInfo
().
dataDir
+
"/
ss-tunnel-nat.conf"
))(
p
=>
{
p
.
println
(
conf
)
p
.
println
(
conf
)
})
})
val
cmdBuf
=
new
ArrayBuffer
[
String
]
val
cmdBuf
=
new
ArrayBuffer
[
String
]
cmdBuf
+=
(
Path
.
BASE
+
"
ss-tunnel"
cmdBuf
+=
(
getApplicationInfo
().
dataDir
+
"/
ss-tunnel"
,
"-u"
,
"-u"
,
"-t"
,
"10"
,
"-t"
,
"10"
,
"-b"
,
"127.0.0.1"
,
"-b"
,
"127.0.0.1"
,
"-l"
,
"8163"
,
"-l"
,
"8163"
,
"-L"
,
"8.8.8.8:53"
,
"-L"
,
"8.8.8.8:53"
,
"-c"
,
Path
.
BASE
+
"
ss-tunnel-nat.conf"
)
,
"-c"
,
getApplicationInfo
().
dataDir
+
"/
ss-tunnel-nat.conf"
)
if
(
config
.
isAuth
)
cmdBuf
+=
"-A"
if
(
config
.
isAuth
)
cmdBuf
+=
"-A"
...
@@ -266,10 +266,10 @@ class ShadowsocksNatService extends BaseService {
...
@@ -266,10 +266,10 @@ class ShadowsocksNatService extends BaseService {
8163
,
""
)
8163
,
""
)
}
}
ConfigUtils
.
printToFile
(
new
File
(
Path
.
BASE
+
"
pdnsd-nat.conf"
))(
p
=>
{
ConfigUtils
.
printToFile
(
new
File
(
getApplicationInfo
().
dataDir
+
"/
pdnsd-nat.conf"
))(
p
=>
{
p
.
println
(
conf
)
p
.
println
(
conf
)
})
})
val
cmd
=
Path
.
BASE
+
"pdnsd -c "
+
Path
.
BASE
+
"
pdnsd-nat.conf"
val
cmd
=
getApplicationInfo
().
dataDir
+
"/pdnsd -c "
+
getApplicationInfo
().
dataDir
+
"/
pdnsd-nat.conf"
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
cmd
)
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
cmd
)
...
@@ -293,9 +293,9 @@ class ShadowsocksNatService extends BaseService {
...
@@ -293,9 +293,9 @@ class ShadowsocksNatService extends BaseService {
def
startRedsocksDaemon
()
{
def
startRedsocksDaemon
()
{
val
conf
=
ConfigUtils
.
REDSOCKS
.
formatLocal
(
Locale
.
ENGLISH
,
config
.
localPort
)
val
conf
=
ConfigUtils
.
REDSOCKS
.
formatLocal
(
Locale
.
ENGLISH
,
config
.
localPort
)
val
cmd
=
Path
.
BASE
+
"redsocks -c %s
redsocks-nat.conf"
val
cmd
=
"%s/redsocks -c %s/
redsocks-nat.conf"
.
formatLocal
(
Locale
.
ENGLISH
,
Path
.
BASE
,
Path
.
BASE
)
.
formatLocal
(
Locale
.
ENGLISH
,
getApplicationInfo
().
dataDir
,
getApplicationInfo
().
dataDir
)
ConfigUtils
.
printToFile
(
new
File
(
Path
.
BASE
+
"
redsocks-nat.conf"
))(
p
=>
{
ConfigUtils
.
printToFile
(
new
File
(
getApplicationInfo
().
dataDir
+
"/
redsocks-nat.conf"
))(
p
=>
{
p
.
println
(
conf
)
p
.
println
(
conf
)
})
})
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
d337f0e2
...
@@ -261,7 +261,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
...
@@ -261,7 +261,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
var
tries
=
1
var
tries
=
1
while
(
tries
<
5
)
{
while
(
tries
<
5
)
{
Thread
.
sleep
(
1000
*
tries
)
Thread
.
sleep
(
1000
*
tries
)
if
(
System
.
sendfd
(
fd
)
!=
-
1
)
{
if
(
System
.
sendfd
(
fd
,
getApplicationInfo
().
dataDir
+
"/sock_path"
)
!=
-
1
)
{
return
true
return
true
}
}
tries
+=
1
tries
+=
1
...
@@ -277,7 +277,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
...
@@ -277,7 +277,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
case
Route
.
BYPASS_LAN
=>
getResources
.
getStringArray
(
R
.
array
.
private_route
)
case
Route
.
BYPASS_LAN
=>
getResources
.
getStringArray
(
R
.
array
.
private_route
)
case
Route
.
BYPASS_CHN
=>
getResources
.
getStringArray
(
R
.
array
.
chn_route_full
)
case
Route
.
BYPASS_CHN
=>
getResources
.
getStringArray
(
R
.
array
.
chn_route_full
)
}
}
ConfigUtils
.
printToFile
(
new
File
(
Path
.
BASE
+
"
acl.list"
))(
p
=>
{
ConfigUtils
.
printToFile
(
new
File
(
getApplicationInfo
().
dataDir
+
"/
acl.list"
))(
p
=>
{
acl
.
foreach
(
item
=>
p
.
println
(
item
))
acl
.
foreach
(
item
=>
p
.
println
(
item
))
})
})
}
}
...
@@ -285,21 +285,22 @@ class ShadowsocksVpnService extends VpnService with BaseService {
...
@@ -285,21 +285,22 @@ class ShadowsocksVpnService extends VpnService with BaseService {
val
conf
=
ConfigUtils
val
conf
=
ConfigUtils
.
SHADOWSOCKS
.
formatLocal
(
Locale
.
ENGLISH
,
config
.
proxy
,
config
.
remotePort
,
config
.
localPort
,
.
SHADOWSOCKS
.
formatLocal
(
Locale
.
ENGLISH
,
config
.
proxy
,
config
.
remotePort
,
config
.
localPort
,
config
.
sitekey
,
config
.
encMethod
,
600
)
config
.
sitekey
,
config
.
encMethod
,
600
)
ConfigUtils
.
printToFile
(
new
File
(
Path
.
BASE
+
"
ss-local-vpn.conf"
))(
p
=>
{
ConfigUtils
.
printToFile
(
new
File
(
getApplicationInfo
().
dataDir
+
"/
ss-local-vpn.conf"
))(
p
=>
{
p
.
println
(
conf
)
p
.
println
(
conf
)
})
})
val
cmd
=
new
ArrayBuffer
[
String
]
val
cmd
=
new
ArrayBuffer
[
String
]
cmd
+=
(
Path
.
BASE
+
"
ss-local"
,
"-V"
,
"-u"
cmd
+=
(
getApplicationInfo
().
dataDir
+
"/
ss-local"
,
"-V"
,
"-u"
,
"-b"
,
"127.0.0.1"
,
"-b"
,
"127.0.0.1"
,
"-t"
,
"600"
,
"-t"
,
"600"
,
"-c"
,
Path
.
BASE
+
"ss-local-vpn.conf"
)
,
"-P"
,
ShadowsocksApplication
.
dataDir
,
"-c"
,
getApplicationInfo
().
dataDir
+
"/ss-local-vpn.conf"
)
if
(
config
.
isAuth
)
cmd
+=
"-A"
if
(
config
.
isAuth
)
cmd
+=
"-A"
if
(
config
.
route
!=
Route
.
ALL
)
{
if
(
config
.
route
!=
Route
.
ALL
)
{
cmd
+=
"--acl"
cmd
+=
"--acl"
cmd
+=
(
Path
.
BASE
+
"
acl.list"
)
cmd
+=
(
getApplicationInfo
().
dataDir
+
"/
acl.list"
)
}
}
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
cmd
.
mkString
(
" "
))
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
cmd
.
mkString
(
" "
))
...
@@ -314,18 +315,19 @@ class ShadowsocksVpnService extends VpnService with BaseService {
...
@@ -314,18 +315,19 @@ class ShadowsocksVpnService extends VpnService with BaseService {
val
conf
=
ConfigUtils
val
conf
=
ConfigUtils
.
SHADOWSOCKS
.
formatLocal
(
Locale
.
ENGLISH
,
config
.
proxy
,
config
.
remotePort
,
8163
,
.
SHADOWSOCKS
.
formatLocal
(
Locale
.
ENGLISH
,
config
.
proxy
,
config
.
remotePort
,
8163
,
config
.
sitekey
,
config
.
encMethod
,
10
)
config
.
sitekey
,
config
.
encMethod
,
10
)
ConfigUtils
.
printToFile
(
new
File
(
Path
.
BASE
+
"
ss-tunnel-vpn.conf"
))(
p
=>
{
ConfigUtils
.
printToFile
(
new
File
(
getApplicationInfo
().
dataDir
+
"/
ss-tunnel-vpn.conf"
))(
p
=>
{
p
.
println
(
conf
)
p
.
println
(
conf
)
})
})
val
cmd
=
new
ArrayBuffer
[
String
]
val
cmd
=
new
ArrayBuffer
[
String
]
cmd
+=
(
Path
.
BASE
+
"
ss-tunnel"
cmd
+=
(
getApplicationInfo
().
dataDir
+
"/
ss-tunnel"
,
"-V"
,
"-V"
,
"-u"
,
"-u"
,
"-t"
,
"10"
,
"-t"
,
"10"
,
"-b"
,
"127.0.0.1"
,
"-b"
,
"127.0.0.1"
,
"-l"
,
"8163"
,
"-l"
,
"8163"
,
"-L"
,
"8.8.8.8:53"
,
"-L"
,
"8.8.8.8:53"
,
"-c"
,
Path
.
BASE
+
"ss-tunnel-vpn.conf"
)
,
"-P"
,
ShadowsocksApplication
.
dataDir
,
"-c"
,
getApplicationInfo
().
dataDir
+
"/ss-tunnel-vpn.conf"
)
if
(
config
.
isAuth
)
cmd
+=
"-A"
if
(
config
.
isAuth
)
cmd
+=
"-A"
...
@@ -350,10 +352,10 @@ class ShadowsocksVpnService extends VpnService with BaseService {
...
@@ -350,10 +352,10 @@ class ShadowsocksVpnService extends VpnService with BaseService {
8163
,
ipv6
)
8163
,
ipv6
)
}
}
}
}
ConfigUtils
.
printToFile
(
new
File
(
Path
.
BASE
+
"
pdnsd-vpn.conf"
))(
p
=>
{
ConfigUtils
.
printToFile
(
new
File
(
getApplicationInfo
().
dataDir
+
"/
pdnsd-vpn.conf"
))(
p
=>
{
p
.
println
(
conf
)
p
.
println
(
conf
)
})
})
val
cmd
=
Path
.
BASE
+
"pdnsd -c "
+
Path
.
BASE
+
"
pdnsd-vpn.conf"
val
cmd
=
getApplicationInfo
().
dataDir
+
"/pdnsd -c "
+
getApplicationInfo
().
dataDir
+
"/
pdnsd-vpn.conf"
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
cmd
)
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
cmd
)
...
@@ -428,16 +430,17 @@ class ShadowsocksVpnService extends VpnService with BaseService {
...
@@ -428,16 +430,17 @@ class ShadowsocksVpnService extends VpnService with BaseService {
val
fd
=
conn
.
getFd
val
fd
=
conn
.
getFd
var
cmd
=
(
Path
.
BASE
+
var
cmd
=
(
getApplicationInfo
().
dataDir
+
"tun2socks --netif-ipaddr %s "
"
/
tun2socks --netif-ipaddr %s "
+
"--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 "
+
"--sock-path %s "
+
"--loglevel 3"
)
+
"--loglevel 3"
)
.
formatLocal
(
Locale
.
ENGLISH
,
.
formatLocal
(
Locale
.
ENGLISH
,
PRIVATE_VLAN
.
formatLocal
(
Locale
.
ENGLISH
,
"2"
),
PRIVATE_VLAN
.
formatLocal
(
Locale
.
ENGLISH
,
"2"
),
config
.
localPort
,
fd
,
VPN_MTU
)
config
.
localPort
,
fd
,
VPN_MTU
,
getApplicationInfo
().
dataDir
+
"/sock_path"
)
if
(
config
.
isIpv6
)
if
(
config
.
isIpv6
)
cmd
+=
" --netif-ip6addr "
+
PRIVATE_VLAN6
.
formatLocal
(
Locale
.
ENGLISH
,
"2"
)
cmd
+=
" --netif-ip6addr "
+
PRIVATE_VLAN6
.
formatLocal
(
Locale
.
ENGLISH
,
"2"
)
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksVpnThread.scala
View file @
d337f0e2
...
@@ -53,7 +53,7 @@ class ShadowsocksVpnThread(vpnService: ShadowsocksVpnService) extends Thread {
...
@@ -53,7 +53,7 @@ class ShadowsocksVpnThread(vpnService: ShadowsocksVpnService) extends Thread {
import
ShadowsocksVpnThread._
import
ShadowsocksVpnThread._
val
TAG
=
"ShadowsocksVpnService"
val
TAG
=
"ShadowsocksVpnService"
val
PATH
=
"/data/data/com.github.shadowsocks
/protect_path"
lazy
val
PATH
=
ShadowsocksApplication
.
dataDir
+
"
/protect_path"
@volatile
var
isRunning
:
Boolean
=
true
@volatile
var
isRunning
:
Boolean
=
true
@volatile
var
serverSocket
:
LocalServerSocket
=
null
@volatile
var
serverSocket
:
LocalServerSocket
=
null
...
...
src/main/scala/com/github/shadowsocks/utils/Constants.scala
View file @
d337f0e2
...
@@ -55,10 +55,6 @@ object Msg {
...
@@ -55,10 +55,6 @@ object Msg {
val
VPN_ERROR
=
6
val
VPN_ERROR
=
6
}
}
object
Path
{
val
BASE
=
"/data/data/com.github.shadowsocks/"
}
object
Key
{
object
Key
{
val
profileId
=
"profileId"
val
profileId
=
"profileId"
val
profileName
=
"profileName"
val
profileName
=
"profileName"
...
...
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