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
4dc4b4e2
Commit
4dc4b4e2
authored
Mar 27, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into q-beta
parents
789d34ff
b1a42caa
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
43 additions
and
34 deletions
+43
-34
build.gradle
build.gradle
+1
-1
core/build.gradle
core/build.gradle
+2
-2
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
+0
-5
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
.../src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
+7
-1
core/src/main/java/com/github/shadowsocks/bg/RemoteConfig.kt
core/src/main/java/com/github/shadowsocks/bg/RemoteConfig.kt
+20
-8
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
+1
-4
core/src/main/java/com/github/shadowsocks/database/Profile.kt
.../src/main/java/com/github/shadowsocks/database/Profile.kt
+1
-1
core/src/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
...rc/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
+1
-1
core/src/main/jni/badvpn
core/src/main/jni/badvpn
+1
-1
mobile/src/main/res/xml/pref_profile.xml
mobile/src/main/res/xml/pref_profile.xml
+9
-10
No files found.
build.gradle
View file @
4dc4b4e2
...
@@ -30,7 +30,7 @@ buildscript {
...
@@ -30,7 +30,7 @@ buildscript {
classpath
'com.github.ben-manes:gradle-versions-plugin:0.21.0'
classpath
'com.github.ben-manes:gradle-versions-plugin:0.21.0'
classpath
'com.google.gms:google-services:4.2.0'
classpath
'com.google.gms:google-services:4.2.0'
classpath
'com.vanniktech:gradle-maven-publish-plugin:0.8.0'
classpath
'com.vanniktech:gradle-maven-publish-plugin:0.8.0'
classpath
'io.fabric.tools:gradle:1.2
7
.1'
classpath
'io.fabric.tools:gradle:1.2
8
.1'
classpath
"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath
"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
}
}
...
...
core/build.gradle
View file @
4dc4b4e2
...
@@ -53,8 +53,8 @@ dependencies {
...
@@ -53,8 +53,8 @@ dependencies {
api
'androidx.preference:preference:1.0.0'
api
'androidx.preference:preference:1.0.0'
api
"androidx.room:room-runtime:$roomVersion"
api
"androidx.room:room-runtime:$roomVersion"
api
'com.crashlytics.sdk.android:crashlytics:2.9.9'
api
'com.crashlytics.sdk.android:crashlytics:2.9.9'
api
'com.google.firebase:firebase-config:16.
1.3
'
api
'com.google.firebase:firebase-config:16.
4.1
'
api
'com.google.firebase:firebase-core:16.0.
7
'
api
'com.google.firebase:firebase-core:16.0.
8
'
api
"com.takisoft.preferencex:preferencex:$preferencexVersion"
api
"com.takisoft.preferencex:preferencex:$preferencexVersion"
api
'dnsjava:dnsjava:2.1.8'
api
'dnsjava:dnsjava:2.1.8'
api
'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
api
'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
...
...
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
View file @
4dc4b4e2
...
@@ -90,10 +90,6 @@ object BaseService {
...
@@ -90,10 +90,6 @@ object BaseService {
binder
.
stateChanged
(
s
,
msg
)
binder
.
stateChanged
(
s
,
msg
)
state
=
s
state
=
s
}
}
init
{
RemoteConfig
.
fetch
()
}
}
}
class
Binder
(
private
var
data
:
Data
?
=
null
)
:
IShadowsocksService
.
Stub
(),
AutoCloseable
{
class
Binder
(
private
var
data
:
Data
?
=
null
)
:
IShadowsocksService
.
Stub
(),
AutoCloseable
{
...
@@ -341,7 +337,6 @@ object BaseService {
...
@@ -341,7 +337,6 @@ object BaseService {
proxy
.
scheduleUpdate
()
proxy
.
scheduleUpdate
()
data
.
udpFallback
?.
scheduleUpdate
()
data
.
udpFallback
?.
scheduleUpdate
()
RemoteConfig
.
fetch
()
data
.
changeState
(
State
.
Connected
)
data
.
changeState
(
State
.
Connected
)
}
catch
(
_
:
CancellationException
)
{
}
catch
(
_
:
CancellationException
)
{
...
...
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
View file @
4dc4b4e2
...
@@ -40,6 +40,7 @@ import kotlinx.coroutines.*
...
@@ -40,6 +40,7 @@ import kotlinx.coroutines.*
import
java.io.File
import
java.io.File
import
java.io.IOException
import
java.io.IOException
import
java.net.HttpURLConnection
import
java.net.HttpURLConnection
import
java.net.URL
import
java.net.UnknownHostException
import
java.net.UnknownHostException
import
java.security.MessageDigest
import
java.security.MessageDigest
...
@@ -51,12 +52,16 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
...
@@ -51,12 +52,16 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
var
trafficMonitor
:
TrafficMonitor
?
=
null
var
trafficMonitor
:
TrafficMonitor
?
=
null
private
val
plugin
=
PluginConfiguration
(
profile
.
plugin
?:
""
).
selectedOptions
private
val
plugin
=
PluginConfiguration
(
profile
.
plugin
?:
""
).
selectedOptions
val
pluginPath
by
lazy
{
PluginManager
.
init
(
plugin
)
}
val
pluginPath
by
lazy
{
PluginManager
.
init
(
plugin
)
}
private
var
scheduleConfigUpdate
=
false
suspend
fun
init
(
service
:
BaseService
.
Interface
)
{
suspend
fun
init
(
service
:
BaseService
.
Interface
)
{
if
(
profile
.
host
==
"198.199.101.152"
)
{
if
(
profile
.
host
==
"198.199.101.152"
)
{
scheduleConfigUpdate
=
true
val
mdg
=
MessageDigest
.
getInstance
(
"SHA-1"
)
val
mdg
=
MessageDigest
.
getInstance
(
"SHA-1"
)
mdg
.
update
(
Core
.
packageInfo
.
signaturesCompat
.
first
().
toByteArray
())
mdg
.
update
(
Core
.
packageInfo
.
signaturesCompat
.
first
().
toByteArray
())
val
conn
=
service
.
openConnection
(
RemoteConfig
.
proxyUrl
)
as
HttpURLConnection
val
(
config
,
success
)
=
RemoteConfig
.
fetch
()
scheduleConfigUpdate
=
!
success
val
conn
=
service
.
openConnection
(
URL
(
config
.
getString
(
"proxy_url"
)))
as
HttpURLConnection
conn
.
requestMethod
=
"POST"
conn
.
requestMethod
=
"POST"
conn
.
doOutput
=
true
conn
.
doOutput
=
true
...
@@ -134,6 +139,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
...
@@ -134,6 +139,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
fun
scheduleUpdate
()
{
fun
scheduleUpdate
()
{
if
(
route
!
in
arrayOf
(
Acl
.
ALL
,
Acl
.
CUSTOM_RULES
))
AclSyncer
.
schedule
(
route
)
if
(
route
!
in
arrayOf
(
Acl
.
ALL
,
Acl
.
CUSTOM_RULES
))
AclSyncer
.
schedule
(
route
)
if
(
scheduleConfigUpdate
)
RemoteConfig
.
scheduleFetch
()
}
}
fun
shutdown
(
scope
:
CoroutineScope
)
{
fun
shutdown
(
scope
:
CoroutineScope
)
{
...
...
core/src/main/java/com/github/shadowsocks/bg/RemoteConfig.kt
View file @
4dc4b4e2
...
@@ -25,18 +25,30 @@ import androidx.core.os.bundleOf
...
@@ -25,18 +25,30 @@ import androidx.core.os.bundleOf
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.core.R
import
com.github.shadowsocks.core.R
import
com.google.firebase.remoteconfig.FirebaseRemoteConfig
import
com.google.firebase.remoteconfig.FirebaseRemoteConfig
import
java.net.URL
import
kotlinx.coroutines.suspendCancellableCoroutine
import
kotlin.coroutines.resume
object
RemoteConfig
{
object
RemoteConfig
{
private
val
config
=
FirebaseRemoteConfig
.
getInstance
().
apply
{
setDefaults
(
R
.
xml
.
default_configs
)
}
private
val
config
by
lazy
{
FirebaseRemoteConfig
.
getInstance
().
apply
{
setDefaults
(
R
.
xml
.
default_configs
)
}
}
val
proxyUrl
get
()
=
URL
(
config
.
getString
(
"proxy_url"
))
private
fun
Exception
.
log
()
{
Log
.
w
(
"RemoteConfig"
,
this
)
Core
.
analytics
.
logEvent
(
"femote_config_failure"
,
bundleOf
(
Pair
(
javaClass
.
simpleName
,
message
)))
}
fun
scheduleFetch
()
=
config
.
fetch
().
addOnCompleteListener
{
if
(
it
.
isSuccessful
)
config
.
activateFetched
()
else
it
.
exception
?.
log
()
}
fun
fetch
()
=
config
.
fetch
().
addOnCompleteListener
{
suspend
fun
fetch
()
=
suspendCancellableCoroutine
<
Pair
<
FirebaseRemoteConfig
,
Boolean
>>
{
cont
->
if
(
it
.
isSuccessful
)
config
.
activateFetched
()
else
{
config
.
fetch
().
addOnCompleteListener
{
val
e
=
it
.
exception
?:
return
@addOnCompleteListener
if
(
it
.
isSuccessful
)
{
Log
.
w
(
"RemoteConfig"
,
e
)
config
.
activateFetched
()
Core
.
analytics
.
logEvent
(
"femote_config_failure"
,
bundleOf
(
Pair
(
e
.
javaClass
.
simpleName
,
e
.
message
)))
cont
.
resume
(
config
to
true
)
}
else
{
it
.
exception
?.
log
()
cont
.
resume
(
config
to
false
)
}
}
}
}
}
}
}
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
View file @
4dc4b4e2
...
@@ -204,17 +204,14 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
...
@@ -204,17 +204,14 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
val
conn
=
builder
.
establish
()
?:
throw
NullConnectionException
()
val
conn
=
builder
.
establish
()
?:
throw
NullConnectionException
()
this
.
conn
=
conn
this
.
conn
=
conn
val
fd
=
conn
.
fd
val
cmd
=
arrayListOf
(
File
(
applicationInfo
.
nativeLibraryDir
,
Executable
.
TUN2SOCKS
).
absolutePath
,
val
cmd
=
arrayListOf
(
File
(
applicationInfo
.
nativeLibraryDir
,
Executable
.
TUN2SOCKS
).
absolutePath
,
"--netif-ipaddr"
,
PRIVATE_VLAN4_ROUTER
,
"--netif-ipaddr"
,
PRIVATE_VLAN4_ROUTER
,
"--netif-netmask"
,
"255.255.255.0"
,
"--socks-server-addr"
,
"${DataStore.listenAddress}:${DataStore.portProxy}"
,
"--socks-server-addr"
,
"${DataStore.listenAddress}:${DataStore.portProxy}"
,
"--tunfd"
,
fd
.
toString
(),
"--tunmtu"
,
VPN_MTU
.
toString
(),
"--tunmtu"
,
VPN_MTU
.
toString
(),
"--sock-path"
,
"sock_path"
,
"--sock-path"
,
"sock_path"
,
"--dnsgw"
,
"127.0.0.1:${DataStore.portLocalDns}"
,
"--dnsgw"
,
"127.0.0.1:${DataStore.portLocalDns}"
,
"--loglevel"
,
"
3
"
)
"--loglevel"
,
"
warning
"
)
if
(
profile
.
ipv6
)
{
if
(
profile
.
ipv6
)
{
cmd
+=
"--netif-ip6addr"
cmd
+=
"--netif-ip6addr"
cmd
+=
PRIVATE_VLAN6_ROUTER
cmd
+=
PRIVATE_VLAN6_ROUTER
...
...
core/src/main/java/com/github/shadowsocks/database/Profile.kt
View file @
4dc4b4e2
...
@@ -54,7 +54,7 @@ data class Profile(
...
@@ -54,7 +54,7 @@ data class Profile(
var
password
:
String
=
"u1rRWTssNv0p"
,
var
password
:
String
=
"u1rRWTssNv0p"
,
var
method
:
String
=
"aes-256-cfb"
,
var
method
:
String
=
"aes-256-cfb"
,
var
route
:
String
=
"all"
,
var
route
:
String
=
"all"
,
var
remoteDns
:
String
=
"
8.8.8.8
"
,
var
remoteDns
:
String
=
"
dns.google
"
,
var
proxyApps
:
Boolean
=
false
,
var
proxyApps
:
Boolean
=
false
,
var
bypass
:
Boolean
=
false
,
var
bypass
:
Boolean
=
false
,
var
udpdns
:
Boolean
=
false
,
var
udpdns
:
Boolean
=
false
,
...
...
core/src/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
View file @
4dc4b4e2
...
@@ -76,7 +76,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
...
@@ -76,7 +76,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
private
val
job
=
SupervisorJob
()
private
val
job
=
SupervisorJob
()
override
val
coroutineContext
=
job
+
CoroutineExceptionHandler
{
_
,
t
->
printLog
(
t
)
}
override
val
coroutineContext
=
job
+
CoroutineExceptionHandler
{
_
,
t
->
printLog
(
t
)
}
suspend
fun
start
(
listen
:
SocketAddress
)
=
DatagramChannel
.
open
().
apply
{
suspend
fun
start
(
listen
:
SocketAddress
)
=
DatagramChannel
.
open
().
run
{
configureBlocking
(
false
)
configureBlocking
(
false
)
socket
().
bind
(
listen
)
socket
().
bind
(
listen
)
monitor
.
register
(
this
,
SelectionKey
.
OP_READ
)
{
handlePacket
(
this
)
}
monitor
.
register
(
this
,
SelectionKey
.
OP_READ
)
{
handlePacket
(
this
)
}
...
...
badvpn
@
e8660cfa
Subproject commit
ba4c45d6b4d30fd6b2557e92a770ccae12ec9257
Subproject commit
e8660cfae85762d3d3eaf72c47b8478f1c9f0e22
mobile/src/main/res/xml/pref_profile.xml
View file @
4dc4b4e2
...
@@ -49,11 +49,6 @@
...
@@ -49,11 +49,6 @@
android:entryValues=
"@array/route_value"
android:entryValues=
"@array/route_value"
android:summary=
"%s"
android:summary=
"%s"
android:title=
"@string/route_list"
/>
android:title=
"@string/route_list"
/>
<AutoSummaryEditTextPreference
android:key=
"remoteDns"
android:icon=
"@drawable/ic_action_dns"
android:title=
"@string/remote_dns"
app:pref_summaryHasText=
"%s"
/>
<SwitchPreference
<SwitchPreference
android:key=
"isIpv6"
android:key=
"isIpv6"
android:icon=
"@drawable/ic_image_looks_6"
android:icon=
"@drawable/ic_image_looks_6"
...
@@ -65,13 +60,17 @@
...
@@ -65,13 +60,17 @@
android:summary=
"@string/proxied_apps_summary"
android:summary=
"@string/proxied_apps_summary"
android:title=
"@string/proxied_apps"
/>
android:title=
"@string/proxied_apps"
/>
<SwitchPreference
<SwitchPreference
android:key=
"metered"
android:key=
"metered"
android:icon=
"@drawable/ic_device_data_usage"
android:icon=
"@drawable/ic_device_data_usage"
android:summary=
"@string/metered_summary"
android:summary=
"@string/metered_summary"
android:title=
"@string/metered"
/>
android:title=
"@string/metered"
/>
<AutoSummaryEditTextPreference
android:key=
"remoteDns"
android:icon=
"@drawable/ic_action_dns"
android:title=
"@string/remote_dns"
app:pref_summaryHasText=
"%s"
/>
<SwitchPreference
<SwitchPreference
android:key=
"isUdpDns"
android:key=
"isUdpDns"
android:icon=
"@drawable/ic_action_dns"
android:summary=
"@string/udp_dns_summary"
android:summary=
"@string/udp_dns_summary"
android:title=
"@string/udp_dns"
/>
android:title=
"@string/udp_dns"
/>
...
...
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