Commit 10de6ea6 authored by Max Lv's avatar Max Lv

remote the DNS WAR

parent c1f55c80
...@@ -847,7 +847,6 @@ class Shadowsocks ...@@ -847,7 +847,6 @@ class Shadowsocks
} }
ab.append("mount -o ro,remount -t yaffs2 /dev/block/mtdblock3 /system") ab.append("mount -o ro,remount -t yaffs2 /dev/block/mtdblock3 /system")
Console.runRootCommand(ab.toArray) Console.runRootCommand(ab.toArray)
} }
def reset() { def reset() {
......
...@@ -228,19 +228,11 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -228,19 +228,11 @@ class ShadowsocksNatService extends Service with BaseService {
, "-c" , Path.BASE + "ss-tunnel-nat.conf" , "-c" , Path.BASE + "ss-tunnel-nat.conf"
, "-f" , Path.BASE + "ss-tunnel-nat.pid") , "-f" , Path.BASE + "ss-tunnel-nat.pid")
if (Utils.isLollipopOrAbove) {
cmd += ("-l" , "53")
} else {
cmd += ("-l" , "8153") cmd += ("-l" , "8153")
}
if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" ")) if (BuildConfig.DEBUG) Log.d(TAG, cmd.mkString(" "))
if (Utils.isLollipopOrAbove) {
Console.runRootCommand(cmd.mkString(" "))
} else {
Console.runCommand(cmd.mkString(" ")) Console.runCommand(cmd.mkString(" "))
}
} else { } else {
val conf = ConfigUtils val conf = ConfigUtils
...@@ -263,13 +255,8 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -263,13 +255,8 @@ class ShadowsocksNatService extends Service with BaseService {
} }
def startDnsDaemon() { def startDnsDaemon() {
val conf = if (Utils.isLollipopOrAbove) { val conf = ConfigUtils
ConfigUtils
.PDNSD_BYPASS.formatLocal(Locale.ENGLISH, "127.0.0.1", 53, Path.BASE + "pdnsd-nat.pid", getString(R.string.exclude), 8163)
} else {
ConfigUtils
.PDNSD_BYPASS.formatLocal(Locale.ENGLISH, "127.0.0.1", 8153, Path.BASE + "pdnsd-nat.pid", getString(R.string.exclude), 8163) .PDNSD_BYPASS.formatLocal(Locale.ENGLISH, "127.0.0.1", 8153, Path.BASE + "pdnsd-nat.pid", getString(R.string.exclude), 8163)
}
ConfigUtils.printToFile(new File(Path.BASE + "pdnsd-nat.conf"))(p => { ConfigUtils.printToFile(new File(Path.BASE + "pdnsd-nat.conf"))(p => {
p.println(conf) p.println(conf)
}) })
...@@ -277,11 +264,7 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -277,11 +264,7 @@ class ShadowsocksNatService extends Service with BaseService {
if (BuildConfig.DEBUG) Log.d(TAG, cmd) if (BuildConfig.DEBUG) Log.d(TAG, cmd)
if (Utils.isLollipopOrAbove) {
Console.runRootCommand(cmd)
} else {
Console.runCommand(cmd) Console.runCommand(cmd)
}
} }
...@@ -428,10 +411,8 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -428,10 +411,8 @@ class ShadowsocksNatService extends Service with BaseService {
init_sb.append(cmd_bypass.replace("-d 0.0.0.0", "-m owner --uid-owner " + myUid)) init_sb.append(cmd_bypass.replace("-d 0.0.0.0", "-m owner --uid-owner " + myUid))
init_sb.append(cmd_bypass.replace("-d 0.0.0.0", "--dport 53")) init_sb.append(cmd_bypass.replace("-d 0.0.0.0", "--dport 53"))
if (!Utils.isLollipopOrAbove) {
init_sb.append(Utils.getIptables init_sb.append(Utils.getIptables
+ " -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination 127.0.0.1:" + DNS_PORT) + " -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination 127.0.0.1:" + DNS_PORT)
}
if (config.isGlobalProxy || config.isBypassApps) { if (config.isGlobalProxy || config.isBypassApps) {
http_sb.append(Utils.getIptables + CMD_IPTABLES_DNAT_ADD_SOCKS) http_sb.append(Utils.getIptables + CMD_IPTABLES_DNAT_ADD_SOCKS)
...@@ -500,9 +481,6 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -500,9 +481,6 @@ class ShadowsocksNatService extends Service with BaseService {
config = c config = c
// register connection receiver
if (Utils.isLollipopOrAbove) initConnectionReceiver()
// register close receiver // register close receiver
val filter = new IntentFilter() val filter = new IntentFilter()
filter.addAction(Intent.ACTION_SHUTDOWN) filter.addAction(Intent.ACTION_SHUTDOWN)
...@@ -559,7 +537,6 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -559,7 +537,6 @@ class ShadowsocksNatService extends Service with BaseService {
if (resolved && handleConnection) { if (resolved && handleConnection) {
// Set DNS // Set DNS
if (Utils.isLollipopOrAbove) setupDns()
flushDns() flushDns()
notifyForegroundAlert(getString(R.string.forward_success), notifyForegroundAlert(getString(R.string.forward_success),
...@@ -583,9 +560,6 @@ class ShadowsocksNatService extends Service with BaseService { ...@@ -583,9 +560,6 @@ class ShadowsocksNatService extends Service with BaseService {
unregisterReceiver(closeReceiver) unregisterReceiver(closeReceiver)
closeReceiver = null closeReceiver = null
} }
if (Utils.isLollipopOrAbove) {
destroyConnectionReceiver()
}
// send event // send event
application.tracker.send(new HitBuilders.EventBuilder() application.tracker.send(new HitBuilders.EventBuilder()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment