fixed TorBinaryInstaller issue on Android OS 2.2/Froyo. Now looks for APK file with incremented path name -1 -2 -3 etc

svn:r22498
This commit is contained in:
Nathan Freitas 2010-06-09 20:14:03 +00:00
parent b9e1ba8f7a
commit fb3a202d16
3 changed files with 23 additions and 6 deletions

View File

@ -45,7 +45,20 @@ public class TorBinaryInstaller implements TorServiceConstants {
try try
{ {
ZipFile zip = new ZipFile(APK_PATH);
String apkPath = APK_PATH;
int apkIdx = 1;
while (!new File(apkPath).exists())
{
apkPath = APK_PATH_BASE + '-' + (apkIdx++) + ".apk";
Log.i(TAG,"Could not find APK. Trying new path: " + apkPath);
}
ZipFile zip = new ZipFile(apkPath);
ZipEntry zipen = zip.getEntry(TOR_BINARY_ZIP_KEY); ZipEntry zipen = zip.getEntry(TOR_BINARY_ZIP_KEY);
streamToFile(zip.getInputStream(zipen),TOR_BINARY_INSTALL_PATH); streamToFile(zip.getInputStream(zipen),TOR_BINARY_INSTALL_PATH);

View File

@ -50,7 +50,8 @@ public interface TorServiceConstants {
//path of the installed APK file //path of the installed APK file
public final static String APK_PATH = "/data/app/org.torproject.android.apk"; public final static String APK_PATH = "/data/app/org.torproject.android.apk";
public final static String APK_PATH_BASE = "/data/app/org.torproject.android";
public final static int FILE_WRITE_BUFFER_SIZE = 2048; public final static int FILE_WRITE_BUFFER_SIZE = 2048;

View File

@ -16,10 +16,13 @@ public class TorTransProxy {
private final static String CMD_NAT_FLUSH = "iptables -t nat -F || exit\n"; private final static String CMD_NAT_FLUSH = "iptables -t nat -F || exit\n";
private final static String CMD_DNS_PROXYING_ADD = "iptables -t nat -A PREROUTING -p udp --dport 53 -j DNAT --to 127.0.0.1:5400 || exit\n"; private final static String CMD_DNS_PROXYING_ADD = "iptables -t nat -A PREROUTING -p udp --dport 53 -j DNAT --to 127.0.0.1:5400 || exit\n";
private final static String CMD_DNS_PROXYING_DELETE = "iptables -t nat -D PREROUTING -p udp --dport 53 -j DNAT --to 127.0.0.1:5400 || exit\n";
//private final static String CMD_DNS_PROXYING_DELETE = "iptables -t nat -D PREROUTING -p udp --dport 53 -j DNAT --to 127.0.0.1:5400 || exit\n";
// - just calling a system wide flush of iptables rules
private final static String IPTABLES_ADD = " -A "; private final static String IPTABLES_ADD = " -A ";
private final static String IPTABLES_DELETE = " -D ";
//private final static String IPTABLES_DELETE = " -D "; //not deleting manually anymore - just calling a system wide flush of iptables rules
private final static String IPTABLES_DROP_ALL = " -j DROP "; private final static String IPTABLES_DROP_ALL = " -j DROP ";
private static boolean hasRoot = false; private static boolean hasRoot = false;
@ -121,7 +124,7 @@ public class TorTransProxy {
script.append(command); script.append(command);
script.append("OUTPUT -p udp -m owner --uid-owner "); script.append("OUTPUT -p udp -m owner --uid-owner ");
script.append(apps[i].getUid()); script.append(apps[i].getUid());
script.append(" -j DNAT --to 127.0.0.1:9040"); script.append(" -j DROP"); //drop all UDP packets as Tor won't handle them
script.append(" || exit\n"); script.append(" || exit\n");
} }
} }