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
6dadff97
Commit
6dadff97
authored
Mar 29, 2018
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use underlying network only since Android P
Fixes #1706.
parent
35d3707f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
mobile/src/main/java/com/github/shadowsocks/bg/VpnService.kt
mobile/src/main/java/com/github/shadowsocks/bg/VpnService.kt
+10
-4
No files found.
mobile/src/main/java/com/github/shadowsocks/bg/VpnService.kt
View file @
6dadff97
...
...
@@ -20,6 +20,7 @@
package
com.github.shadowsocks.bg
import
android.annotation.TargetApi
import
android.app.Service
import
android.content.Context
import
android.content.Intent
...
...
@@ -28,6 +29,7 @@ import android.net.*
import
android.os.Build
import
android.os.IBinder
import
android.os.ParcelFileDescriptor
import
android.support.v4.os.BuildCompat
import
android.util.Log
import
com.github.shadowsocks.App.Companion.app
import
com.github.shadowsocks.JniHelper
...
...
@@ -116,12 +118,14 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
private
var
worker
:
ProtectWorker
?
=
null
private
var
tun2socksProcess
:
GuardedProcess
?
=
null
private
var
underlyingNetwork
:
Network
?
=
null
@TargetApi
(
28
)
set
(
value
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
22
)
setUnderlyingNetworks
(
if
(
value
==
null
)
null
else
arrayOf
(
value
))
setUnderlyingNetworks
(
if
(
value
==
null
)
null
else
arrayOf
(
value
))
field
=
value
}
private
val
connectivity
by
lazy
{
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
)
as
ConnectivityManager
}
@TargetApi
(
28
)
private
val
defaultNetworkCallback
=
object
:
ConnectivityManager
.
NetworkCallback
()
{
override
fun
onAvailable
(
network
:
Network
)
{
underlyingNetwork
=
network
...
...
@@ -229,9 +233,11 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
this
.
conn
=
conn
val
fd
=
conn
.
fd
if
(
BuildCompat
.
isAtLeastP
())
{
// we want REQUEST here instead of LISTEN
connectivity
.
requestNetwork
(
defaultNetworkRequest
,
defaultNetworkCallback
)
listeningForDefaultNetwork
=
true
}
val
cmd
=
arrayListOf
(
File
(
applicationInfo
.
nativeLibraryDir
,
Executable
.
TUN2SOCKS
).
absolutePath
,
"--netif-ipaddr"
,
PRIVATE_VLAN
.
format
(
Locale
.
ENGLISH
,
"2"
),
...
...
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