Bump version
This commit is contained in:
@@ -262,7 +262,7 @@ class Shadowsocks
|
||||
} else {
|
||||
in = assetManager.open(file)
|
||||
}
|
||||
out = new FileOutputStream(Path.BASE + file)
|
||||
out = new FileOutputStream(getApplicationInfo().dataDir + "/" + file)
|
||||
copyFile(in, out)
|
||||
in.close()
|
||||
in = null
|
||||
@@ -292,8 +292,8 @@ class Shadowsocks
|
||||
val cmd = new ArrayBuffer[String]()
|
||||
|
||||
for (task <- Array("ss-local", "ss-tunnel", "pdnsd", "redsocks", "tun2socks")) {
|
||||
cmd.append("chmod 666 %s%s-nat.pid".formatLocal(Locale.ENGLISH, Path.BASE, task))
|
||||
cmd.append("chmod 666 %s%s-vpn.pid".formatLocal(Locale.ENGLISH, Path.BASE, task))
|
||||
cmd.append("chmod 666 %s/%s-nat.pid".formatLocal(Locale.ENGLISH, getApplicationInfo().dataDir, task))
|
||||
cmd.append("chmod 666 %s/%s-vpn.pid".formatLocal(Locale.ENGLISH, getApplicationInfo().dataDir, task))
|
||||
}
|
||||
|
||||
if (ShadowsocksApplication.isVpnEnabled) {
|
||||
@@ -306,8 +306,8 @@ class Shadowsocks
|
||||
|
||||
for (task <- Array("ss-local", "ss-tunnel", "pdnsd", "redsocks", "tun2socks")) {
|
||||
try {
|
||||
val pid_nat = scala.io.Source.fromFile(Path.BASE + task + "-nat.pid").mkString.trim.toInt
|
||||
val pid_vpn = scala.io.Source.fromFile(Path.BASE + task + "-vpn.pid").mkString.trim.toInt
|
||||
val pid_nat = scala.io.Source.fromFile(getApplicationInfo().dataDir + "/" + task + "-nat.pid").mkString.trim.toInt
|
||||
val pid_vpn = scala.io.Source.fromFile(getApplicationInfo().dataDir + "/" + task + "-vpn.pid").mkString.trim.toInt
|
||||
cmd.append("kill -9 %d".formatLocal(Locale.ENGLISH, pid_nat))
|
||||
cmd.append("kill -9 %d".formatLocal(Locale.ENGLISH, pid_vpn))
|
||||
Process.killProcess(pid_nat)
|
||||
@@ -315,10 +315,10 @@ class Shadowsocks
|
||||
} catch {
|
||||
case e: Throwable => // Ignore
|
||||
}
|
||||
cmd.append("rm -f %s%s-nat.pid".formatLocal(Locale.ENGLISH, Path.BASE, task))
|
||||
cmd.append("rm -f %s%s-nat.conf".formatLocal(Locale.ENGLISH, Path.BASE, task))
|
||||
cmd.append("rm -f %s%s-vpn.pid".formatLocal(Locale.ENGLISH, Path.BASE, task))
|
||||
cmd.append("rm -f %s%s-vpn.conf".formatLocal(Locale.ENGLISH, Path.BASE, task))
|
||||
cmd.append("rm -f %s/%s-nat.pid".formatLocal(Locale.ENGLISH, getApplicationInfo().dataDir, task))
|
||||
cmd.append("rm -f %s/%s-nat.conf".formatLocal(Locale.ENGLISH, getApplicationInfo().dataDir, task))
|
||||
cmd.append("rm -f %s/%s-vpn.pid".formatLocal(Locale.ENGLISH, getApplicationInfo().dataDir, task))
|
||||
cmd.append("rm -f %s/%s-vpn.conf".formatLocal(Locale.ENGLISH, getApplicationInfo().dataDir, task))
|
||||
}
|
||||
if (ShadowsocksApplication.isVpnEnabled) Console.runCommand(cmd.toArray) else {
|
||||
Console.runRootCommand(cmd.toArray)
|
||||
@@ -502,7 +502,7 @@ class Shadowsocks
|
||||
|
||||
val ab = new ArrayBuffer[String]
|
||||
for (executable <- Shadowsocks.EXECUTABLES) {
|
||||
ab.append("chmod 755 " + Path.BASE + executable)
|
||||
ab.append("chmod 755 " + getApplicationInfo().dataDir + "/" + executable)
|
||||
}
|
||||
Console.runCommand(ab.toArray)
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ object ShadowsocksApplication {
|
||||
lazy val tracker = GoogleAnalytics.getInstance(instance).newTracker(R.xml.tracker)
|
||||
lazy val settings = PreferenceManager.getDefaultSharedPreferences(instance)
|
||||
lazy val profileManager = new ProfileManager(settings, dbHelper)
|
||||
lazy val dataDir = instance.getApplicationInfo().dataDir
|
||||
|
||||
def isVpnEnabled = !settings.getBoolean(Key.isNAT, false)
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ class ShadowsocksNatService extends BaseService {
|
||||
case Route.BYPASS_LAN => getResources.getStringArray(R.array.private_route)
|
||||
case Route.BYPASS_CHN => getResources.getStringArray(R.array.chn_route_full)
|
||||
}
|
||||
ConfigUtils.printToFile(new File(Path.BASE + "acl.list"))(p => {
|
||||
ConfigUtils.printToFile(new File(getApplicationInfo().dataDir + "/acl.list"))(p => {
|
||||
acl.foreach(item => p.println(item))
|
||||
})
|
||||
}
|
||||
@@ -176,21 +176,21 @@ class ShadowsocksNatService extends BaseService {
|
||||
val conf = ConfigUtils
|
||||
.SHADOWSOCKS.formatLocal(Locale.ENGLISH, config.proxy, config.remotePort, config.localPort,
|
||||
config.sitekey, config.encMethod, 600)
|
||||
ConfigUtils.printToFile(new File(Path.BASE + "ss-local-nat.conf"))(p => {
|
||||
ConfigUtils.printToFile(new File(getApplicationInfo().dataDir + "/ss-local-nat.conf"))(p => {
|
||||
p.println(conf)
|
||||
})
|
||||
|
||||
val cmd = new ArrayBuffer[String]
|
||||
cmd += (Path.BASE + "ss-local"
|
||||
cmd += (getApplicationInfo().dataDir + "/ss-local"
|
||||
, "-b" , "127.0.0.1"
|
||||
, "-t" , "600"
|
||||
, "-c" , Path.BASE + "ss-local-nat.conf")
|
||||
, "-c" , getApplicationInfo().dataDir + "/ss-local-nat.conf")
|
||||
|
||||
if (config.isAuth) cmd += "-A"
|
||||
|
||||
if (config.route != Route.ALL) {
|
||||
cmd += "--acl"
|
||||
cmd += (Path.BASE + "acl.list")
|
||||
cmd += (getApplicationInfo().dataDir + "/acl.list")
|
||||
}
|
||||
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" "))
|
||||
@@ -205,16 +205,16 @@ class ShadowsocksNatService extends BaseService {
|
||||
val conf = ConfigUtils
|
||||
.SHADOWSOCKS.formatLocal(Locale.ENGLISH, config.proxy, config.remotePort, 8153,
|
||||
config.sitekey, config.encMethod, 10)
|
||||
ConfigUtils.printToFile(new File(Path.BASE + "ss-tunnel-nat.conf"))(p => {
|
||||
ConfigUtils.printToFile(new File(getApplicationInfo().dataDir + "/ss-tunnel-nat.conf"))(p => {
|
||||
p.println(conf)
|
||||
})
|
||||
val cmd = new ArrayBuffer[String]
|
||||
cmd += (Path.BASE + "ss-tunnel"
|
||||
cmd += (getApplicationInfo().dataDir + "/ss-tunnel"
|
||||
, "-u"
|
||||
, "-t" , "10"
|
||||
, "-b" , "127.0.0.1"
|
||||
, "-L" , "8.8.8.8:53"
|
||||
, "-c" , Path.BASE + "ss-tunnel-nat.conf")
|
||||
, "-c" , getApplicationInfo().dataDir + "/ss-tunnel-nat.conf")
|
||||
|
||||
cmd += ("-l" , "8153")
|
||||
|
||||
@@ -231,17 +231,17 @@ class ShadowsocksNatService extends BaseService {
|
||||
val conf = ConfigUtils
|
||||
.SHADOWSOCKS.formatLocal(Locale.ENGLISH, config.proxy, config.remotePort, 8163,
|
||||
config.sitekey, config.encMethod, 10)
|
||||
ConfigUtils.printToFile(new File(Path.BASE + "ss-tunnel-nat.conf"))(p => {
|
||||
ConfigUtils.printToFile(new File(getApplicationInfo().dataDir + "/ss-tunnel-nat.conf"))(p => {
|
||||
p.println(conf)
|
||||
})
|
||||
val cmdBuf = new ArrayBuffer[String]
|
||||
cmdBuf += (Path.BASE + "ss-tunnel"
|
||||
cmdBuf += (getApplicationInfo().dataDir + "/ss-tunnel"
|
||||
, "-u"
|
||||
, "-t" , "10"
|
||||
, "-b" , "127.0.0.1"
|
||||
, "-l" , "8163"
|
||||
, "-L" , "8.8.8.8:53"
|
||||
, "-c" , Path.BASE + "ss-tunnel-nat.conf")
|
||||
, "-c" , getApplicationInfo().dataDir + "/ss-tunnel-nat.conf")
|
||||
|
||||
if (config.isAuth) cmdBuf += "-A"
|
||||
|
||||
@@ -266,10 +266,10 @@ class ShadowsocksNatService extends BaseService {
|
||||
8163, "")
|
||||
}
|
||||
|
||||
ConfigUtils.printToFile(new File(Path.BASE + "pdnsd-nat.conf"))(p => {
|
||||
ConfigUtils.printToFile(new File(getApplicationInfo().dataDir + "/pdnsd-nat.conf"))(p => {
|
||||
p.println(conf)
|
||||
})
|
||||
val cmd = Path.BASE + "pdnsd -c " + Path.BASE + "pdnsd-nat.conf"
|
||||
val cmd = getApplicationInfo().dataDir + "/pdnsd -c " + getApplicationInfo().dataDir + "/pdnsd-nat.conf"
|
||||
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, cmd)
|
||||
|
||||
@@ -293,9 +293,9 @@ class ShadowsocksNatService extends BaseService {
|
||||
|
||||
def startRedsocksDaemon() {
|
||||
val conf = ConfigUtils.REDSOCKS.formatLocal(Locale.ENGLISH, config.localPort)
|
||||
val cmd = Path.BASE + "redsocks -c %sredsocks-nat.conf"
|
||||
.formatLocal(Locale.ENGLISH, Path.BASE, Path.BASE)
|
||||
ConfigUtils.printToFile(new File(Path.BASE + "redsocks-nat.conf"))(p => {
|
||||
val cmd = "%s/redsocks -c %s/redsocks-nat.conf"
|
||||
.formatLocal(Locale.ENGLISH, getApplicationInfo().dataDir, getApplicationInfo().dataDir)
|
||||
ConfigUtils.printToFile(new File(getApplicationInfo().dataDir + "/redsocks-nat.conf"))(p => {
|
||||
p.println(conf)
|
||||
})
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
var tries = 1
|
||||
while (tries < 5) {
|
||||
Thread.sleep(1000 * tries)
|
||||
if (System.sendfd(fd) != -1) {
|
||||
if (System.sendfd(fd, getApplicationInfo().dataDir + "/sock_path") != -1) {
|
||||
return true
|
||||
}
|
||||
tries += 1
|
||||
@@ -277,7 +277,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
case Route.BYPASS_LAN => getResources.getStringArray(R.array.private_route)
|
||||
case Route.BYPASS_CHN => getResources.getStringArray(R.array.chn_route_full)
|
||||
}
|
||||
ConfigUtils.printToFile(new File(Path.BASE + "acl.list"))(p => {
|
||||
ConfigUtils.printToFile(new File(getApplicationInfo().dataDir + "/acl.list"))(p => {
|
||||
acl.foreach(item => p.println(item))
|
||||
})
|
||||
}
|
||||
@@ -285,21 +285,22 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
val conf = ConfigUtils
|
||||
.SHADOWSOCKS.formatLocal(Locale.ENGLISH, config.proxy, config.remotePort, config.localPort,
|
||||
config.sitekey, config.encMethod, 600)
|
||||
ConfigUtils.printToFile(new File(Path.BASE + "ss-local-vpn.conf"))(p => {
|
||||
ConfigUtils.printToFile(new File(getApplicationInfo().dataDir + "/ss-local-vpn.conf"))(p => {
|
||||
p.println(conf)
|
||||
})
|
||||
|
||||
val cmd = new ArrayBuffer[String]
|
||||
cmd += (Path.BASE + "ss-local", "-V", "-u"
|
||||
cmd += (getApplicationInfo().dataDir + "/ss-local", "-V", "-u"
|
||||
, "-b", "127.0.0.1"
|
||||
, "-t", "600"
|
||||
, "-c", Path.BASE + "ss-local-vpn.conf")
|
||||
, "-P", ShadowsocksApplication.dataDir
|
||||
, "-c", getApplicationInfo().dataDir + "/ss-local-vpn.conf")
|
||||
|
||||
if (config.isAuth) cmd += "-A"
|
||||
|
||||
if (config.route != Route.ALL) {
|
||||
cmd += "--acl"
|
||||
cmd += (Path.BASE + "acl.list")
|
||||
cmd += (getApplicationInfo().dataDir + "/acl.list")
|
||||
}
|
||||
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" "))
|
||||
@@ -314,18 +315,19 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
val conf = ConfigUtils
|
||||
.SHADOWSOCKS.formatLocal(Locale.ENGLISH, config.proxy, config.remotePort, 8163,
|
||||
config.sitekey, config.encMethod, 10)
|
||||
ConfigUtils.printToFile(new File(Path.BASE + "ss-tunnel-vpn.conf"))(p => {
|
||||
ConfigUtils.printToFile(new File(getApplicationInfo().dataDir + "/ss-tunnel-vpn.conf"))(p => {
|
||||
p.println(conf)
|
||||
})
|
||||
val cmd = new ArrayBuffer[String]
|
||||
cmd += (Path.BASE + "ss-tunnel"
|
||||
cmd += (getApplicationInfo().dataDir + "/ss-tunnel"
|
||||
, "-V"
|
||||
, "-u"
|
||||
, "-t", "10"
|
||||
, "-b", "127.0.0.1"
|
||||
, "-l", "8163"
|
||||
, "-L", "8.8.8.8:53"
|
||||
, "-c", Path.BASE + "ss-tunnel-vpn.conf")
|
||||
, "-P", ShadowsocksApplication.dataDir
|
||||
, "-c", getApplicationInfo().dataDir + "/ss-tunnel-vpn.conf")
|
||||
|
||||
if (config.isAuth) cmd += "-A"
|
||||
|
||||
@@ -350,10 +352,10 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
8163, ipv6)
|
||||
}
|
||||
}
|
||||
ConfigUtils.printToFile(new File(Path.BASE + "pdnsd-vpn.conf"))(p => {
|
||||
ConfigUtils.printToFile(new File(getApplicationInfo().dataDir + "/pdnsd-vpn.conf"))(p => {
|
||||
p.println(conf)
|
||||
})
|
||||
val cmd = Path.BASE + "pdnsd -c " + Path.BASE + "pdnsd-vpn.conf"
|
||||
val cmd = getApplicationInfo().dataDir + "/pdnsd -c " + getApplicationInfo().dataDir + "/pdnsd-vpn.conf"
|
||||
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, cmd)
|
||||
|
||||
@@ -428,16 +430,17 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
|
||||
val fd = conn.getFd
|
||||
|
||||
var cmd = (Path.BASE +
|
||||
"tun2socks --netif-ipaddr %s "
|
||||
var cmd = (getApplicationInfo().dataDir +
|
||||
"/tun2socks --netif-ipaddr %s "
|
||||
+ "--netif-netmask 255.255.255.0 "
|
||||
+ "--socks-server-addr 127.0.0.1:%d "
|
||||
+ "--tunfd %d "
|
||||
+ "--tunmtu %d "
|
||||
+ "--sock-path %s "
|
||||
+ "--loglevel 3")
|
||||
.formatLocal(Locale.ENGLISH,
|
||||
PRIVATE_VLAN.formatLocal(Locale.ENGLISH, "2"),
|
||||
config.localPort, fd, VPN_MTU)
|
||||
config.localPort, fd, VPN_MTU, getApplicationInfo().dataDir + "/sock_path")
|
||||
|
||||
if (config.isIpv6)
|
||||
cmd += " --netif-ip6addr " + PRIVATE_VLAN6.formatLocal(Locale.ENGLISH, "2")
|
||||
|
||||
@@ -53,7 +53,7 @@ class ShadowsocksVpnThread(vpnService: ShadowsocksVpnService) extends Thread {
|
||||
import ShadowsocksVpnThread._
|
||||
|
||||
val TAG = "ShadowsocksVpnService"
|
||||
val PATH = "/data/data/com.github.shadowsocks/protect_path"
|
||||
lazy val PATH = ShadowsocksApplication.dataDir + "/protect_path"
|
||||
|
||||
@volatile var isRunning: Boolean = true
|
||||
@volatile var serverSocket: LocalServerSocket = null
|
||||
|
||||
@@ -55,10 +55,6 @@ object Msg {
|
||||
val VPN_ERROR = 6
|
||||
}
|
||||
|
||||
object Path {
|
||||
val BASE = "/data/data/com.github.shadowsocks/"
|
||||
}
|
||||
|
||||
object Key {
|
||||
val profileId = "profileId"
|
||||
val profileName = "profileName"
|
||||
|
||||
Reference in New Issue
Block a user