fix a very old bug in redsocks

This commit is contained in:
Max Lv
2014-11-17 19:51:08 +08:00
parent 8fb5d7f8c6
commit 27ba7d64f4
9 changed files with 818 additions and 413 deletions
@@ -341,6 +341,7 @@ class Shadowsocks
ab.clear()
ab.append("kill -9 `cat /data/data/com.github.shadowsocks/redsocks.pid`")
ab.append("rm /data/data/com.github.shadowsocks/redsocks.conf")
ab.append("rm /data/data/com.github.shadowsocks/redsocks.pid")
ab.append(Utils.getIptables + " -t nat -F OUTPUT")
Console.runRootCommand(ab.toArray)
@@ -137,18 +137,27 @@ class ShadowsocksNatService extends Service with BaseService {
if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" "))
Core.sstunnel(cmd.toArray)
} else {
val conf = {
ConfigUtils.PDNSD.format("127.0.0.1")
}
val cmdBuf = new ArrayBuffer[String]
cmdBuf += ("ss-tunnel"
, "-b", "127.0.0.1"
, "-l", "8163"
, "-L", "8.8.8.8:53"
, "-s", config.proxy
, "-p", config.remotePort.toString
, "-k", config.sitekey
, "-m", config.encMethod
, "-f", Path.BASE + "ss-tunnel.pid")
if (BuildConfig.DEBUG) Log.d(TAG, cmdBuf.mkString(" "))
Core.sstunnel(cmdBuf.toArray)
val conf = ConfigUtils
.PDNSD_BYPASS.format("127.0.0.1", getString(R.string.exclude), 8163)
ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => {
p.println(conf)
})
val args = "pdnsd -c " + Path.BASE + "pdnsd.conf"
val cmd = Path.BASE + args
val cmd = Path.BASE + "pdnsd -c " + Path.BASE + "pdnsd.conf"
if (BuildConfig.DEBUG) Log.d(TAG, cmd)
Console.runRootCommand(cmd)
Core.pdnsd(cmd.split(" "))
}
}
@@ -172,7 +181,7 @@ class ShadowsocksNatService extends Service with BaseService {
p.println(conf)
})
val cmd = Path.BASE + args
Console.runRootCommand(cmd)
Console.runCommand(cmd)
}
/** Called when the activity is first created. */