|
@@ -10,6 +10,7 @@ import java.io.InputStreamReader;
|
|
import java.io.OutputStream;
|
|
import java.io.OutputStream;
|
|
|
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
|
+import android.os.Build;
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
|
|
|
|
import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
|
|
import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
|
|
@@ -52,24 +53,26 @@ public class Device {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
- final String ipTablesList = "iptables -L -n -t nat"; // list all rules in NAT table
|
|
|
|
- try {
|
|
|
|
- Process p = new ProcessBuilder("su", "-c", ipTablesList).start();
|
|
|
|
- switch (p.waitFor()) {
|
|
|
|
- case 0: // everything is fine
|
|
|
|
- iptables = true; // iptables available and working
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- case 3: // no such table
|
|
|
|
- case 127: // command not found
|
|
|
|
- default: // unexpected return code
|
|
|
|
- // while testing code 3 has been returned when table NAT is not available
|
|
|
|
- iptables = false;
|
|
|
|
|
|
+ if (Build.VERSION.SDK_INT >= 18) { // iptables isn't fully implemented on older versions
|
|
|
|
+ final String ipTablesList = "iptables -L -n -t nat"; // list all rules in NAT table
|
|
|
|
+ try {
|
|
|
|
+ Process p = new ProcessBuilder("su", "-c", ipTablesList).start();
|
|
|
|
+ switch (p.waitFor()) {
|
|
|
|
+ case 0: // everything is fine
|
|
|
|
+ iptables = true; // iptables available and working
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 3: // no such table
|
|
|
|
+ case 127: // command not found
|
|
|
|
+ default: // unexpected return code
|
|
|
|
+ // while testing code 3 has been returned when table NAT is not available
|
|
|
|
+ iptables = false;
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
- } catch (IOException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- } catch (InterruptedException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
initialized = true;
|
|
initialized = true;
|