mirror of https://github.com/LeOS-GSI/LeOS-Genesis
parent
375f07fb87
commit
836183291c
|
@ -19,6 +19,7 @@ import java.lang.ref.WeakReference;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.darkweb.genesissearchengine.appManager.activityContextManager;
|
||||||
import com.darkweb.genesissearchengine.appManager.homeManager.homeController.homeController;
|
import com.darkweb.genesissearchengine.appManager.homeManager.homeController.homeController;
|
||||||
import com.darkweb.genesissearchengine.constants.constants;
|
import com.darkweb.genesissearchengine.constants.constants;
|
||||||
import com.darkweb.genesissearchengine.constants.enums;
|
import com.darkweb.genesissearchengine.constants.enums;
|
||||||
|
@ -26,6 +27,7 @@ import com.darkweb.genesissearchengine.constants.keys;
|
||||||
import com.darkweb.genesissearchengine.constants.status;
|
import com.darkweb.genesissearchengine.constants.status;
|
||||||
import com.darkweb.genesissearchengine.constants.strings;
|
import com.darkweb.genesissearchengine.constants.strings;
|
||||||
import com.darkweb.genesissearchengine.eventObserver;
|
import com.darkweb.genesissearchengine.eventObserver;
|
||||||
|
import com.darkweb.genesissearchengine.helperManager.helperMethod;
|
||||||
import com.darkweb.genesissearchengine.pluginManager.pluginController;
|
import com.darkweb.genesissearchengine.pluginManager.pluginController;
|
||||||
import com.darkweb.genesissearchengine.pluginManager.pluginEnums;
|
import com.darkweb.genesissearchengine.pluginManager.pluginEnums;
|
||||||
|
|
||||||
|
@ -85,15 +87,19 @@ public class orbotManager
|
||||||
Intent mServiceIntent = new Intent(mAppContext.get().getApplicationContext(), OrbotService.class);
|
Intent mServiceIntent = new Intent(mAppContext.get().getApplicationContext(), OrbotService.class);
|
||||||
mServiceIntent.setAction(ACTION_START);
|
mServiceIntent.setAction(ACTION_START);
|
||||||
|
|
||||||
mAppContext.get().bindService(mServiceIntent, mServerConn, Context.BIND_AUTO_CREATE);
|
helperMethod.onDelayHandler(activityContextManager.getInstance().getHomeController(), 3000, () -> {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
mAppContext.get().stopService(mServiceIntent);
|
mAppContext.get().stopService(mServiceIntent);
|
||||||
mAppContext.get().startForegroundService(mServiceIntent);
|
mAppContext.get().startForegroundService(mServiceIntent);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
mAppContext.get().stopService(mServiceIntent);
|
||||||
mAppContext.get().startService(mServiceIntent);
|
mAppContext.get().startService(mServiceIntent);
|
||||||
}
|
}
|
||||||
|
mAppContext.get().bindService(mServiceIntent, mServerConn, Context.BIND_AUTO_CREATE);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -1,10 +1,3 @@
|
||||||
/* Copyright (c) 2009-2011, Nathan Freitas, Orbot / The Guardian Project - https://guardianproject.info/apps/orbot */
|
|
||||||
/* See LICENSE for licensing information */
|
|
||||||
/*
|
|
||||||
* Code for iptables binary management taken from DroidWall GPLv3
|
|
||||||
* Copyright (C) 2009-2010 Rodrigo Zechin Rosauro
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.torproject.android.service;
|
package org.torproject.android.service;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
@ -30,6 +23,7 @@ import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.net.VpnService;
|
import android.net.VpnService;
|
||||||
|
import android.os.BatteryManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
|
@ -258,7 +252,7 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
|
||||||
if (conn != null && orbotLocalConstants.mIsTorInitialized) {
|
if (conn != null && orbotLocalConstants.mIsTorInitialized) {
|
||||||
Intent intentRefresh = new Intent(CMD_NEWNYM);
|
Intent intentRefresh = new Intent(CMD_NEWNYM);
|
||||||
PendingIntent pendingIntentNewNym = PendingIntent.getBroadcast(this, 0, intentRefresh, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent pendingIntentNewNym = PendingIntent.getBroadcast(this, 0, intentRefresh, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
mNotifyBuilder.addAction(R.drawable.ic_stat_starting_tor_logo, getString(R.string.menu_new_identity), pendingIntentNewNym);
|
mNotifyBuilder.addAction(R.mipmap.ic_stat_tor_logo, getString(R.string.menu_new_identity), pendingIntentNewNym);
|
||||||
|
|
||||||
Intent intentSetting = new Intent(CMD_SETTING);
|
Intent intentSetting = new Intent(CMD_SETTING);
|
||||||
PendingIntent pendingIntentSetting = PendingIntent.getBroadcast(this, 0, intentSetting, PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent pendingIntentSetting = PendingIntent.getBroadcast(this, 0, intentSetting, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
@ -364,16 +358,20 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
|
||||||
|
|
||||||
private void stopTorAsync() {
|
private void stopTorAsync() {
|
||||||
|
|
||||||
Log.i("OrbotService", "stopTor");
|
debug("stopTor");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sendCallbackStatus(STATUS_STOPPING);
|
sendCallbackStatus(STATUS_STOPPING);
|
||||||
sendCallbackLogMessage(getString(R.string.status_shutting_down));
|
sendCallbackLogMessage(getString(R.string.status_shutting_down));
|
||||||
|
|
||||||
|
if (Prefs.bridgesEnabled()) {
|
||||||
if (useIPtObfsMeekProxy())
|
if (useIPtObfsMeekProxy())
|
||||||
IPtProxy.stopObfs4Proxy();
|
IPtProxy.stopObfs4Proxy();
|
||||||
|
else if (useIPtSnowflakeProxy())
|
||||||
if (useIPtSnowflakeProxy())
|
|
||||||
IPtProxy.stopSnowflake();
|
IPtProxy.stopSnowflake();
|
||||||
|
}
|
||||||
|
else if (Prefs.beSnowflakeProxy())
|
||||||
|
disableSnowflakeProxy();
|
||||||
|
|
||||||
stopTor();
|
stopTor();
|
||||||
|
|
||||||
|
@ -389,6 +387,11 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
|
||||||
sendCallbackStatus(STATUS_OFF);
|
sendCallbackStatus(STATUS_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void disableSnowflakeProxy () {
|
||||||
|
IPtProxy.stopSnowflakeProxy();
|
||||||
|
logNotice("Snowflake Proxy mode DISABLED");
|
||||||
|
}
|
||||||
|
|
||||||
private void stopTorOnError(String message) {
|
private void stopTorOnError(String message) {
|
||||||
stopTorAsync();
|
stopTorAsync();
|
||||||
showToolbarNotification(
|
showToolbarNotification(
|
||||||
|
@ -411,19 +414,14 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
|
||||||
public static void loadCdnFronts (Context context) {
|
public static void loadCdnFronts (Context context) {
|
||||||
if (mFronts == null) {
|
if (mFronts == null) {
|
||||||
mFronts = new HashMap<>();
|
mFronts = new HashMap<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(context.getAssets().open("fronts")));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(context.getAssets().open("fronts")));
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine())!=null) {
|
while ((line = reader.readLine())!=null) {
|
||||||
String[] front = line.split(" ");
|
String[] front = line.split(" ");
|
||||||
|
|
||||||
//add some code to test the connection here
|
|
||||||
|
|
||||||
mFronts.put(front[0],front[1]);
|
mFronts.put(front[0],front[1]);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.i("sad","asd");
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -433,16 +431,11 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
|
||||||
return mFronts.get(service);
|
return mFronts.get(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void startSnowflakeClient() {
|
private void startSnowflakeClient() {
|
||||||
//this is using the current, default Tor snowflake infrastructure
|
|
||||||
String target = getCdnFront("snowflake-target");
|
String target = getCdnFront("snowflake-target");
|
||||||
String front = getCdnFront("snowflake-front");
|
String front = getCdnFront("snowflake-front");
|
||||||
String stunServer = getCdnFront("snowflake-stun");
|
String stunServer = getCdnFront("snowflake-stun");
|
||||||
|
IPtProxy.startSnowflake(stunServer, target, front,null, true, false, true, 3);
|
||||||
IPtProxy.startSnowflake(stunServer, target, front,
|
|
||||||
null, true, false, true, 3);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -982,8 +975,8 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
|
||||||
events.add(TorControlCommands.EVENT_INFO_MSG);
|
events.add(TorControlCommands.EVENT_INFO_MSG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
conn.setEvents(events);
|
conn.setEvents(events);
|
||||||
|
initControlConnection();
|
||||||
logNotice("SUCCESS added control port event handler");
|
logNotice("SUCCESS added control port event handler");
|
||||||
} catch (InterruptedException | IOException e) {
|
} catch (InterruptedException | IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -1225,7 +1218,6 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
|
||||||
int e=0;
|
int e=0;
|
||||||
private void sendCallbackLogMessage(String logMessage)
|
private void sendCallbackLogMessage(String logMessage)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(logMessage.contains("Bootstrapped 100%")){
|
if(logMessage.contains("Bootstrapped 100%")){
|
||||||
orbotLocalConstants.mIsTorInitialized = true;
|
orbotLocalConstants.mIsTorInitialized = true;
|
||||||
}
|
}
|
||||||
|
@ -1827,14 +1819,24 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
|
||||||
if (!TextUtils.isEmpty(action)) {
|
if (!TextUtils.isEmpty(action)) {
|
||||||
if (action.equals(ACTION_START) || action.equals(ACTION_START_ON_BOOT)) {
|
if (action.equals(ACTION_START) || action.equals(ACTION_START_ON_BOOT)) {
|
||||||
|
|
||||||
|
if (Prefs.bridgesEnabled()) {
|
||||||
if (useIPtObfsMeekProxy())
|
if (useIPtObfsMeekProxy())
|
||||||
IPtProxy.startObfs4Proxy("DEBUG", true, false);
|
IPtProxy.startObfs4Proxy("DEBUG", false, false);
|
||||||
|
else if (useIPtSnowflakeProxy())
|
||||||
if (useIPtSnowflakeProxy())
|
|
||||||
startSnowflakeClient();
|
startSnowflakeClient();
|
||||||
|
} else if (Prefs.beSnowflakeProxy()) {
|
||||||
|
|
||||||
if (Prefs.beSnowflakeProxy())
|
if (Prefs.limitSnowflakeProxying())
|
||||||
runSnowflakeProxy();
|
{
|
||||||
|
if (isChargingAndWifi(OrbotService.this))
|
||||||
|
{
|
||||||
|
enableSnowflakeProxy();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
enableSnowflakeProxy();
|
||||||
|
}
|
||||||
|
|
||||||
startTor();
|
startTor();
|
||||||
replyWithStatus(mIntent);
|
replyWithStatus(mIntent);
|
||||||
|
@ -1854,7 +1856,8 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
|
||||||
if (mPortSOCKS != -1 && mPortHTTP != -1)
|
if (mPortSOCKS != -1 && mPortHTTP != -1)
|
||||||
sendCallbackPorts(mPortSOCKS, mPortHTTP, mPortDns, mPortTrans);
|
sendCallbackPorts(mPortSOCKS, mPortHTTP, mPortDns, mPortTrans);
|
||||||
}
|
}
|
||||||
|
} else if (action.equals(ACTION_STOP)) {
|
||||||
|
stopTorAsync();
|
||||||
} else if (action.equals(ACTION_START_VPN)) {
|
} else if (action.equals(ACTION_START_VPN)) {
|
||||||
if (mVpnManager != null && (!mVpnManager.isStarted())) {
|
if (mVpnManager != null && (!mVpnManager.isStarted())) {
|
||||||
//start VPN here
|
//start VPN here
|
||||||
|
@ -1875,14 +1878,9 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
|
||||||
replyWithStatus(mIntent);
|
replyWithStatus(mIntent);
|
||||||
} else if (action.equals(TorControlCommands.SIGNAL_RELOAD)) {
|
} else if (action.equals(TorControlCommands.SIGNAL_RELOAD)) {
|
||||||
requestTorRereadConfig();
|
requestTorRereadConfig();
|
||||||
}
|
} else if (action.equals(TorControlCommands.SIGNAL_NEWNYM)) {
|
||||||
else if (action.equals(CMD_NEWNYM)) {
|
|
||||||
newIdentity();
|
newIdentity();
|
||||||
}
|
} else if (action.equals(CMD_ACTIVE)) {
|
||||||
else if (action.equals(CMD_SETTING)) {
|
|
||||||
onSettingRegister();
|
|
||||||
}
|
|
||||||
else if (action.equals(CMD_ACTIVE)) {
|
|
||||||
sendSignalActive();
|
sendSignalActive();
|
||||||
} else if (action.equals(CMD_SET_EXIT)) {
|
} else if (action.equals(CMD_SET_EXIT)) {
|
||||||
setExitNode(mIntent.getStringExtra("exit"));
|
setExitNode(mIntent.getStringExtra("exit"));
|
||||||
|
@ -1893,6 +1891,19 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void enableSnowflakeProxy () {
|
||||||
|
int capacity = 1;
|
||||||
|
String broker = "https://snowflake-broker.bamsoftware.com/";
|
||||||
|
String relay = "wss://snowflake.bamsoftware.com/";
|
||||||
|
String stun = "stun:stun.stunprotocol.org:3478";
|
||||||
|
String logFile = null;
|
||||||
|
boolean keepLocalAddresses = true;
|
||||||
|
boolean unsafeLogging = false;
|
||||||
|
IPtProxy.startSnowflakeProxy(capacity, broker, relay, stun, logFile, keepLocalAddresses, unsafeLogging);
|
||||||
|
|
||||||
|
logNotice("Snowflake Proxy mode ENABLED");
|
||||||
|
}
|
||||||
|
|
||||||
public void disableNotification(){
|
public void disableNotification(){
|
||||||
if(mNotificationManager!=null){
|
if(mNotificationManager!=null){
|
||||||
mNotificationManager.cancel(NOTIFY_ID);
|
mNotificationManager.cancel(NOTIFY_ID);
|
||||||
|
@ -1925,6 +1936,20 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isChargingAndWifi(Context context) {
|
||||||
|
Intent intent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||||
|
int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
|
||||||
|
boolean isCharging = plugged == BatteryManager.BATTERY_PLUGGED_AC || plugged == BatteryManager.BATTERY_PLUGGED_USB || plugged == BatteryManager.BATTERY_PLUGGED_WIRELESS;
|
||||||
|
|
||||||
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
|
||||||
|
boolean isUnmetered = cm.getActiveNetworkInfo() != null
|
||||||
|
&& cm.getActiveNetworkInfo().isConnected()
|
||||||
|
&& (!cm.isActiveNetworkMetered());
|
||||||
|
|
||||||
|
return isCharging && isUnmetered;
|
||||||
|
}
|
||||||
|
|
||||||
private class ActionBroadcastReceiver extends BroadcastReceiver {
|
private class ActionBroadcastReceiver extends BroadcastReceiver {
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
switch (intent.getAction()) {
|
switch (intent.getAction()) {
|
||||||
|
|
|
@ -6,7 +6,6 @@ import net.freehaven.tor.control.EventHandler;
|
||||||
|
|
||||||
import org.torproject.android.service.util.ExternalIPFetcher;
|
import org.torproject.android.service.util.ExternalIPFetcher;
|
||||||
import org.torproject.android.service.util.Prefs;
|
import org.torproject.android.service.util.Prefs;
|
||||||
import org.torproject.android.service.wrapper.orbotLocalConstants;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -86,7 +85,7 @@ public class TorEventHandler implements EventHandler, TorServiceConstants {
|
||||||
|
|
||||||
int iconId = R.drawable.ic_stat_starting_tor_logo;
|
int iconId = R.drawable.ic_stat_starting_tor_logo;
|
||||||
|
|
||||||
if (read > 0 || written > 0 || OrbotService.getServiceObject().getConnectivity())
|
if (read > 0 || written > 0)
|
||||||
iconId = R.mipmap.ic_stat_tor_logo;
|
iconId = R.mipmap.ic_stat_tor_logo;
|
||||||
|
|
||||||
String sb = OrbotService.formatBandwidthCount(mService, read) + " \u2193" + " / " +
|
String sb = OrbotService.formatBandwidthCount(mService, read) + " \u2193" + " / " +
|
||||||
|
@ -110,9 +109,8 @@ public class TorEventHandler implements EventHandler, TorServiceConstants {
|
||||||
public void circuitStatus(String status, String circID, String path) {
|
public void circuitStatus(String status, String circID, String path) {
|
||||||
|
|
||||||
/* once the first circuit is complete, then announce that Orbot is on*/
|
/* once the first circuit is complete, then announce that Orbot is on*/
|
||||||
if (mService.getCurrentStatus() == STATUS_STARTING && TextUtils.equals(status, "BUILT")){
|
if (mService.getCurrentStatus() == STATUS_STARTING && TextUtils.equals(status, "BUILT"))
|
||||||
mService.sendCallbackStatus(STATUS_ON);
|
mService.sendCallbackStatus(STATUS_ON);
|
||||||
}
|
|
||||||
|
|
||||||
if (Prefs.useDebugLogging()) {
|
if (Prefs.useDebugLogging()) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
|
@ -4,7 +4,6 @@ import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.torproject.android.service.OrbotService;
|
import org.torproject.android.service.OrbotService;
|
||||||
import org.torproject.android.service.TorEventHandler;
|
import org.torproject.android.service.TorEventHandler;
|
||||||
import org.torproject.android.service.wrapper.orbotLocalConstants;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -19,7 +18,7 @@ public class ExternalIPFetcher implements Runnable {
|
||||||
private final static String ONIONOO_BASE_URL = "https://onionoo.torproject.org/details?fields=country_name,as_name,or_addresses&lookup=";
|
private final static String ONIONOO_BASE_URL = "https://onionoo.torproject.org/details?fields=country_name,as_name,or_addresses&lookup=";
|
||||||
private OrbotService mService;
|
private OrbotService mService;
|
||||||
private TorEventHandler.Node mNode;
|
private TorEventHandler.Node mNode;
|
||||||
private int mLocalHttpProxyPort = orbotLocalConstants.mHTTPPort;
|
private int mLocalHttpProxyPort = 8118;
|
||||||
|
|
||||||
public ExternalIPFetcher(OrbotService service, TorEventHandler.Node node, int localProxyPort) {
|
public ExternalIPFetcher(OrbotService service, TorEventHandler.Node node, int localProxyPort) {
|
||||||
mService = service;
|
mService = service;
|
||||||
|
|
|
@ -2,8 +2,8 @@ package org.torproject.android.service.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
|
||||||
import org.torproject.android.service.OrbotConstants;
|
import org.torproject.android.service.OrbotConstants;
|
||||||
import org.torproject.android.service.wrapper.orbotLocalConstants;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -21,6 +21,10 @@ public class Prefs {
|
||||||
private final static String PREF_USE_VPN = "pref_vpn";
|
private final static String PREF_USE_VPN = "pref_vpn";
|
||||||
private final static String PREF_EXIT_NODES = "pref_exit_nodes";
|
private final static String PREF_EXIT_NODES = "pref_exit_nodes";
|
||||||
private final static String PREF_BE_A_SNOWFLAKE = "pref_be_a_snowflake";
|
private final static String PREF_BE_A_SNOWFLAKE = "pref_be_a_snowflake";
|
||||||
|
private final static String PREF_BE_A_SNOWFLAKE_LIMIT = "pref_be_a_snowflake_limit";
|
||||||
|
|
||||||
|
private final static String PREF_HOST_ONION_SERVICES = "pref_host_onionservices";
|
||||||
|
|
||||||
|
|
||||||
private static SharedPreferences prefs;
|
private static SharedPreferences prefs;
|
||||||
|
|
||||||
|
@ -37,16 +41,20 @@ public class Prefs {
|
||||||
prefs.edit().putString(key, value).apply();
|
prefs.edit().putString(key, value).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hostOnionServicesEnabled () {
|
||||||
|
return prefs.getBoolean(PREF_HOST_ONION_SERVICES, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void putHostOnionServicesEnabled(boolean value) {
|
||||||
|
putBoolean(PREF_HOST_ONION_SERVICES, value);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean bridgesEnabled() {
|
public static boolean bridgesEnabled() {
|
||||||
//if phone is in Farsi, enable bridges by default
|
//if phone is in Farsi, enable bridges by default
|
||||||
boolean bridgesEnabledDefault = Locale.getDefault().getLanguage().equals("fa");
|
boolean bridgesEnabledDefault = Locale.getDefault().getLanguage().equals("fa");
|
||||||
return prefs.getBoolean(PREF_BRIDGES_ENABLED, bridgesEnabledDefault);
|
return prefs.getBoolean(PREF_BRIDGES_ENABLED, bridgesEnabledDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hostOnionServicesEnabled(){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void putBridgesEnabled(boolean value) {
|
public static void putBridgesEnabled(boolean value) {
|
||||||
putBoolean(PREF_BRIDGES_ENABLED, value);
|
putBoolean(PREF_BRIDGES_ENABLED, value);
|
||||||
}
|
}
|
||||||
|
@ -55,24 +63,6 @@ public class Prefs {
|
||||||
String defaultBridgeType = "obfs4";
|
String defaultBridgeType = "obfs4";
|
||||||
if (Locale.getDefault().getLanguage().equals("fa"))
|
if (Locale.getDefault().getLanguage().equals("fa"))
|
||||||
defaultBridgeType = "meek"; //if Farsi, use meek as the default bridge type
|
defaultBridgeType = "meek"; //if Farsi, use meek as the default bridge type
|
||||||
if(orbotLocalConstants.mIsManualBridge){
|
|
||||||
if(!orbotLocalConstants.mManualBridgeType.equals("")){
|
|
||||||
defaultBridgeType = orbotLocalConstants.mManualBridgeType;
|
|
||||||
putString(PREF_BRIDGES_LIST, defaultBridgeType);
|
|
||||||
return defaultBridgeType;
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
if(orbotLocalConstants.mBridges.equals("obfs4")){
|
|
||||||
defaultBridgeType = "obfs4";
|
|
||||||
putString(PREF_BRIDGES_LIST, defaultBridgeType);
|
|
||||||
return defaultBridgeType;
|
|
||||||
}else if(orbotLocalConstants.mBridges.equals("meek")){
|
|
||||||
defaultBridgeType = "meek";
|
|
||||||
putString(PREF_BRIDGES_LIST, defaultBridgeType);
|
|
||||||
return defaultBridgeType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return prefs.getString(PREF_BRIDGES_LIST, defaultBridgeType);
|
return prefs.getString(PREF_BRIDGES_LIST, defaultBridgeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +82,10 @@ public class Prefs {
|
||||||
putBoolean(PREF_BE_A_SNOWFLAKE,beSnowflakeProxy);
|
putBoolean(PREF_BE_A_SNOWFLAKE,beSnowflakeProxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean limitSnowflakeProxying () {
|
||||||
|
return prefs.getBoolean(PREF_BE_A_SNOWFLAKE_LIMIT,true);
|
||||||
|
}
|
||||||
|
|
||||||
public static void setDefaultLocale(String value) {
|
public static void setDefaultLocale(String value) {
|
||||||
putString(PREF_DEFAULT_LOCALE, value);
|
putString(PREF_DEFAULT_LOCALE, value);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +95,7 @@ public class Prefs {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean useDebugLogging() {
|
public static boolean useDebugLogging() {
|
||||||
return false;//prefs.getBoolean(PREF_ENABLE_LOGGING, false);
|
return prefs.getBoolean(PREF_ENABLE_LOGGING, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean persistNotifications() {
|
public static boolean persistNotifications() {
|
||||||
|
|
|
@ -45,9 +45,11 @@ import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
@ -55,6 +57,8 @@ import java.util.concurrent.TimeoutException;
|
||||||
import static org.torproject.android.service.TorServiceConstants.ACTION_START;
|
import static org.torproject.android.service.TorServiceConstants.ACTION_START;
|
||||||
import static org.torproject.android.service.TorServiceConstants.ACTION_START_VPN;
|
import static org.torproject.android.service.TorServiceConstants.ACTION_START_VPN;
|
||||||
import static org.torproject.android.service.TorServiceConstants.ACTION_STOP_VPN;
|
import static org.torproject.android.service.TorServiceConstants.ACTION_STOP_VPN;
|
||||||
|
import static org.torproject.android.service.TorServiceConstants.TOR_DNS_PORT_DEFAULT;
|
||||||
|
import static org.torproject.android.service.TorServiceConstants.TOR_TRANSPROXY_PORT_DEFAULT;
|
||||||
|
|
||||||
public class OrbotVpnManager implements Handler.Callback {
|
public class OrbotVpnManager implements Handler.Callback {
|
||||||
private static final String TAG = "OrbotVpnService";
|
private static final String TAG = "OrbotVpnService";
|
||||||
|
@ -83,7 +87,8 @@ public class OrbotVpnManager implements Handler.Callback {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File makePdnsdConf(Context context, File fileDir, String torDnsHost, int torDnsPort, String pdnsdHost, int pdnsdPort) throws IOException {
|
public static File makePdnsdConf(Context context, File fileDir, String torDnsHost, int torDnsPort, String pdnsdHost, int pdnsdPort) throws IOException {
|
||||||
String conf = String.format(context.getString(R.string.pdnsd_conf), torDnsHost, torDnsPort, fileDir.getCanonicalPath(), pdnsdHost, pdnsdPort);
|
String conf = String.format(context.getString(R.string.pdnsd_conf),
|
||||||
|
torDnsHost, torDnsPort, fileDir.getAbsolutePath(), pdnsdHost, pdnsdPort);
|
||||||
|
|
||||||
Log.d(TAG, "pdsnd conf:" + conf);
|
Log.d(TAG, "pdsnd conf:" + conf);
|
||||||
|
|
||||||
|
@ -93,9 +98,8 @@ public class OrbotVpnManager implements Handler.Callback {
|
||||||
fPid.delete();
|
fPid.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileOutputStream fos = new FileOutputStream(fPid, false);
|
PrintWriter ps = new PrintWriter(new FileWriter(fPid, false));
|
||||||
PrintStream ps = new PrintStream(fos);
|
ps.write(conf);
|
||||||
ps.print(conf);
|
|
||||||
ps.close();
|
ps.close();
|
||||||
|
|
||||||
File cache = new File(fileDir, "pdnsd.cache");
|
File cache = new File(fileDir, "pdnsd.cache");
|
||||||
|
@ -140,8 +144,8 @@ public class OrbotVpnManager implements Handler.Callback {
|
||||||
} else if (action.equals(TorServiceConstants.LOCAL_ACTION_PORTS)) {
|
} else if (action.equals(TorServiceConstants.LOCAL_ACTION_PORTS)) {
|
||||||
Log.d(TAG, "setting VPN ports");
|
Log.d(TAG, "setting VPN ports");
|
||||||
|
|
||||||
int torSocks = intent.getIntExtra(OrbotService.EXTRA_SOCKS_PROXY_PORT, -1);
|
int torSocks = intent.getIntExtra(OrbotService.EXTRA_SOCKS_PROXY_PORT, TOR_TRANSPROXY_PORT_DEFAULT);
|
||||||
int torDns = intent.getIntExtra(OrbotService.EXTRA_DNS_PORT, -1);
|
int torDns = intent.getIntExtra(OrbotService.EXTRA_DNS_PORT, TOR_DNS_PORT_DEFAULT);
|
||||||
|
|
||||||
//if running, we need to restart
|
//if running, we need to restart
|
||||||
if ((torSocks != mTorSocks || torDns != mTorDns)) {
|
if ((torSocks != mTorSocks || torDns != mTorDns)) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class Tun2Socks {
|
||||||
private static HashMap<Integer, String> mAppUidBlacklist = new HashMap<>();
|
private static HashMap<Integer, String> mAppUidBlacklist = new HashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
//System.loadLibrary("tun2socks");
|
System.loadLibrary("tun2socks");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
|
|
|
@ -29,8 +29,8 @@ LOCAL_MODULE := pdnsd
|
||||||
LOCAL_SRC_FILES := $(PDNSD_SOURCES:$(LOCAL_PATH)/%=%)
|
LOCAL_SRC_FILES := $(PDNSD_SOURCES:$(LOCAL_PATH)/%=%)
|
||||||
LOCAL_CFLAGS := -Wall -O2 -I$(LOCAL_PATH)/pdnsd -DHAVE_STPCPY
|
LOCAL_CFLAGS := -Wall -O2 -I$(LOCAL_PATH)/pdnsd -DHAVE_STPCPY
|
||||||
|
|
||||||
|
|
||||||
include $(BUILD_EXECUTABLE)
|
include $(BUILD_EXECUTABLE)
|
||||||
|
##include $(BUILD_SHARED_LIBRARY)
|
||||||
|
|
||||||
########################################################
|
########################################################
|
||||||
## libancillary
|
## libancillary
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
libs
|
Loading…
Reference in New Issue