Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/org/adblockplus/android/configurators/IptablesProxyConfigurator.java

Issue 5169693514006528: Issue 1498 - Look for iptables on the system first (Closed)
Patch Set: Created Jan. 14, 2015, 6:26 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/org/adblockplus/android/configurators/IptablesProxyConfigurator.java
===================================================================
--- a/src/org/adblockplus/android/configurators/IptablesProxyConfigurator.java
+++ b/src/org/adblockplus/android/configurators/IptablesProxyConfigurator.java
@@ -58,14 +58,7 @@
throw new IllegalStateException("No root access");
}
- final File ipt = this.context.getFileStreamPath("iptables");
-
- if (!ipt.exists())
- {
- throw new FileNotFoundException("No iptables executable");
- }
-
- final String path = ipt.getAbsolutePath();
+ final String path = getIptablesExecutablePath();
RootTools.sendShell("chmod 700 " + path, DEFAULT_TIMEOUT);
@@ -103,6 +96,19 @@
}
}
+ private String getIptablesExecutablePath() throws FileNotFoundException
+ {
+ File iptablesExecutable = new File("/system/bin/iptables");
+ if (!iptablesExecutable.exists())
+ {
+ Log.i(TAG, "iptables not found on the system, using embedded binary");
+ iptablesExecutable = context.getFileStreamPath("iptables");
+ }
+ if (!iptablesExecutable.exists())
+ throw new FileNotFoundException("No iptables executable");
+ return iptablesExecutable.getAbsolutePath();
+ }
+
@Override
public boolean registerProxy(final InetAddress address, final int port)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld