Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5bce2ca8b6 | ||
|
|
58c613b365 | ||
|
|
446a71db93 | ||
|
|
a3b2357d72 | ||
|
|
8d456e3d64 | ||
|
|
4ff77701be | ||
|
|
78e7175f7d | ||
|
|
0d03a09682 | ||
|
|
62745de01b | ||
|
|
bb81fe1339 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
resolvers += Resolver.url("scalasbt releases", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-snapshots"))(Resolver.ivyStylePatterns)
|
||||
|
||||
addSbtPlugin("com.hanhuy.sbt" % "android-sdk-plugin" % "1.5.1")
|
||||
addSbtPlugin("com.hanhuy.sbt" % "android-sdk-plugin" % "1.5.6")
|
||||
|
||||
resolvers += "Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||
|
||||
|
||||
@@ -1,102 +1,107 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.github.shadowsocks"
|
||||
android:versionCode="118"
|
||||
android:versionName="2.8.1">
|
||||
package="com.github.shadowsocks"
|
||||
android:versionCode="120"
|
||||
android:versionName="2.8.3">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_SUPERUSER"/>
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen"
|
||||
android:required="false"/>
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen"
|
||||
android:required="false"/>
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="16"
|
||||
android:targetSdkVersion="23"/>
|
||||
<uses-sdk
|
||||
android:minSdkVersion="16"
|
||||
android:targetSdkVersion="23"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:name=".ShadowsocksApplication"
|
||||
android:hardwareAccelerated="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:backupAgent=".ShadowsocksBackupAgent"
|
||||
android:label="@string/app_name">
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:name=".ShadowsocksApplication"
|
||||
android:hardwareAccelerated="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:backupAgent=".ShadowsocksBackupAgent"
|
||||
android:label="@string/app_name">
|
||||
|
||||
<meta-data android:name="com.google.android.gms.version"
|
||||
android:value="@integer/google_play_services_version"/>
|
||||
<meta-data android:name="com.google.android.backup.api_key"
|
||||
android:value="AEdPqrEAAAAI_zVxZthz2HDuz9toTvkYvL0L5GA-OjeUIfBeXg"/>
|
||||
<meta-data android:name="com.google.android.gms.version"
|
||||
android:value="@integer/google_play_services_version"/>
|
||||
<meta-data android:name="com.google.android.backup.api_key"
|
||||
android:value="AEdPqrEAAAAI_zVxZthz2HDuz9toTvkYvL0L5GA-OjeUIfBeXg"/>
|
||||
|
||||
<activity
|
||||
android:name="com.google.android.gms.ads.AdActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
|
||||
<activity
|
||||
android:name="com.google.android.gms.ads.AdActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
|
||||
|
||||
<activity
|
||||
android:name=".Shadowsocks"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.Shadowsocks"
|
||||
android:launchMode="singleTask">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".Shadowsocks"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.Shadowsocks"
|
||||
android:launchMode="singleTask">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ParserActivity"
|
||||
android:theme="@style/PopupTheme"
|
||||
android:launchMode="singleTask">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data android:scheme="ss"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ParserActivity"
|
||||
android:theme="@style/PopupTheme"
|
||||
android:launchMode="singleTask">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data android:scheme="ss"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ShadowsocksRunnerActivity"
|
||||
android:theme="@android:style/Theme.NoDisplay"
|
||||
android:launchMode="singleTask">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ShadowsocksRunnerActivity"
|
||||
android:theme="@android:style/Theme.NoDisplay"
|
||||
android:launchMode="singleTask">
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".AppManager"
|
||||
android:theme="@style/Theme.AppManager"
|
||||
android:label="@string/app_name"
|
||||
android:parentActivityName=".Shadowsocks">
|
||||
<intent-filter>
|
||||
<action android:name="com.github.shadowsocks.AppManager"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".AppManager"
|
||||
android:theme="@style/Theme.AppManager"
|
||||
android:label="@string/app_name"
|
||||
android:parentActivityName=".Shadowsocks">
|
||||
<intent-filter>
|
||||
<action android:name="com.github.shadowsocks.AppManager"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".ShadowsocksNatService"
|
||||
android:process=":nat"
|
||||
android:exported="false">
|
||||
</service>
|
||||
<service
|
||||
android:name=".ShadowsocksRunnerService"
|
||||
android:exported="false">
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".ShadowsocksVpnService"
|
||||
android:process=":vpn"
|
||||
android:label="@string/app_name"
|
||||
android:permission="android.permission.BIND_VPN_SERVICE"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.net.VpnService"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
<service
|
||||
android:name=".ShadowsocksNatService"
|
||||
android:process=":nat"
|
||||
android:exported="false">
|
||||
</service>
|
||||
|
||||
<receiver android:name=".ShadowsocksReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||
<action android:name="com.github.shadowsocks.ACTION_UPDATE_STATE"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<service
|
||||
android:name=".ShadowsocksVpnService"
|
||||
android:process=":vpn"
|
||||
android:label="@string/app_name"
|
||||
android:permission="android.permission.BIND_VPN_SERVICE"
|
||||
android:exported="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.net.VpnService"/>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
</application>
|
||||
<receiver android:name=".ShadowsocksReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED"/>
|
||||
<action android:name="com.github.shadowsocks.ACTION_UPDATE_STATE"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
||||
@@ -388,6 +388,8 @@
|
||||
<item>43.246.0.0/18</item>
|
||||
<item>43.246.64.0/19</item>
|
||||
<item>43.246.96.0/22</item>
|
||||
<item>43.246.212.0/22</item>
|
||||
<item>43.246.228.0/22</item>
|
||||
<item>43.247.4.0/22</item>
|
||||
<item>43.247.8.0/22</item>
|
||||
<item>43.247.44.0/22</item>
|
||||
@@ -655,6 +657,22 @@
|
||||
<item>45.125.96.0/21</item>
|
||||
<item>45.125.104.0/22</item>
|
||||
<item>45.125.136.0/22</item>
|
||||
<item>45.126.48.0/21</item>
|
||||
<item>45.126.100.0/22</item>
|
||||
<item>45.126.108.0/22</item>
|
||||
<item>45.126.112.0/21</item>
|
||||
<item>45.126.120.0/22</item>
|
||||
<item>45.126.212.0/22</item>
|
||||
<item>45.126.220.0/22</item>
|
||||
<item>45.127.8.0/21</item>
|
||||
<item>45.127.36.0/22</item>
|
||||
<item>45.127.96.0/22</item>
|
||||
<item>45.127.116.0/22</item>
|
||||
<item>45.127.124.0/22</item>
|
||||
<item>45.127.128.0/22</item>
|
||||
<item>45.127.144.0/21</item>
|
||||
<item>45.127.156.0/22</item>
|
||||
<item>45.127.216.0/22</item>
|
||||
<item>47.92.0.0/14</item>
|
||||
<item>47.96.0.0/11</item>
|
||||
<item>49.4.0.0/14</item>
|
||||
@@ -699,6 +717,7 @@
|
||||
<item>59.107.0.0/16</item>
|
||||
<item>59.108.0.0/14</item>
|
||||
<item>59.151.0.0/17</item>
|
||||
<item>59.153.4.0/22</item>
|
||||
<item>59.155.0.0/16</item>
|
||||
<item>59.172.0.0/14</item>
|
||||
<item>59.191.0.0/17</item>
|
||||
@@ -844,6 +863,7 @@
|
||||
<item>103.8.156.0/22</item>
|
||||
<item>103.8.200.0/21</item>
|
||||
<item>103.8.220.0/22</item>
|
||||
<item>103.9.8.0/22</item>
|
||||
<item>103.9.152.0/22</item>
|
||||
<item>103.9.248.0/21</item>
|
||||
<item>103.10.0.0/22</item>
|
||||
@@ -971,6 +991,8 @@
|
||||
<item>103.35.48.0/22</item>
|
||||
<item>103.35.104.0/22</item>
|
||||
<item>103.35.116.0/22</item>
|
||||
<item>103.35.200.0/22</item>
|
||||
<item>103.35.220.0/22</item>
|
||||
<item>103.36.20.0/22</item>
|
||||
<item>103.36.28.0/22</item>
|
||||
<item>103.36.36.0/22</item>
|
||||
@@ -1293,6 +1315,23 @@
|
||||
<item>103.193.240.0/22</item>
|
||||
<item>103.194.16.0/22</item>
|
||||
<item>103.194.230.0/23</item>
|
||||
<item>103.195.104.0/22</item>
|
||||
<item>103.195.112.0/22</item>
|
||||
<item>103.195.136.0/22</item>
|
||||
<item>103.195.148.0/22</item>
|
||||
<item>103.195.152.0/22</item>
|
||||
<item>103.195.160.0/22</item>
|
||||
<item>103.195.192.0/22</item>
|
||||
<item>103.196.60.0/22</item>
|
||||
<item>103.196.64.0/22</item>
|
||||
<item>103.196.72.0/22</item>
|
||||
<item>103.196.88.0/21</item>
|
||||
<item>103.196.96.0/22</item>
|
||||
<item>103.196.168.0/22</item>
|
||||
<item>103.196.184.0/22</item>
|
||||
<item>103.196.204.0/22</item>
|
||||
<item>103.197.180.0/22</item>
|
||||
<item>103.197.228.0/22</item>
|
||||
<item>103.224.40.0/21</item>
|
||||
<item>103.224.60.0/22</item>
|
||||
<item>103.224.80.0/22</item>
|
||||
@@ -1371,6 +1410,7 @@
|
||||
<item>103.234.128.0/22</item>
|
||||
<item>103.234.172.0/22</item>
|
||||
<item>103.234.180.0/22</item>
|
||||
<item>103.234.244.0/22</item>
|
||||
<item>103.235.16.0/22</item>
|
||||
<item>103.235.48.0/22</item>
|
||||
<item>103.235.56.0/21</item>
|
||||
@@ -1386,6 +1426,10 @@
|
||||
<item>103.236.64.0/19</item>
|
||||
<item>103.236.96.0/22</item>
|
||||
<item>103.236.120.0/22</item>
|
||||
<item>103.236.184.0/22</item>
|
||||
<item>103.236.220.0/22</item>
|
||||
<item>103.236.232.0/22</item>
|
||||
<item>103.236.240.0/20</item>
|
||||
<item>103.237.0.0/20</item>
|
||||
<item>103.237.24.0/21</item>
|
||||
<item>103.237.68.0/22</item>
|
||||
@@ -2156,6 +2200,7 @@
|
||||
<item>150.115.0.0/16</item>
|
||||
<item>150.121.0.0/16</item>
|
||||
<item>150.122.0.0/16</item>
|
||||
<item>150.129.136.0/22</item>
|
||||
<item>150.129.152.0/22</item>
|
||||
<item>150.129.192.0/22</item>
|
||||
<item>150.129.216.0/22</item>
|
||||
@@ -2598,6 +2643,8 @@
|
||||
<item>202.122.128.0/24</item>
|
||||
<item>202.122.132.0/24</item>
|
||||
<item>202.123.96.0/20</item>
|
||||
<item>202.123.116.0/22</item>
|
||||
<item>202.123.120.0/22</item>
|
||||
<item>202.124.16.0/21</item>
|
||||
<item>202.124.24.0/22</item>
|
||||
<item>202.125.112.0/20</item>
|
||||
@@ -2679,6 +2726,8 @@
|
||||
<item>202.172.0.0/22</item>
|
||||
<item>202.173.0.0/22</item>
|
||||
<item>202.173.8.0/21</item>
|
||||
<item>202.173.112.0/22</item>
|
||||
<item>202.173.120.0/22</item>
|
||||
<item>202.173.224.0/19</item>
|
||||
<item>202.174.64.0/20</item>
|
||||
<item>202.176.224.0/19</item>
|
||||
@@ -3698,6 +3747,7 @@
|
||||
<item>220.112.0.0/14</item>
|
||||
<item>220.152.128.0/17</item>
|
||||
<item>220.154.0.0/15</item>
|
||||
<item>220.158.240.0/22</item>
|
||||
<item>220.160.0.0/11</item>
|
||||
<item>220.192.0.0/12</item>
|
||||
<item>220.231.0.0/18</item>
|
||||
|
||||
@@ -178,7 +178,7 @@ class ShadowsocksNatService extends Service with BaseService {
|
||||
|
||||
val conf = ConfigUtils
|
||||
.SHADOWSOCKS.formatLocal(Locale.ENGLISH, config.proxy, config.remotePort, config.localPort,
|
||||
config.sitekey, config.encMethod, 10)
|
||||
config.sitekey, config.encMethod, 600)
|
||||
ConfigUtils.printToFile(new File(Path.BASE + "ss-local-nat.conf"))(p => {
|
||||
p.println(conf)
|
||||
})
|
||||
|
||||
@@ -65,10 +65,15 @@ class ShadowsocksReceiver extends BroadcastReceiver {
|
||||
val isAutoConnect: Boolean = settings.getBoolean(Key.isAutoConnect, false)
|
||||
val isInstalled: Boolean = status.getBoolean(versionName, false)
|
||||
if (isAutoConnect && isInstalled) {
|
||||
val intent = new Intent(context, classOf[ShadowsocksRunnerActivity])
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
context.startActivity(intent)
|
||||
if (Utils.isLollipopOrAbove) {
|
||||
val intent = new Intent(context, classOf[ShadowsocksRunnerService])
|
||||
context.startService(intent)
|
||||
} else {
|
||||
val intent = new Intent(context, classOf[ShadowsocksRunnerActivity])
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Shadowsocks - A shadowsocks client for Android
|
||||
* Copyright (C) 2014 <max.c.lv@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*
|
||||
* ___====-_ _-====___
|
||||
* _--^^^#####// \\#####^^^--_
|
||||
* _-^##########// ( ) \\##########^-_
|
||||
* -############// |\^^/| \\############-
|
||||
* _/############// (@::@) \\############\_
|
||||
* /#############(( \\// ))#############\
|
||||
* -###############\\ (oo) //###############-
|
||||
* -#################\\ / VV \ //#################-
|
||||
* -###################\\/ \//###################-
|
||||
* _#/|##########/\######( /\ )######/\##########|\#_
|
||||
* |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
|
||||
* ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
|
||||
* ` ` ` ` / | | | | \ ' ' ' '
|
||||
* ( | | | | )
|
||||
* __\ | | | | /__
|
||||
* (vvv(VVV)(VVV)vvv)
|
||||
*
|
||||
* HERE BE DRAGONS
|
||||
*
|
||||
*/
|
||||
|
||||
package com.github.shadowsocks
|
||||
|
||||
import android.app.Service
|
||||
import android.content._
|
||||
import android.net.VpnService
|
||||
import android.os._
|
||||
import android.preference.PreferenceManager
|
||||
import com.github.shadowsocks.aidl.IShadowsocksService
|
||||
import com.github.shadowsocks.utils._
|
||||
|
||||
class ShadowsocksRunnerService extends Service {
|
||||
|
||||
private lazy val settings = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
private lazy val status = getSharedPreferences(Key.status, Context.MODE_PRIVATE)
|
||||
|
||||
val handler = new Handler()
|
||||
val connection = new ServiceConnection {
|
||||
override def onServiceConnected(name: ComponentName, service: IBinder) {
|
||||
bgService = IShadowsocksService.Stub.asInterface(service)
|
||||
handler.postDelayed(() => if (bgService != null) startBackgroundService(), 1000)
|
||||
}
|
||||
override def onServiceDisconnected(name: ComponentName) {
|
||||
bgService = null
|
||||
}
|
||||
}
|
||||
|
||||
// Variables
|
||||
var vpnEnabled = -1
|
||||
var bgService: IShadowsocksService = null
|
||||
|
||||
def isVpnEnabled: Boolean = {
|
||||
if (vpnEnabled < 0) {
|
||||
vpnEnabled = if ((!Utils.isLollipopOrAbove || status.getBoolean(Key.isNAT, false)) && Console.isRoot) {
|
||||
0
|
||||
} else {
|
||||
1
|
||||
}
|
||||
}
|
||||
if (vpnEnabled == 1) true else false
|
||||
}
|
||||
|
||||
override def onBind(intent: Intent): IBinder = {
|
||||
null
|
||||
}
|
||||
|
||||
def startBackgroundService() {
|
||||
if (isVpnEnabled) {
|
||||
val intent = VpnService.prepare(ShadowsocksRunnerService.this)
|
||||
if (intent == null) {
|
||||
if (bgService != null) {
|
||||
bgService.start(ConfigUtils.load(settings))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bgService.start(ConfigUtils.load(settings))
|
||||
}
|
||||
stopSelf()
|
||||
}
|
||||
|
||||
def attachService() {
|
||||
if (bgService == null) {
|
||||
val s = if (!isVpnEnabled) classOf[ShadowsocksNatService] else classOf[ShadowsocksVpnService]
|
||||
val intent = new Intent(this, s)
|
||||
intent.setAction(Action.SERVICE)
|
||||
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||
startService(new Intent(this, s))
|
||||
}
|
||||
}
|
||||
|
||||
def deattachService() {
|
||||
if (bgService != null) {
|
||||
unbindService(connection)
|
||||
bgService = null
|
||||
}
|
||||
}
|
||||
|
||||
override def onCreate() {
|
||||
super.onCreate()
|
||||
attachService()
|
||||
}
|
||||
|
||||
override def onDestroy() {
|
||||
super.onDestroy()
|
||||
deattachService()
|
||||
}
|
||||
}
|
||||
@@ -68,10 +68,10 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
val PRIVATE_VLAN = "26.26.26.%s"
|
||||
val PRIVATE_VLAN6 = "fdfe:dcba:9876::%s"
|
||||
var conn: ParcelFileDescriptor = null
|
||||
var receiver: BroadcastReceiver = null
|
||||
var apps: Array[ProxiedApp] = null
|
||||
var config: Config = null
|
||||
var vpnThread: ShadowsocksVpnThread = null
|
||||
var closeReceiver: BroadcastReceiver = null
|
||||
|
||||
def isByass(net: SubnetUtils): Boolean = {
|
||||
val info = net.getInfo
|
||||
@@ -171,10 +171,10 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
stopSelf()
|
||||
}
|
||||
|
||||
// clean up the context
|
||||
if (receiver != null) {
|
||||
unregisterReceiver(receiver)
|
||||
receiver = null
|
||||
// clean up recevier
|
||||
if (closeReceiver != null) {
|
||||
unregisterReceiver(closeReceiver)
|
||||
closeReceiver = null
|
||||
}
|
||||
|
||||
// channge the state
|
||||
@@ -211,6 +211,16 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
|
||||
config = c
|
||||
|
||||
// register close receiver
|
||||
val filter = new IntentFilter()
|
||||
filter.addAction(Intent.ACTION_SHUTDOWN)
|
||||
filter.addAction(Action.CLOSE)
|
||||
closeReceiver = (context: Context, intent: Intent) => {
|
||||
Toast.makeText(context, R.string.stopping, Toast.LENGTH_SHORT).show()
|
||||
stopRunner()
|
||||
}
|
||||
registerReceiver(closeReceiver, filter)
|
||||
|
||||
// ensure the VPNService is prepared
|
||||
if (VpnService.prepare(this) != null) {
|
||||
val i = new Intent(this, classOf[ShadowsocksRunnerActivity])
|
||||
@@ -226,15 +236,6 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
.setLabel(getVersionName)
|
||||
.build())
|
||||
|
||||
// register close receiver
|
||||
val filter = new IntentFilter()
|
||||
filter.addAction(Intent.ACTION_SHUTDOWN)
|
||||
receiver = (p1: Context, p2: Intent) => {
|
||||
Toast.makeText(p1, R.string.stopping, Toast.LENGTH_SHORT)
|
||||
stopRunner()
|
||||
}
|
||||
registerReceiver(receiver, filter)
|
||||
|
||||
changeState(State.CONNECTING)
|
||||
|
||||
Future {
|
||||
@@ -317,7 +318,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
|
||||
val conf = ConfigUtils
|
||||
.SHADOWSOCKS.formatLocal(Locale.ENGLISH, config.proxy, config.remotePort, config.localPort,
|
||||
config.sitekey, config.encMethod, 10)
|
||||
config.sitekey, config.encMethod, 600)
|
||||
ConfigUtils.printToFile(new File(Path.BASE + "ss-local-vpn.conf"))(p => {
|
||||
p.println(conf)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user