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
b05adbdd
Commit
b05adbdd
authored
Nov 09, 2015
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove redundant Global Proxy
parent
58c16704
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
122 additions
and
124 deletions
+122
-124
src/main/AndroidManifest.xml
src/main/AndroidManifest.xml
+3
-9
src/main/aidl/com/github/shadowsocks/aidl/Config.java
src/main/aidl/com/github/shadowsocks/aidl/Config.java
+6
-14
src/main/res/layout/layout_apps.xml
src/main/res/layout/layout_apps.xml
+45
-25
src/main/res/layout/layout_apps_item.xml
src/main/res/layout/layout_apps_item.xml
+1
-1
src/main/res/values-zh/strings.xml
src/main/res/values-zh/strings.xml
+1
-3
src/main/res/values/strings.xml
src/main/res/values/strings.xml
+1
-3
src/main/res/xml/pref_all.xml
src/main/res/xml/pref_all.xml
+3
-11
src/main/scala/com/github/shadowsocks/AppManager.scala
src/main/scala/com/github/shadowsocks/AppManager.scala
+7
-1
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
+10
-7
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
.../scala/com/github/shadowsocks/ShadowsocksNatService.scala
+2
-2
src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala
...in/scala/com/github/shadowsocks/ShadowsocksSettings.scala
+14
-1
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
.../scala/com/github/shadowsocks/ShadowsocksVpnService.scala
+1
-1
src/main/scala/com/github/shadowsocks/database/DBHelper.scala
...main/scala/com/github/shadowsocks/database/DBHelper.scala
+19
-9
src/main/scala/com/github/shadowsocks/database/Profile.scala
src/main/scala/com/github/shadowsocks/database/Profile.scala
+1
-19
src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
...cala/com/github/shadowsocks/database/ProfileManager.scala
+2
-6
src/main/scala/com/github/shadowsocks/utils/ConfigUtils.scala
...main/scala/com/github/shadowsocks/utils/ConfigUtils.scala
+5
-8
src/main/scala/com/github/shadowsocks/utils/Constants.scala
src/main/scala/com/github/shadowsocks/utils/Constants.scala
+1
-4
No files found.
src/main/AndroidManifest.xml
View file @
b05adbdd
...
...
@@ -64,7 +64,7 @@
<activity
android:name=
".ProfileManagerActivity"
android:label=
"@string/
app_name
"
android:label=
"@string/
profiles
"
android:parentActivityName=
".Shadowsocks"
android:exported=
"false"
>
<intent-filter>
...
...
@@ -75,14 +75,8 @@
<activity
android:name=
".AppManager"
android:label=
"@string/app_name"
android:parentActivityName=
".Shadowsocks"
android:exported=
"false"
>
<intent-filter>
<action
android:name=
"com.github.shadowsocks.AppManager"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
</intent-filter>
</activity>
android:label=
"@string/proxied_apps"
android:parentActivityName=
".Shadowsocks"
/>
<service
android:name=
".ShadowsocksRunnerService"
...
...
src/main/aidl/com/github/shadowsocks/aidl/Config.java
View file @
b05adbdd
...
...
@@ -5,10 +5,8 @@ import android.os.Parcelable;
public
class
Config
implements
Parcelable
{
public
boolean
isGlobalProxy
=
true
;
public
boolean
isGFWList
=
true
;
public
boolean
isProxyApps
=
false
;
public
boolean
isBypassApps
=
false
;
public
boolean
isTrafficStat
=
false
;
public
boolean
isUdpDns
=
false
;
public
boolean
isAuth
=
false
;
public
boolean
isIpv6
=
false
;
...
...
@@ -34,13 +32,11 @@ public class Config implements Parcelable {
}
};
public
Config
(
boolean
is
GlobalProxy
,
boolean
isGFWList
,
boolean
isBypassApps
,
boolean
is
TrafficStat
,
boolean
is
UdpDns
,
boolean
isAuth
,
boolean
isIpv6
,
String
profileName
,
String
proxy
,
String
sitekey
,
public
Config
(
boolean
is
ProxyApps
,
boolean
isBypassApps
,
boolean
isUdpDns
,
boolean
isAuth
,
boolean
isIpv6
,
String
profileName
,
String
proxy
,
String
sitekey
,
String
encMethod
,
String
proxiedAppString
,
String
route
,
int
remotePort
,
int
localPort
)
{
this
.
isGlobalProxy
=
isGlobalProxy
;
this
.
isGFWList
=
isGFWList
;
this
.
isProxyApps
=
isProxyApps
;
this
.
isBypassApps
=
isBypassApps
;
this
.
isTrafficStat
=
isTrafficStat
;
this
.
isUdpDns
=
isUdpDns
;
this
.
isAuth
=
isAuth
;
this
.
isIpv6
=
isIpv6
;
...
...
@@ -59,10 +55,8 @@ public class Config implements Parcelable {
}
public
void
readFromParcel
(
Parcel
in
)
{
isGlobalProxy
=
in
.
readInt
()
==
1
;
isGFWList
=
in
.
readInt
()
==
1
;
isProxyApps
=
in
.
readInt
()
==
1
;
isBypassApps
=
in
.
readInt
()
==
1
;
isTrafficStat
=
in
.
readInt
()
==
1
;
isUdpDns
=
in
.
readInt
()
==
1
;
isAuth
=
in
.
readInt
()
==
1
;
isIpv6
=
in
.
readInt
()
==
1
;
...
...
@@ -81,10 +75,8 @@ public class Config implements Parcelable {
}
@Override
public
void
writeToParcel
(
Parcel
out
,
int
flags
)
{
out
.
writeInt
(
isGlobalProxy
?
1
:
0
);
out
.
writeInt
(
isGFWList
?
1
:
0
);
out
.
writeInt
(
isProxyApps
?
1
:
0
);
out
.
writeInt
(
isBypassApps
?
1
:
0
);
out
.
writeInt
(
isTrafficStat
?
1
:
0
);
out
.
writeInt
(
isUdpDns
?
1
:
0
);
out
.
writeInt
(
isAuth
?
1
:
0
);
out
.
writeInt
(
isIpv6
?
1
:
0
);
...
...
src/main/res/layout/layout_apps.xml
View file @
b05adbdd
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"fill_parent"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
android:orientation=
"vertical"
android:duplicateParentState=
"false"
>
<include
layout=
"@layout/toolbar_light_dark"
/>
<LinearLayout
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:paddingBottom=
"8dp"
android:paddingLeft=
"48dp"
android:paddingStart=
"48dp"
android:paddingTop=
"8dp"
android:background=
"@android:color/white"
android:elevation=
"1dp"
tools:ignore=
"RtlSymmetry"
>
<TextView
android:id=
"@+id/bypassLabel"
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"wrap_content"
android:padding=
"3dp"
android:gravity=
"center_vertical"
android:textSize=
"18sp"
android:text=
"@string/bypass_apps"
/>
<LinearLayout
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:paddingLeft=
"40dp"
android:paddingStart=
"40dp"
android:elevation=
"1dp"
android:background=
"@android:color/white"
android:orientation=
"vertical"
tools:ignore=
"RtlSymmetry"
>
<LinearLayout
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"8dp"
>
<TextView
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"wrap_content"
android:padding=
"3dp"
android:gravity=
"center_vertical"
android:textSize=
"18sp"
android:text=
"@string/on"
/>
<Switch
android:checked=
"true"
android:id=
"@+id/onSwitch"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"8dp"
>
<TextView
android:id=
"@+id/bypassLabel"
android:layout_width=
"0dp"
android:layout_weight=
"1"
android:layout_height=
"wrap_content"
android:padding=
"3dp"
android:gravity=
"center_vertical"
android:textSize=
"18sp"
android:text=
"@string/bypass_apps"
/>
<Switch
android:id=
"@+id/bypassSwitch"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"6dp"
android:layout_marginRight=
"6dp"
/>
<Switch
android:id=
"@+id/bypassSwitch"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
</LinearLayout>
<FrameLayout
android:layout_width=
"fill_parent"
android:layout_height=
"0dp"
...
...
src/main/res/layout/layout_apps_item.xml
View file @
b05adbdd
...
...
@@ -28,7 +28,7 @@
android:id=
"@+id/itemcheck"
android:layout_width=
"wrap_content"
android:layout_height=
"fill_parent"
android:layout_marginRight=
"
6
dp"
/>
android:layout_marginRight=
"
8
dp"
/>
</TableRow>
</TableLayout>
src/main/res/values-zh/strings.xml
View file @
b05adbdd
...
...
@@ -25,11 +25,9 @@
<string
name=
"auto_set_gfwlist"
>
国内路由
</string>
<string
name=
"auto_set_gfwlist_summary"
>
绕过所有位于中国的网站
</string>
<string
name=
"route_list"
>
路由
</string>
<string
name=
"auto_set_proxy"
>
全局代理
</string>
<string
name=
"auto_set_proxy_summary"
>
设置系统代理
</string>
<string
name=
"proxied_apps"
>
分应用代理
</string>
<string
name=
"proxied_apps_summary"
>
为应用程序分别设置代理
</string>
<string
name=
"
proxied_help"
>
分应用代理
</string>
<string
name=
"
on"
>
开
</string>
<string
name=
"bypass_apps"
>
绕行模式
</string>
<string
name=
"bypass_apps_summary"
>
启用该选项,以使所选应用程序的流量不经过代理
</string>
<string
name=
"auto_connect"
>
自动连接
</string>
...
...
src/main/res/values/strings.xml
View file @
b05adbdd
...
...
@@ -40,11 +40,9 @@
<string
name=
"auto_set_gfwlist_summary"
>
Bypass all sites located in China
</string>
<string
name=
"route_list"
>
Route
</string>
<string
name=
"auto_set_proxy"
>
Global Proxy
</string>
<string
name=
"auto_set_proxy_summary"
>
Set up system-wide proxy
</string>
<string
name=
"proxied_apps"
>
Per-App Proxy
</string>
<string
name=
"proxied_apps_summary"
>
Set proxy for selected apps
</string>
<string
name=
"
proxied_help"
>
Per-App Proxy
</string>
<string
name=
"
on"
>
On
</string>
<string
name=
"bypass_apps"
>
Bypass Mode
</string>
<string
name=
"bypass_apps_summary"
>
Enable this option to bypass selected apps
</string>
<string
name=
"auto_connect"
>
Auto Connect
</string>
...
...
src/main/res/xml/pref_all.xml
View file @
b05adbdd
...
...
@@ -77,18 +77,10 @@
android:summary=
"@string/ipv6_summary"
android:title=
"@string/ipv6"
/>
<SwitchPreference
android:defaultValue=
"true"
android:key=
"isGlobalProxy"
android:disableDependentsState=
"true"
android:summary=
"@string/auto_set_proxy_summary"
android:title=
"@string/auto_set_proxy"
/>
<Preference
android:key=
"proxyedApps"
android:dependency=
"isGlobalProxy"
android:key=
"isProxyApps"
android:defaultValue=
"false"
android:summary=
"@string/proxied_apps_summary"
android:title=
"@string/proxied_apps"
>
<intent
android:action=
"com.github.shadowsocks.AppManager"
/>
</Preference>
android:title=
"@string/proxied_apps"
/>
<SwitchPreference
android:key=
"isUdpDns"
android:defaultValue=
"false"
...
...
src/main/scala/com/github/shadowsocks/AppManager.scala
View file @
b05adbdd
...
...
@@ -252,7 +252,7 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
this
.
setContentView
(
R
.
layout
.
layout_apps
)
val
toolbar
=
findViewById
(
R
.
id
.
toolbar
).
asInstanceOf
[
Toolbar
]
toolbar
.
setTitle
(
R
.
string
.
proxied_
help
)
toolbar
.
setTitle
(
R
.
string
.
proxied_
apps
)
toolbar
.
setNavigationIcon
(
R
.
drawable
.
abc_ic_ab_back_mtrl_am_alpha
)
toolbar
.
setNavigationOnClickListener
((
v
:
View
)
=>
{
val
intent
=
getParentActivityIntent
...
...
@@ -268,6 +268,12 @@ class AppManager extends AppCompatActivity with OnCheckedChangeListener with OnC
WindowManager
.
LayoutParams
.
FLAG_NOT_FOCUSABLE
|
WindowManager
.
LayoutParams
.
FLAG_NOT_TOUCHABLE
,
PixelFormat
.
TRANSLUCENT
))
findViewById
(
R
.
id
.
onSwitch
).
asInstanceOf
[
Switch
]
.
setOnCheckedChangeListener
((
button
:
CompoundButton
,
checked
:
Boolean
)
=>
{
ShadowsocksApplication
.
settings
.
edit
().
putBoolean
(
Key
.
isProxyApps
,
checked
).
apply
()
finish
()
})
val
bypassSwitch
=
findViewById
(
R
.
id
.
bypassSwitch
).
asInstanceOf
[
Switch
]
bypassSwitch
.
setOnCheckedChangeListener
((
button
:
CompoundButton
,
checked
:
Boolean
)
=>
ShadowsocksApplication
.
settings
.
edit
().
putBoolean
(
Key
.
isBypassApps
,
checked
).
apply
())
...
...
src/main/scala/com/github/shadowsocks/Shadowsocks.scala
View file @
b05adbdd
...
...
@@ -60,7 +60,7 @@ import android.widget._
import
com.github.jorgecastilloprz.FABProgressCircle
import
com.github.shadowsocks.aidl.
{
IShadowsocksService
,
IShadowsocksServiceCallback
}
import
com.github.shadowsocks.database._
import
com.github.shadowsocks.preferences.
{
DropDownPreference
,
PasswordEditTextPreference
,
SummaryEditTextPreference
}
import
com.github.shadowsocks.preferences.
{
NumberPickerPreference
,
DropDownPreference
,
PasswordEditTextPreference
,
SummaryEditTextPreference
}
import
com.github.shadowsocks.utils._
import
com.google.android.gms.ads.
{
AdRequest
,
AdSize
,
AdView
}
...
...
@@ -98,7 +98,7 @@ object Shadowsocks {
val
PREFS_NAME
=
"Shadowsocks"
val
PROXY_PREFS
=
Array
(
Key
.
profileName
,
Key
.
proxy
,
Key
.
remotePort
,
Key
.
localPort
,
Key
.
sitekey
,
Key
.
encMethod
,
Key
.
isAuth
)
val
FEATURE_PREFS
=
Array
(
Key
.
route
,
Key
.
is
GlobalProxy
,
Key
.
proxyed
Apps
,
Key
.
isUdpDns
,
Key
.
isIpv6
)
val
FEATURE_PREFS
=
Array
(
Key
.
route
,
Key
.
is
Proxy
Apps
,
Key
.
isUdpDns
,
Key
.
isIpv6
)
val
EXECUTABLES
=
Array
(
Executable
.
PDNSD
,
Executable
.
REDSOCKS
,
Executable
.
SS_TUNNEL
,
Executable
.
SS_LOCAL
,
Executable
.
TUN2SOCKS
)
...
...
@@ -112,6 +112,10 @@ object Shadowsocks {
pref
.
asInstanceOf
[
PasswordEditTextPreference
].
setText
(
value
)
}
def
updateNumberPickerPreference
(
pref
:
Preference
,
value
:
Int
)
:
Unit
=
{
pref
.
asInstanceOf
[
NumberPickerPreference
].
setValue
(
value
)
}
def
updateSummaryEditTextPreference
(
pref
:
Preference
,
value
:
String
)
{
pref
.
setSummary
(
value
)
pref
.
asInstanceOf
[
SummaryEditTextPreference
].
setText
(
value
)
...
...
@@ -125,12 +129,12 @@ object Shadowsocks {
name
match
{
case
Key
.
profileName
=>
updateSummaryEditTextPreference
(
pref
,
profile
.
name
)
case
Key
.
proxy
=>
updateSummaryEditTextPreference
(
pref
,
profile
.
host
)
case
Key
.
remotePort
=>
update
SummaryEditTextPreference
(
pref
,
profile
.
remotePort
.
toString
)
case
Key
.
localPort
=>
update
SummaryEditTextPreference
(
pref
,
profile
.
localPort
.
toString
)
case
Key
.
remotePort
=>
update
NumberPickerPreference
(
pref
,
profile
.
remotePort
)
case
Key
.
localPort
=>
update
NumberPickerPreference
(
pref
,
profile
.
localPort
)
case
Key
.
sitekey
=>
updatePasswordEditTextPreference
(
pref
,
profile
.
password
)
case
Key
.
encMethod
=>
updateDropDownPreference
(
pref
,
profile
.
method
)
case
Key
.
route
=>
updateDropDownPreference
(
pref
,
profile
.
route
)
case
Key
.
is
GlobalProxy
=>
updateSwitchPreference
(
pref
,
profile
.
global
)
case
Key
.
is
ProxyApps
=>
updateSwitchPreference
(
pref
,
profile
.
proxyApps
)
case
Key
.
isUdpDns
=>
updateSwitchPreference
(
pref
,
profile
.
udpdns
)
case
Key
.
isAuth
=>
updateSwitchPreference
(
pref
,
profile
.
auth
)
case
Key
.
isIpv6
=>
updateSwitchPreference
(
pref
,
profile
.
ipv6
)
...
...
@@ -501,8 +505,7 @@ class Shadowsocks
for
(
name
<-
Shadowsocks
.
FEATURE_PREFS
)
{
val
pref
=
preferences
.
findPreference
(
name
)
if
(
pref
!=
null
)
{
if
(
Seq
(
Key
.
isGlobalProxy
,
Key
.
proxyedApps
)
.
contains
(
name
))
{
if
(
name
==
Key
.
isProxyApps
)
{
pref
.
setEnabled
(
enabled
&&
(
Utils
.
isLollipopOrAbove
||
!
ShadowsocksApplication
.
isVpnEnabled
))
}
else
{
pref
.
setEnabled
(
enabled
)
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksNatService.scala
View file @
b05adbdd
...
...
@@ -390,10 +390,10 @@ class ShadowsocksNatService extends Service with BaseService {
init_sb
.
append
(
Utils
.
getIptables
+
" -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination 127.0.0.1:"
+
8153
)
if
(
config
.
isGlobalProxy
||
config
.
isBypassApps
)
{
if
(
!
config
.
isProxyApps
||
config
.
isBypassApps
)
{
http_sb
.
append
(
Utils
.
getIptables
+
CMD_IPTABLES_DNAT_ADD_SOCKS
)
}
if
(
!
config
.
isGlobalProxy
)
{
if
(
config
.
isProxyApps
)
{
if
(
apps
==
null
||
apps
.
length
<=
0
)
{
apps
=
AppManager
.
getProxiedApps
(
this
,
config
.
proxiedAppString
)
}
...
...
src/main/scala/com/github/shadowsocks/ShadowsocksSettings.scala
View file @
b05adbdd
...
...
@@ -6,7 +6,7 @@ import android.app.AlertDialog
import
android.content.
{
DialogInterface
,
Intent
}
import
android.net.Uri
import
android.os.
{
Build
,
Bundle
}
import
android.preference.
{
Preference
,
PreferenceFragment
}
import
android.preference.
{
SwitchPreference
,
Preference
,
PreferenceFragment
}
import
android.webkit.
{
WebViewClient
,
WebView
}
import
com.github.shadowsocks.utils.Key
...
...
@@ -14,10 +14,18 @@ import com.github.shadowsocks.utils.Key
class
ShadowsocksSettings
extends
PreferenceFragment
{
private
lazy
val
activity
=
getActivity
.
asInstanceOf
[
Shadowsocks
]
private
var
isProxyApps
:
SwitchPreference
=
_
override
def
onCreate
(
savedInstanceState
:
Bundle
)
{
super
.
onCreate
(
savedInstanceState
)
addPreferencesFromResource
(
R
.
xml
.
pref_all
)
isProxyApps
=
findPreference
(
Key
.
isProxyApps
).
asInstanceOf
[
SwitchPreference
]
isProxyApps
.
setOnPreferenceChangeListener
((
preference
:
Preference
,
newValue
:
Any
)
=>
{
startActivity
(
new
Intent
(
activity
,
classOf
[
AppManager
]))
newValue
.
asInstanceOf
[
Boolean
]
// keep it ON
})
findPreference
(
Key
.
isNAT
).
setOnPreferenceChangeListener
((
preference
:
Preference
,
newValue
:
Any
)
=>
if
(
ShadowsocksApplication
.
isRoot
)
activity
.
handler
.
post
(()
=>
{
activity
.
deattachService
()
...
...
@@ -62,4 +70,9 @@ class ShadowsocksSettings extends PreferenceFragment {
true
})
}
override
def
onResume
=
{
super
.
onResume
isProxyApps
.
setChecked
(
ShadowsocksApplication
.
settings
.
getBoolean
(
Key
.
isProxyApps
,
false
))
// update
}
}
src/main/scala/com/github/shadowsocks/ShadowsocksVpnService.scala
View file @
b05adbdd
...
...
@@ -394,7 +394,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
if
(
Utils
.
isLollipopOrAbove
)
{
if
(
!
config
.
isGlobalProxy
)
{
if
(
config
.
isProxyApps
)
{
val
apps
=
AppManager
.
getProxiedApps
(
this
,
config
.
proxiedAppString
)
val
pkgSet
:
mutable.HashSet
[
String
]
=
new
mutable
.
HashSet
[
String
]
for
(
app
<-
apps
)
{
...
...
src/main/scala/com/github/shadowsocks/database/DBHelper.scala
View file @
b05adbdd
...
...
@@ -39,19 +39,19 @@
package
com.github.shadowsocks.database
import
com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper
import
android.content.Context
import
android.database.sqlite.SQLiteDatabase
import
com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper
import
com.j256.ormlite.dao.Dao
import
com.j256.ormlite.support.ConnectionSource
import
com.j256.ormlite.table.TableUtils
import
com.j256.ormlite.dao.Dao
object
DBHelper
{
val
PROFILE
=
"profile.db"
}
class
DBHelper
(
val
context
:
Context
)
extends
OrmLiteSqliteOpenHelper
(
context
,
DBHelper
.
PROFILE
,
null
,
1
1
)
{
extends
OrmLiteSqliteOpenHelper
(
context
,
DBHelper
.
PROFILE
,
null
,
1
2
)
{
lazy
val
profileDao
:
Dao
[
Profile
,
Int
]
=
getDao
(
classOf
[
Profile
])
...
...
@@ -63,21 +63,31 @@ class DBHelper(val context: Context)
newVersion
:
Int
)
{
if
(
oldVersion
!=
newVersion
)
{
if
(
oldVersion
<
7
)
{
profileDao
.
executeRaw
(
"DROP TABLE IF EXISTS 'profile';"
)
profileDao
.
executeRaw
NoArgs
(
"DROP TABLE IF EXISTS 'profile';"
)
onCreate
(
database
,
connectionSource
)
}
else
{
if
(
oldVersion
<
8
)
{
profileDao
.
executeRaw
(
"ALTER TABLE `profile` ADD COLUMN udpdns SMALLINT;"
)
profileDao
.
executeRaw
(
"ALTER TABLE `profile` ADD COLUMN route VARCHAR;"
)
profileDao
.
executeRaw
NoArgs
(
"ALTER TABLE `profile` ADD COLUMN udpdns SMALLINT;"
)
profileDao
.
executeRaw
NoArgs
(
"ALTER TABLE `profile` ADD COLUMN route VARCHAR;"
)
}
if
(
oldVersion
<
9
)
{
profileDao
.
executeRaw
(
"ALTER TABLE `profile` ADD COLUMN route VARCHAR;"
)
profileDao
.
executeRaw
NoArgs
(
"ALTER TABLE `profile` ADD COLUMN route VARCHAR;"
)
}
if
(
oldVersion
<
10
)
{
profileDao
.
executeRaw
(
"ALTER TABLE `profile` ADD COLUMN auth SMALLINT;"
)
profileDao
.
executeRaw
NoArgs
(
"ALTER TABLE `profile` ADD COLUMN auth SMALLINT;"
)
}
if
(
oldVersion
<
11
)
{
profileDao
.
executeRaw
(
"ALTER TABLE `profile` ADD COLUMN ipv6 SMALLINT;"
)
profileDao
.
executeRawNoArgs
(
"ALTER TABLE `profile` ADD COLUMN ipv6 SMALLINT;"
)
}
if
(
oldVersion
<
12
)
{
profileDao
.
executeRawNoArgs
(
"ALTER TABLE `profile` RENAME TO `tmp`;"
)
onCreate
(
database
,
connectionSource
)
profileDao
.
executeRawNoArgs
(
"INSERT INTO `profile`(id, name, host, localPort, remotePort, password, method, route, proxyApps, bypass,"
+
" udpdns, auth, ipv6, individual) "
+
"SELECT id, name, host, localPort, remotePort, password, method, route, 1 - global, bypass, udpdns, auth,"
+
" ipv6, individual FROM `tmp`;"
)
profileDao
.
executeRawNoArgs
(
"DROP TABLE `tmp`;"
)
}
}
}
...
...
src/main/scala/com/github/shadowsocks/database/Profile.scala
View file @
b05adbdd
...
...
@@ -63,30 +63,15 @@ class Profile {
@DatabaseField
var
method
:
String
=
"rc4"
@DatabaseField
var
date
:
String
=
""
@DatabaseField
var
route
:
String
=
"all"
@DatabaseField
var
upload
:
Int
=
0
@DatabaseField
var
download
:
Int
=
0
@DatabaseField
var
chnroute
:
Boolean
=
true
@DatabaseField
var
global
:
Boolean
=
true
var
proxyApps
:
Boolean
=
false
@DatabaseField
var
bypass
:
Boolean
=
false
@DatabaseField
var
traffic
:
Boolean
=
false
@DatabaseField
var
udpdns
:
Boolean
=
false
...
...
@@ -98,7 +83,4 @@ class Profile {
@DatabaseField
(
dataType
=
DataType
.
LONG_STRING
)
var
individual
:
String
=
""
@DatabaseField
(
dataType
=
DataType
.
LONG_STRING
)
var
description
:
String
=
""
}
src/main/scala/com/github/shadowsocks/database/ProfileManager.scala
View file @
b05adbdd
...
...
@@ -117,10 +117,8 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
}
val
edit
=
settings
.
edit
()
edit
.
putBoolean
(
Key
.
isGlobalProxy
,
profile
.
global
)
edit
.
putBoolean
(
Key
.
isGFWList
,
profile
.
chnroute
)
edit
.
putBoolean
(
Key
.
isProxyApps
,
profile
.
proxyApps
)
edit
.
putBoolean
(
Key
.
isBypassApps
,
profile
.
bypass
)
edit
.
putBoolean
(
Key
.
isTrafficStat
,
profile
.
traffic
)
edit
.
putBoolean
(
Key
.
isUdpDns
,
profile
.
udpdns
)
edit
.
putBoolean
(
Key
.
isAuth
,
profile
.
auth
)
edit
.
putBoolean
(
Key
.
isIpv6
,
profile
.
ipv6
)
...
...
@@ -143,10 +141,8 @@ class ProfileManager(settings: SharedPreferences, dbHelper: DBHelper) {
profile
.
id
=
settings
.
getInt
(
Key
.
profileId
,
-
1
)
profile
.
global
=
settings
.
getBoolean
(
Key
.
isGlobalProxy
,
false
)
profile
.
chnroute
=
settings
.
getBoolean
(
Key
.
isGFWList
,
false
)
profile
.
proxyApps
=
settings
.
getBoolean
(
Key
.
isProxyApps
,
false
)
profile
.
bypass
=
settings
.
getBoolean
(
Key
.
isBypassApps
,
false
)
profile
.
traffic
=
settings
.
getBoolean
(
Key
.
isTrafficStat
,
false
)
profile
.
udpdns
=
settings
.
getBoolean
(
Key
.
isUdpDns
,
false
)
profile
.
auth
=
settings
.
getBoolean
(
Key
.
isAuth
,
false
)
profile
.
ipv6
=
settings
.
getBoolean
(
Key
.
isIpv6
,
false
)
...
...
src/main/scala/com/github/shadowsocks/utils/ConfigUtils.scala
View file @
b05adbdd
...
...
@@ -241,16 +241,13 @@ object ConfigUtils {
val
password
=
proxy
(
2
).
trim
val
method
=
proxy
(
3
).
trim
new
Config
(
config
.
isGlobalProxy
,
config
.
isGFWList
,
config
.
isBypassApps
,
config
.
isTrafficStat
,
config
.
isUdpDns
,
config
.
isAuth
,
config
.
isIpv6
,
config
.
profileName
,
host
,
password
,
method
,
config
.
proxiedAppString
,
config
.
route
,
port
,
config
.
localPort
)
new
Config
(
config
.
isProxyApps
,
config
.
isBypassApps
,
config
.
isUdpDns
,
config
.
isAuth
,
config
.
isIpv6
,
config
.
profileName
,
host
,
password
,
method
,
config
.
proxiedAppString
,
config
.
route
,
port
,
config
.
localPort
)
}
def
load
(
settings
:
SharedPreferences
)
:
Config
=
{
val
isGlobalProxy
=
settings
.
getBoolean
(
Key
.
isGlobalProxy
,
false
)
val
isGFWList
=
settings
.
getBoolean
(
Key
.
isGFWList
,
false
)
val
isProxyApps
=
settings
.
getBoolean
(
Key
.
isProxyApps
,
false
)
val
isBypassApps
=
settings
.
getBoolean
(
Key
.
isBypassApps
,
false
)
val
isTrafficStat
=
settings
.
getBoolean
(
Key
.
isTrafficStat
,
false
)
val
isUdpDns
=
settings
.
getBoolean
(
Key
.
isUdpDns
,
false
)
val
isAuth
=
settings
.
getBoolean
(
Key
.
isAuth
,
false
)
val
isIpv6
=
settings
.
getBoolean
(
Key
.
isIpv6
,
false
)
...
...
@@ -265,7 +262,7 @@ object ConfigUtils {
val
localPort
=
settings
.
getInt
(
Key
.
localPort
,
1984
)
val
proxiedAppString
=
settings
.
getString
(
Key
.
proxied
,
""
)
new
Config
(
is
GlobalProxy
,
isGFWList
,
isBypassApps
,
isTrafficStat
,
isUdpDns
,
isAuth
,
isIpv6
,
profileName
,
proxy
,
sitekey
,
encMethod
,
proxiedAppString
,
route
,
remotePort
,
localPort
)
new
Config
(
is
ProxyApps
,
isBypassApps
,
isUdpDns
,
isAuth
,
isIpv6
,
profileName
,
proxy
,
sitekey
,
encMethod
,
proxiedAppString
,
route
,
remotePort
,
localPort
)
}
}
src/main/scala/com/github/shadowsocks/utils/Constants.scala
View file @
b05adbdd
...
...
@@ -67,16 +67,13 @@ object Key {
val
profiles
=
"profiles"
val
isNAT
=
"isNAT"
val
proxyedApps
=
"proxyedApps"
val
route
=
"route"
val
isRunning
=
"isRunning"
val
isAutoConnect
=
"isAutoConnect"
val
isGlobalProxy
=
"isGlobalProxy"
val
isGFWList
=
"isGFWList"
val
isProxyApps
=
"isProxyApps"
val
isBypassApps
=
"isBypassApps"
val
isTrafficStat
=
"isTrafficStat"
val
isUdpDns
=
"isUdpDns"
val
isAuth
=
"isAuth"
val
isIpv6
=
"isIpv6"
...
...
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