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
0f24d7c0
Commit
0f24d7c0
authored
Oct 09, 2016
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cloud based ACL updating
parent
bbf61448
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
47 additions
and
33 deletions
+47
-33
build.sbt
build.sbt
+5
-0
project/plugins.sbt
project/plugins.sbt
+2
-0
src/main/res/xml/pref_all.xml
src/main/res/xml/pref_all.xml
+0
-3
src/main/scala/com/github/shadowsocks/BaseService.scala
src/main/scala/com/github/shadowsocks/BaseService.scala
+30
-0
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+0
-9
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
.../scala/com/github/shadowsocks/ShadowsocksNatService.scala
+5
-2
src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala
...in/scala/com/github/shadowsocks/ShadowsocksSettings.scala
+0
-6
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+5
-0
src/main/scala/com/github/shadowsocks/utils/Utils.scala
src/main/scala/com/github/shadowsocks/utils/Utils.scala
+0
-13
No files found.
build.sbt
View file @
0f24d7c0
...
...
@@ -30,6 +30,8 @@ resolvers += Resolver.jcenterRepo
useSupportVectors
googleServicesSettings
libraryDependencies
++=
Seq
(
"com.android.support"
%
"design"
%
"24.2.1"
,
"com.android.support"
%
"gridlayout-v7"
%
"24.2.1"
,
...
...
@@ -39,6 +41,8 @@ libraryDependencies ++= Seq(
"com.github.kevinsawicki"
%
"http-request"
%
"6.0"
,
"com.google.android.gms"
%
"play-services-ads"
%
"9.6.1"
,
"com.google.android.gms"
%
"play-services-analytics"
%
"9.6.1"
,
"com.google.firebase"
%
"firebase-core"
%
"9.6.1"
,
"com.google.firebase"
%
"firebase-storage"
%
"9.6.1"
,
"com.j256.ormlite"
%
"ormlite-android"
%
"5.0"
,
"com.twofortyfouram"
%
"android-plugin-api-for-locale"
%
"1.0.2"
,
"dnsjava"
%
"dnsjava"
%
"2.1.7"
,
...
...
@@ -52,6 +56,7 @@ proguardVersion in Android := "5.3"
proguardCache
in
Android
:=
Seq
()
proguardOptions
in
Android
++=
Seq
(
"-keepattributes Signature"
,
"-keep class com.github.shadowsocks.System { *; }"
,
"-dontwarn com.google.android.gms.internal.**"
,
"-dontwarn com.j256.ormlite.**"
,
...
...
project/plugins.sbt
View file @
0f24d7c0
addSbtPlugin
(
"org.scala-android"
%
"sbt-android"
%
"1.6.18"
)
addSbtPlugin
(
"org.scala-android"
%
"sbt-android-gms"
%
"0.2"
)
addSbtPlugin
(
"com.timushev.sbt"
%
"sbt-updates"
%
"0.1.10"
)
addSbtPlugin
(
"net.virtual-void"
%
"sbt-dependency-graph"
%
"0.8.2"
)
src/main/res/xml/pref_all.xml
View file @
0f24d7c0
...
...
@@ -121,9 +121,6 @@
android:summary=
"@string/nat_summary"
/>
<Preference
android:key=
"recovery"
android:title=
"@string/recovery"
android:summary=
"@string/recovery_summary"
/>
<Preference
android:key=
"flush_dnscache"
android:title=
"@string/flush_dnscache"
android:summary=
"@string/flush_dnscache_summary"
/>
<Preference
android:key=
"about"
android:title=
"@string/about"
/>
</be.mygod.preference.PreferenceCategory>
...
...
src/main/scala/com/github/shadowsocks/BaseService.scala
View file @
0f24d7c0
...
...
@@ -39,6 +39,7 @@
package
com.github.shadowsocks
import
java.io.File
import
java.io.IOException
import
java.util.
{
Timer
,
TimerTask
}
...
...
@@ -55,6 +56,10 @@ import com.github.shadowsocks.utils._
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.database.Profile
import
com.google.firebase.FirebaseApp
import
com.google.firebase.storage.FileDownloadTask
import
com.google.firebase.storage.FirebaseStorage
trait
BaseService
extends
Service
{
@volatile
private
var
state
=
State
.
STOPPED
...
...
@@ -276,6 +281,7 @@ trait BaseService extends Service {
override
def
onCreate
()
{
super
.
onCreate
()
FirebaseApp
.
initializeApp
(
this
)
app
.
refreshContainerHolder
}
...
...
@@ -311,4 +317,28 @@ trait BaseService extends Service {
case
ex
:
Exception
=>
"exclude = "
+
default
+
";"
}
}
def
getAcl
(
route
:
String
)
{
val
localAcl
=
route
match
{
case
Route
.
BYPASS_LAN
=>
"bypass_lan.acl"
case
Route
.
BYPASS_CHN
=>
"bypass_chn.acl"
case
Route
.
BYPASS_LAN_CHN
=>
"bypass_lan_chn.acl"
case
Route
.
GFWLIST
=>
"gfwlist.acl"
case
Route
.
CHINALIST
=>
"chinalist.acl"
}
val
cloudAclFile
=
new
File
(
getApplicationInfo
.
dataDir
+
"/"
+
localAcl
)
if
(!
cloudAclFile
.
exists
)
cloudAclFile
.
createNewFile
val
tempFile
=
File
.
createTempFile
(
localAcl
,
"acl"
)
val
storage
=
FirebaseStorage
.
getInstance
val
storageRef
=
storage
.
getReferenceFromUrl
(
"gs://admob-app-id-3330146721.appspot.com/acl/"
)
val
aclRef
=
storageRef
.
child
(
localAcl
)
val
task
=
aclRef
.
getFile
(
tempFile
)
task
.
addOnSuccessListener
((
_
)
=>
{
tempFile
.
renameTo
(
cloudAclFile
)
return
})
task
.
addOnFailureListener
((
_
)
=>
Log
.
e
(
"shadowsocks"
,
"Unable to download "
+
localAcl
))
tempFile
.
deleteOnExit
()
}
}
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
0f24d7c0
...
...
@@ -545,15 +545,6 @@ class Shadowsocks extends AppCompatActivity with ServiceBoundContext {
}
}
def
flushDnsCache
()
{
val
h
=
showProgress
(
R
.
string
.
flushing
)
Utils
.
ThrowableFuture
{
if
(!
Utils
.
toggleAirplaneMode
(
getBaseContext
))
h
.
post
(()
=>
Snackbar
.
make
(
findViewById
(
android
.
R
.
id
.
content
),
R
.
string
.
flush_dnscache_no_root
,
Snackbar
.
LENGTH_LONG
).
show
)
h
.
sendEmptyMessage
(
0
)
}
}
override
def
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
)
=
resultCode
match
{
case
Activity
.
RESULT_OK
=>
serviceLoad
()
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
View file @
0f24d7c0
...
...
@@ -96,6 +96,7 @@ class ShadowsocksNatService extends BaseService {
if
(
profile
.
route
!=
Route
.
ALL
)
{
cmd
+=
"--acl"
profile
.
route
match
{
case
Route
.
BYPASS_LAN
=>
cmd
+=
(
getApplicationInfo
.
dataDir
+
"/bypass_lan.acl"
)
case
Route
.
BYPASS_CHN
=>
cmd
+=
(
getApplicationInfo
.
dataDir
+
"/bypass_chn.acl"
)
...
...
@@ -336,8 +337,10 @@ class ShadowsocksNatService extends BaseService {
}
handleConnection
()
// Set DNS
su
.
addCommand
(
Utils
.
FLUSH_DNS
)
// lazily get ACL from cloud
getAcl
(
profile
.
route
)
changeState
(
State
.
CONNECTED
)
notification
=
new
ShadowsocksNotification
(
this
,
profile
.
name
,
true
)
}
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala
View file @
0f24d7c0
...
...
@@ -170,12 +170,6 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
true
})
findPreference
(
"flush_dnscache"
).
setOnPreferenceClickListener
(
_
=>
{
app
.
track
(
TAG
,
"flush_dnscache"
)
activity
.
flushDnsCache
()
true
})
findPreference
(
"about"
).
setOnPreferenceClickListener
((
preference
:
Preference
)
=>
{
app
.
track
(
TAG
,
"about"
)
val
web
=
new
WebView
(
activity
)
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
0f24d7c0
...
...
@@ -162,6 +162,10 @@ class ShadowsocksVpnService extends VpnService with BaseService {
handleConnection
()
changeState
(
State
.
CONNECTED
)
// lazily get ACL from cloud
getAcl
(
profile
.
route
)
notification
=
new
ShadowsocksNotification
(
this
,
profile
.
name
)
}
...
...
@@ -257,6 +261,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
if
(
profile
.
route
!=
Route
.
ALL
)
{
cmd
+=
"--acl"
profile
.
route
match
{
case
Route
.
BYPASS_LAN
=>
cmd
+=
(
getApplicationInfo
.
dataDir
+
"/bypass_lan.acl"
)
case
Route
.
BYPASS_CHN
=>
cmd
+=
(
getApplicationInfo
.
dataDir
+
"/bypass_chn.acl"
)
...
...
src/main/scala/com/github/shadowsocks/utils/Utils.scala
View file @
0f24d7c0
...
...
@@ -169,19 +169,6 @@ object Utils {
result
}
// Because /sys/class/net/* isn't accessible since API level 24
final
val
FLUSH_DNS
=
"for if in /sys/class/net/*; do "
+
"if [ \"down\" != $(cat $if/operstate) ]; then "
+
// up or unknown
"ndc resolver flushif ${if##*/}; "
+
"fi "
+
"done; echo done"
// Blocked > 3 seconds
def
toggleAirplaneMode
(
context
:
Context
)
=
{
val
result
=
Shell
.
SU
.
run
(
FLUSH_DNS
)
result
!=
null
&&
!
result
.
isEmpty
}
def
resolve
(
host
:
String
,
addrType
:
Int
)
:
Option
[
String
]
=
{
try
{
val
lookup
=
new
Lookup
(
host
,
addrType
)
...
...
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