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
bb6b2d61
Commit
bb6b2d61
authored
Feb 01, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Intercept DNS packets only at 172.19.0.2:53
parent
50056387
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
21 deletions
+16
-21
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
+12
-18
core/src/main/jni/Android.mk
core/src/main/jni/Android.mk
+3
-2
core/src/main/jni/badvpn
core/src/main/jni/badvpn
+1
-1
No files found.
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
View file @
bb6b2d61
...
...
@@ -39,7 +39,6 @@ import com.github.shadowsocks.net.DefaultNetworkListener
import
com.github.shadowsocks.net.Subnet
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.Key
import
com.github.shadowsocks.utils.parseNumericAddress
import
com.github.shadowsocks.utils.printLog
import
kotlinx.coroutines.delay
import
java.io.Closeable
...
...
@@ -52,8 +51,10 @@ import android.net.VpnService as BaseVpnService
class
VpnService
:
BaseVpnService
(),
LocalDnsService
.
Interface
{
companion
object
{
private
const
val
VPN_MTU
=
1500
private
const
val
PRIVATE_VLAN
=
"172.19.0.%s"
private
const
val
PRIVATE_VLAN6
=
"fdfe:dcba:9876::%s"
private
const
val
PRIVATE_VLAN4_CLIENT
=
"172.19.0.1"
private
const
val
PRIVATE_VLAN4_ROUTER
=
"172.19.0.2"
private
const
val
PRIVATE_VLAN6_CLIENT
=
"fdfe:dcba:9876::1"
private
const
val
PRIVATE_VLAN6_ROUTER
=
"fdfe:dcba:9876::2"
/**
* https://android.googlesource.com/platform/prebuilts/runtime/+/94fec32/appcompat/hiddenapi-light-greylist.txt#9466
...
...
@@ -136,9 +137,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
override
suspend
fun
startProcesses
()
{
worker
=
ProtectWorker
().
apply
{
start
()
}
super
.
startProcesses
()
sendFd
(
startVpn
())
}
...
...
@@ -153,12 +152,11 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
.
setConfigureIntent
(
Core
.
configureIntent
(
this
))
.
setSession
(
profile
.
formattedName
)
.
setMtu
(
VPN_MTU
)
.
addAddress
(
PRIVATE_VLAN
.
format
(
Locale
.
ENGLISH
,
"1"
),
24
)
profile
.
remoteDns
.
split
(
","
).
forEach
{
builder
.
addDnsServer
(
it
.
trim
())
}
.
addAddress
(
PRIVATE_VLAN4_CLIENT
,
30
)
.
addDnsServer
(
PRIVATE_VLAN4_ROUTER
)
if
(
profile
.
ipv6
)
{
builder
.
addAddress
(
PRIVATE_VLAN6
.
format
(
Locale
.
ENGLISH
,
"1"
)
,
126
)
builder
.
addAddress
(
PRIVATE_VLAN6
_CLIENT
,
126
)
builder
.
addRoute
(
"::"
,
0
)
}
...
...
@@ -179,14 +177,10 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
when
(
profile
.
route
)
{
Acl
.
ALL
,
Acl
.
BYPASS_CHN
,
Acl
.
CUSTOM_RULES
->
builder
.
addRoute
(
"0.0.0.0"
,
0
)
else
->
{
resources
.
getStringArray
(
R
.
array
.
bypass_private_route
).
forEach
{
else
->
resources
.
getStringArray
(
R
.
array
.
bypass_private_route
).
forEach
{
val
subnet
=
Subnet
.
fromString
(
it
)
!!
builder
.
addRoute
(
subnet
.
address
.
hostAddress
,
subnet
.
prefixSize
)
}
profile
.
remoteDns
.
split
(
","
).
mapNotNull
{
it
.
trim
().
parseNumericAddress
()
}
.
forEach
{
builder
.
addRoute
(
it
,
it
.
address
.
size
shl
3
)
}
}
}
active
=
true
// possible race condition here?
...
...
@@ -197,7 +191,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
val
fd
=
conn
.
fd
val
cmd
=
arrayListOf
(
File
(
applicationInfo
.
nativeLibraryDir
,
Executable
.
TUN2SOCKS
).
absolutePath
,
"--netif-ipaddr"
,
PRIVATE_VLAN
.
format
(
Locale
.
ENGLISH
,
"2"
)
,
"--netif-ipaddr"
,
PRIVATE_VLAN
4_ROUTER
,
"--netif-netmask"
,
"255.255.255.0"
,
"--socks-server-addr"
,
"${DataStore.listenAddress}:${DataStore.portProxy}"
,
"--tunfd"
,
fd
.
toString
(),
...
...
@@ -207,7 +201,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
"--loglevel"
,
"3"
)
if
(
profile
.
ipv6
)
{
cmd
+=
"--netif-ip6addr"
cmd
+=
PRIVATE_VLAN6
.
format
(
Locale
.
ENGLISH
,
"2"
)
cmd
+=
PRIVATE_VLAN6
_ROUTER
}
cmd
+=
"--enable-udprelay"
data
.
processes
!!
.
start
(
cmd
,
onRestartCallback
=
{
...
...
core/src/main/jni/Android.mk
View file @
bb6b2d61
...
...
@@ -325,7 +325,6 @@ TUN2SOCKS_SOURCES := \
flow/PacketProtoDecoder.c
\
socksclient/BSocksClient.c
\
tuntap/BTap.c
\
lwip/src/core/timers.c
\
lwip/src/core/udp.c
\
lwip/src/core/memp.c
\
lwip/src/core/init.c
\
...
...
@@ -334,14 +333,16 @@ TUN2SOCKS_SOURCES := \
lwip/src/core/tcp_out.c
\
lwip/src/core/netif.c
\
lwip/src/core/def.c
\
lwip/src/core/ip.c
\
lwip/src/core/mem.c
\
lwip/src/core/tcp_in.c
\
lwip/src/core/stats.c
\
lwip/src/core/inet_chksum.c
\
lwip/src/core/timeouts.c
\
lwip/src/core/ipv4/icmp.c
\
lwip/src/core/ipv4/igmp.c
\
lwip/src/core/ipv4/ip4_addr.c
\
lwip/src/core/ipv4/ip_frag.c
\
lwip/src/core/ipv4/ip
4
_frag.c
\
lwip/src/core/ipv4/ip4.c
\
lwip/src/core/ipv4/autoip.c
\
lwip/src/core/ipv6/ethip6.c
\
...
...
badvpn
@
ba4c45d6
Subproject commit
4c0050878618423da53e7e335fbb55ec2af6be06
Subproject commit
ba4c45d6b4d30fd6b2557e92a770ccae12ec9257
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