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
5f95cccc
Commit
5f95cccc
authored
Oct 19, 2014
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement per-app VPN for Android 5.0
parent
55f25d32
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
6 deletions
+35
-6
src/main/AndroidManifest.xml
src/main/AndroidManifest.xml
+2
-2
src/main/scala/com/github/shadowsocks/AppManager.scala
src/main/scala/com/github/shadowsocks/AppManager.scala
+2
-1
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+1
-1
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+30
-2
No files found.
src/main/AndroidManifest.xml
View file @
5f95cccc
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.github.shadowsocks"
android:versionCode=
"7
5
"
android:versionName=
"2.3.
0
"
>
android:versionCode=
"7
6
"
android:versionName=
"2.3.
1
"
>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.ACCESS_NETWORK_STATE"
/>
...
...
src/main/scala/com/github/shadowsocks/AppManager.scala
View file @
5f95cccc
...
...
@@ -89,8 +89,9 @@ object AppManager {
case
a
=>
{
val
uid
=
a
.
uid
val
userName
=
uid
.
toString
val
packageName
=
a
.
packageName
val
proxied
=
proxiedApps
.
binarySearch
(
userName
)
>=
0
new
ProxiedApp
(
uid
,
user
Name
,
proxied
)
new
ProxiedApp
(
uid
,
package
Name
,
proxied
)
}
}.
toArray
}
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
5f95cccc
...
...
@@ -766,7 +766,7 @@ class Shadowsocks
if
(
pref
!=
null
)
{
if
(
Seq
(
Key
.
isGlobalProxy
,
Key
.
isTrafficStat
,
Key
.
proxyedApps
)
.
contains
(
name
))
{
pref
.
setEnabled
(
enabled
&&
!
isVpnEnabled
)
pref
.
setEnabled
(
enabled
&&
(!
isVpnEnabled
||
Build
.
VERSION
.
SDK_INT
==
Build
.
VERSION_CODES
.
LOLLIPOP
)
)
}
else
{
pref
.
setEnabled
(
enabled
)
}
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
5f95cccc
...
...
@@ -55,6 +55,7 @@ import com.google.android.gms.analytics.HitBuilders
import
org.apache.commons.net.util.SubnetUtils
import
org.apache.http.conn.util.InetAddressUtils
import
scala.collection.mutable
import
scala.collection.mutable.ArrayBuffer
import
scala.concurrent.ops._
...
...
@@ -66,6 +67,8 @@ class ShadowsocksVpnService extends VpnService with BaseService {
val
PRIVATE_VLAN
=
"26.26.26.%s"
val
AF_INET6
=
10
var
conn
:
ParcelFileDescriptor
=
null
var
notificationManager
:
NotificationManager
=
null
var
receiver
:
BroadcastReceiver
=
null
...
...
@@ -88,7 +91,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
,
"-l"
,
config
.
localPort
.
toString
,
"-k"
,
config
.
sitekey
,
"-m"
,
config
.
encMethod
,
"-f"
,
(
Path
.
BASE
+
"ss-local.pid"
)
)
,
"-f"
,
Path
.
BASE
+
"ss-local.pid"
)
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
cmd
.
mkString
(
" "
))
Core
.
sslocal
(
cmd
.
toArray
)
}
...
...
@@ -126,11 +129,36 @@ class ShadowsocksVpnService extends VpnService with BaseService {
.
addAddress
(
PRIVATE_VLAN
.
format
(
"1"
),
24
)
.
addDnsServer
(
"8.8.8.8"
)
if
(
Build
.
VERSION
.
SDK_INT
==
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
builder
.
allowFamily
(
AF_INET6
)
if
(
config
.
isBypassApps
)
{
builder
.
addDisallowedApplication
(
this
.
getPackageName
)
}
if
(!
config
.
isGlobalProxy
)
{
val
apps
=
AppManager
.
getProxiedApps
(
this
,
config
.
proxiedAppString
)
val
uidSet
:
mutable.HashSet
[
String
]
=
new
mutable
.
HashSet
[
String
]
for
(
app
<-
apps
)
{
if
(
app
.
proxied
)
{
uidSet
.
add
(
app
.
name
)
}
}
for
(
uid
<-
uidSet
)
{
if
(!
config
.
isBypassApps
)
{
builder
.
addAllowedApplication
(
uid
)
}
else
{
builder
.
addDisallowedApplication
(
uid
)
}
}
}
}
if
(
InetAddressUtils
.
isIPv6Address
(
config
.
proxy
))
{
builder
.
addRoute
(
"0.0.0.0"
,
0
)
}
else
if
(
config
.
isGFWList
)
{
val
gfwList
=
{
if
(
Build
.
VERSION
.
SDK_INT
==
19
)
{
if
(
Build
.
VERSION
.
SDK_INT
==
Build
.
VERSION_CODES
.
KITKAT
)
{
getResources
.
getStringArray
(
R
.
array
.
simple_list
)
}
else
{
getResources
.
getStringArray
(
R
.
array
.
gfw_list
)
...
...
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