mirror of
https://github.com/MaintainTeam/Hypatia.git
synced 2025-02-28 21:38:21 +03:00
Remove NetCipher
This commit is contained in:
parent
3d7901caa8
commit
6d01c4934d
5 changed files with 64 additions and 9 deletions
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -24,7 +24,7 @@
|
|||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -6,8 +6,8 @@ android {
|
|||
applicationId "us.spotco.malwarescanner"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 26
|
||||
versionCode 37
|
||||
versionName "2.7"
|
||||
versionCode 38
|
||||
versionName "2.8"
|
||||
resConfigs "en"
|
||||
}
|
||||
buildTypes {
|
||||
|
@ -31,5 +31,4 @@ dependencies {
|
|||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'com.android.support:appcompat-v7:26.1.0'
|
||||
implementation 'com.android.support:design:26.1.0'
|
||||
implementation 'info.guardianproject.netcipher:netcipher:2.0.0-alpha1'
|
||||
}
|
||||
|
|
|
@ -166,6 +166,7 @@ class Database {
|
|||
try {
|
||||
HttpURLConnection connection;
|
||||
if (onionRouting) {
|
||||
Utils.waitUntilOrbotIsAvailable();
|
||||
//url = url.replaceAll(baseURL, baseURLOnion); //TODO: Setup the .onion
|
||||
Proxy orbot = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("127.0.0.1", 9050));
|
||||
connection = (HttpURLConnection) new URL(url).openConnection(orbot);
|
||||
|
|
|
@ -46,8 +46,6 @@ import java.io.File;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import info.guardianproject.netcipher.proxy.OrbotHelper;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private SharedPreferences prefs = null;
|
||||
|
@ -149,11 +147,10 @@ public class MainActivity extends AppCompatActivity {
|
|||
switch (item.getItemId()) {
|
||||
case R.id.toggleOnionRouting:
|
||||
if (!item.isChecked()) {
|
||||
if (OrbotHelper.isOrbotInstalled(this)) {
|
||||
if (Utils.isOrbotInstalled(this)) {
|
||||
prefs.edit().putBoolean("ONION_ROUTING", !item.isChecked()).apply();
|
||||
item.setChecked(true);
|
||||
} else {
|
||||
startActivity(OrbotHelper.getOrbotInstallIntent(this));
|
||||
prefs.edit().putBoolean("ONION_ROUTING", false).apply();
|
||||
item.setChecked(false);
|
||||
Toast.makeText(this, R.string.lblOnionRoutingNotInstalled, Toast.LENGTH_SHORT).show();
|
||||
|
@ -165,7 +162,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
break;
|
||||
case R.id.mnuUpdateDatabase:
|
||||
if (prefs.getBoolean("ONION_ROUTING", false)) {
|
||||
OrbotHelper.requestStartTor(this);
|
||||
Utils.requestStartOrbot(this);
|
||||
logView.append("Downloading over Tor, this may take a while...\n");
|
||||
}
|
||||
updateDatabase();
|
||||
|
|
|
@ -21,9 +21,12 @@ import android.app.ActivityManager;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.Socket;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
@ -101,4 +104,59 @@ class Utils {
|
|||
}
|
||||
}
|
||||
|
||||
//Credit: https://stackoverflow.com/a/6758962
|
||||
public static boolean isPackageInstalled(Context context, String packageID) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
try {
|
||||
pm.getPackageInfo(packageID, PackageManager.GET_META_DATA);
|
||||
} catch(PackageManager.NameNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isOrbotInstalled(Context context) {
|
||||
return isPackageInstalled(context, "org.torproject.android");
|
||||
}
|
||||
|
||||
//Credit: OrbotHelper/NetCipher
|
||||
public static void requestStartOrbot(Context context) {
|
||||
Intent intent = new Intent("org.torproject.android.intent.action.START");
|
||||
intent.setPackage("org.torproject.android");
|
||||
intent.putExtra("org.torproject.android.intent.extra.PACKAGE_NAME", context.getPackageName());
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
//Credit: https://www.geekality.net/2013/04/30/java-simple-check-to-see-if-a-server-is-listening-on-a-port/
|
||||
public static boolean isPortListening(String host, int port) {
|
||||
Socket s = null;
|
||||
try {
|
||||
s = new Socket(host, port);
|
||||
return true;
|
||||
} catch(Exception e) {
|
||||
return false;
|
||||
} finally {
|
||||
if (s != null) {
|
||||
try {
|
||||
s.close();
|
||||
} catch(Exception e1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean waitUntilOrbotIsAvailable() {
|
||||
int tries = 0;
|
||||
boolean listening;
|
||||
while(!(listening = isPortListening("127.0.0.1", 9050)) && tries <= 60) {
|
||||
tries++;
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch(Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
return listening;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue