clean up
This commit is contained in:
@@ -141,8 +141,9 @@ class ShadowVpnService extends VpnService {
|
||||
val cmd: String = (BASE +
|
||||
"shadowsocks -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" -m \"%s\" -f " +
|
||||
BASE +
|
||||
"shadowsocks.pid").format(config.proxy, config.remotePort, config.localPort,
|
||||
config.sitekey, config.encMethod)
|
||||
"shadowsocks.pid")
|
||||
.format(config.proxy, config.remotePort, config.localPort, config.sitekey,
|
||||
config.encMethod)
|
||||
Log.d(TAG, cmd)
|
||||
System.exec(cmd)
|
||||
}
|
||||
@@ -188,7 +189,8 @@ class ShadowVpnService extends VpnService {
|
||||
|
||||
// Resolve server address
|
||||
var resolved: Boolean = false
|
||||
if (!InetAddressUtils.isIPv4Address(config.proxy) && !InetAddressUtils.isIPv6Address(config.proxy)) {
|
||||
if (!InetAddressUtils.isIPv4Address(config.proxy) &&
|
||||
!InetAddressUtils.isIPv6Address(config.proxy)) {
|
||||
Utils.resolve(config.proxy, enableIPv6 = true) match {
|
||||
case Some(addr) =>
|
||||
config.proxy = addr
|
||||
@@ -313,7 +315,8 @@ class ShadowVpnService extends VpnService {
|
||||
+ "--socks-server-addr 127.0.0.1:%d "
|
||||
+ "--tunfd %d "
|
||||
+ "--tunmtu %d "
|
||||
+ "--pid %stun2socks.pid").format(localAddress.format(2), udpgw, config.localPort, fd, VPN_MTU, BASE)
|
||||
+ "--pid %stun2socks.pid")
|
||||
.format(localAddress.format(2), udpgw, config.localPort, fd, VPN_MTU, BASE)
|
||||
Log.d(TAG, cmd)
|
||||
System.exec(cmd)
|
||||
}
|
||||
|
||||
@@ -163,8 +163,9 @@ class ShadowsocksService extends Service {
|
||||
val cmd: String = (BASE +
|
||||
"shadowsocks -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" -m \"%s\" -f " +
|
||||
BASE +
|
||||
"shadowsocks.pid").format(config.proxy, config.remotePort, config.localPort,
|
||||
config.sitekey, config.encMethod)
|
||||
"shadowsocks.pid")
|
||||
.format(config.proxy, config.remotePort, config.localPort, config.sitekey,
|
||||
config.encMethod)
|
||||
Log.d(TAG, cmd)
|
||||
System.exec(cmd)
|
||||
}
|
||||
@@ -217,7 +218,8 @@ class ShadowsocksService extends Service {
|
||||
killProcesses()
|
||||
|
||||
var resolved: Boolean = false
|
||||
if (!InetAddressUtils.isIPv4Address(config.proxy) && !InetAddressUtils.isIPv6Address(config.proxy)) {
|
||||
if (!InetAddressUtils.isIPv4Address(config.proxy) &&
|
||||
!InetAddressUtils.isIPv6Address(config.proxy)) {
|
||||
Utils.resolve(config.proxy, enableIPv6 = true) match {
|
||||
case Some(a) =>
|
||||
config.proxy = a
|
||||
|
||||
@@ -70,16 +70,8 @@ object Key {
|
||||
val localPort = "port"
|
||||
}
|
||||
|
||||
case class Config (
|
||||
isGlobalProxy: Boolean,
|
||||
isGFWList: Boolean,
|
||||
isBypassApps: Boolean,
|
||||
var proxy: String,
|
||||
sitekey: String,
|
||||
encMethod: String,
|
||||
remotePort: Int,
|
||||
localPort: Int
|
||||
)
|
||||
case class Config(isGlobalProxy: Boolean, isGFWList: Boolean, isBypassApps: Boolean,
|
||||
var proxy: String, sitekey: String, encMethod: String, remotePort: Int, localPort: Int)
|
||||
|
||||
object State {
|
||||
val INIT = 0
|
||||
@@ -114,18 +106,18 @@ object Extra {
|
||||
edit.apply()
|
||||
}
|
||||
|
||||
def get(intent: Intent): Config = {
|
||||
def get(intent: Intent): Config = {
|
||||
val isGlobalProxy = intent.getBooleanExtra(Key.isGlobalProxy, false)
|
||||
val isGFWList = intent.getBooleanExtra(Key.isGFWList, false)
|
||||
val isBypassApps = intent.getBooleanExtra(Key.isBypassApps, false)
|
||||
val proxy = intent.getStringExtra(Key.proxy)
|
||||
val sitekey = intent.getStringExtra(Key.sitekey)
|
||||
val encMethod = intent.getStringExtra(Key.encMethod)
|
||||
val sitekey = intent.getStringExtra(Key.sitekey)
|
||||
val encMethod = intent.getStringExtra(Key.encMethod)
|
||||
val remotePort = intent.getIntExtra(Key.remotePort, 1984)
|
||||
val localPort = intent.getIntExtra(Key.localPort, 1984)
|
||||
|
||||
new Config(isGlobalProxy, isGFWList, isBypassApps,
|
||||
proxy, sitekey, encMethod, remotePort, localPort)
|
||||
new Config(isGlobalProxy, isGFWList, isBypassApps, proxy, sitekey, encMethod, remotePort,
|
||||
localPort)
|
||||
}
|
||||
|
||||
def put(settings: SharedPreferences, intent: Intent) {
|
||||
@@ -192,7 +184,9 @@ object Utils {
|
||||
def isServiceStarted(name: String, context: Context): Boolean = {
|
||||
import scala.collection.JavaConversions._
|
||||
|
||||
val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE).asInstanceOf[ActivityManager]
|
||||
val activityManager = context
|
||||
.getSystemService(Context.ACTIVITY_SERVICE)
|
||||
.asInstanceOf[ActivityManager]
|
||||
val services = activityManager.getRunningServices(Integer.MAX_VALUE)
|
||||
|
||||
for (service <- services) {
|
||||
|
||||
Reference in New Issue
Block a user