(systemProtocols);
+ if (enabledProtocols.size() > 1) {
+ enabledProtocols.remove("SSLv2");
+ enabledProtocols.remove("SSLv3");
+ } else {
+ Log.w(TAG, "SSL stuck with protocol available for "
+ + String.valueOf(enabledProtocols));
+ }
+ protocols = enabledProtocols.toArray(new String[enabledProtocols.size()]);
+ }
+ super.setEnabledProtocols(protocols);
+ }
+ }
+
+ public class DelegateSSLSocket extends SSLSocket {
+
+ protected final SSLSocket delegate;
+
+ DelegateSSLSocket(SSLSocket delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public String[] getSupportedCipherSuites() {
+ return delegate.getSupportedCipherSuites();
+ }
+
+ @Override
+ public String[] getEnabledCipherSuites() {
+ return delegate.getEnabledCipherSuites();
+ }
+
+ @Override
+ public void setEnabledCipherSuites(String[] suites) {
+ delegate.setEnabledCipherSuites(suites);
+ }
+
+ @Override
+ public String[] getSupportedProtocols() {
+ return delegate.getSupportedProtocols();
+ }
+
+ @Override
+ public String[] getEnabledProtocols() {
+ return delegate.getEnabledProtocols();
+ }
+
+ @Override
+ public void setEnabledProtocols(String[] protocols) {
+ delegate.setEnabledProtocols(protocols);
+ }
+
+ @Override
+ public SSLSession getSession() {
+ return delegate.getSession();
+ }
+
+ @Override
+ public void addHandshakeCompletedListener(HandshakeCompletedListener listener) {
+ delegate.addHandshakeCompletedListener(listener);
+ }
+
+ @Override
+ public void removeHandshakeCompletedListener(HandshakeCompletedListener listener) {
+ delegate.removeHandshakeCompletedListener(listener);
+ }
+
+ @Override
+ public void startHandshake() throws IOException {
+ delegate.startHandshake();
+ }
+
+ @Override
+ public void setUseClientMode(boolean mode) {
+ delegate.setUseClientMode(mode);
+ }
+
+ @Override
+ public boolean getUseClientMode() {
+ return delegate.getUseClientMode();
+ }
+
+ @Override
+ public void setNeedClientAuth(boolean need) {
+ delegate.setNeedClientAuth(need);
+ }
+
+ @Override
+ public void setWantClientAuth(boolean want) {
+ delegate.setWantClientAuth(want);
+ }
+
+ @Override
+ public boolean getNeedClientAuth() {
+ return delegate.getNeedClientAuth();
+ }
+
+ @Override
+ public boolean getWantClientAuth() {
+ return delegate.getWantClientAuth();
+ }
+
+ @Override
+ public void setEnableSessionCreation(boolean flag) {
+ delegate.setEnableSessionCreation(flag);
+ }
+
+ @Override
+ public boolean getEnableSessionCreation() {
+ return delegate.getEnableSessionCreation();
+ }
+
+ @Override
+ public void bind(SocketAddress localAddr) throws IOException {
+ delegate.bind(localAddr);
+ }
+
+ @Override
+ public synchronized void close() throws IOException {
+ delegate.close();
+ }
+
+ @Override
+ public void connect(SocketAddress remoteAddr) throws IOException {
+ delegate.connect(remoteAddr);
+ }
+
+ @Override
+ public void connect(SocketAddress remoteAddr, int timeout) throws IOException {
+ delegate.connect(remoteAddr, timeout);
+ }
+
+ @Override
+ public SocketChannel getChannel() {
+ return delegate.getChannel();
+ }
+
+ @Override
+ public InetAddress getInetAddress() {
+ return delegate.getInetAddress();
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ return delegate.getInputStream();
+ }
+
+ @Override
+ public boolean getKeepAlive() throws SocketException {
+ return delegate.getKeepAlive();
+ }
+
+ @Override
+ public InetAddress getLocalAddress() {
+ return delegate.getLocalAddress();
+ }
+
+ @Override
+ public int getLocalPort() {
+ return delegate.getLocalPort();
+ }
+
+ @Override
+ public SocketAddress getLocalSocketAddress() {
+ return delegate.getLocalSocketAddress();
+ }
+
+ @Override
+ public boolean getOOBInline() throws SocketException {
+ return delegate.getOOBInline();
+ }
+
+ @Override
+ public OutputStream getOutputStream() throws IOException {
+ return delegate.getOutputStream();
+ }
+
+ @Override
+ public int getPort() {
+ return delegate.getPort();
+ }
+
+ @Override
+ public synchronized int getReceiveBufferSize() throws SocketException {
+ return delegate.getReceiveBufferSize();
+ }
+
+ @Override
+ public SocketAddress getRemoteSocketAddress() {
+ return delegate.getRemoteSocketAddress();
+ }
+
+ @Override
+ public boolean getReuseAddress() throws SocketException {
+ return delegate.getReuseAddress();
+ }
+
+ @Override
+ public synchronized int getSendBufferSize() throws SocketException {
+ return delegate.getSendBufferSize();
+ }
+
+ @Override
+ public int getSoLinger() throws SocketException {
+ return delegate.getSoLinger();
+ }
+
+ @Override
+ public synchronized int getSoTimeout() throws SocketException {
+ return delegate.getSoTimeout();
+ }
+
+ @Override
+ public boolean getTcpNoDelay() throws SocketException {
+ return delegate.getTcpNoDelay();
+ }
+
+ @Override
+ public int getTrafficClass() throws SocketException {
+ return delegate.getTrafficClass();
+ }
+
+ @Override
+ public boolean isBound() {
+ return delegate.isBound();
+ }
+
+ @Override
+ public boolean isClosed() {
+ return delegate.isClosed();
+ }
+
+ @Override
+ public boolean isConnected() {
+ return delegate.isConnected();
+ }
+
+ @Override
+ public boolean isInputShutdown() {
+ return delegate.isInputShutdown();
+ }
+
+ @Override
+ public boolean isOutputShutdown() {
+ return delegate.isOutputShutdown();
+ }
+
+ @Override
+ public void sendUrgentData(int value) throws IOException {
+ delegate.sendUrgentData(value);
+ }
+
+ @Override
+ public void setKeepAlive(boolean keepAlive) throws SocketException {
+ delegate.setKeepAlive(keepAlive);
+ }
+
+ @Override
+ public void setOOBInline(boolean oobinline) throws SocketException {
+ delegate.setOOBInline(oobinline);
+ }
+
+ @Override
+ public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) {
+ delegate.setPerformancePreferences(connectionTime,
+ latency, bandwidth);
+ }
+
+ @Override
+ public synchronized void setReceiveBufferSize(int size) throws SocketException {
+ delegate.setReceiveBufferSize(size);
+ }
+
+ @Override
+ public void setReuseAddress(boolean reuse) throws SocketException {
+ delegate.setReuseAddress(reuse);
+ }
+
+ @Override
+ public synchronized void setSendBufferSize(int size) throws SocketException {
+ delegate.setSendBufferSize(size);
+ }
+
+ @Override
+ public void setSoLinger(boolean on, int timeout) throws SocketException {
+ delegate.setSoLinger(on, timeout);
+ }
+
+ @Override
+ public synchronized void setSoTimeout(int timeout) throws SocketException {
+ delegate.setSoTimeout(timeout);
+ }
+
+ @Override
+ public void setTcpNoDelay(boolean on) throws SocketException {
+ delegate.setTcpNoDelay(on);
+ }
+
+ @Override
+ public void setTrafficClass(int value) throws SocketException {
+ delegate.setTrafficClass(value);
+ }
+
+ @Override
+ public void shutdownInput() throws IOException {
+ delegate.shutdownInput();
+ }
+
+ @Override
+ public void shutdownOutput() throws IOException {
+ delegate.shutdownOutput();
+ }
+
+ // inspired by https://github.com/k9mail/k-9/commit/54f9fd36a77423a55f63fbf9b1bcea055a239768
+
+ public DelegateSSLSocket setHostname(String host) {
+ try {
+ delegate
+ .getClass()
+ .getMethod("setHostname", String.class)
+ .invoke(delegate, host);
+ }
+ catch (Exception e) {
+ throw new IllegalStateException("Could not enable SNI", e);
+ }
+
+ return(this);
+ }
+
+ @Override
+ public String toString() {
+ return delegate.toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return delegate.equals(o);
+ }
+ }
+}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/OrbotHelper.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/OrbotHelper.java
similarity index 96%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/OrbotHelper.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/OrbotHelper.java
index 6a191375..ace9ed05 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/OrbotHelper.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/OrbotHelper.java
@@ -1,700 +1,700 @@
-/*
- * Copyright 2014-2016 Hans-Christoph Steiner
- * Copyright 2012-2016 Nathan Freitas
- * Portions Copyright (c) 2016 CommonsWare, LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.darkweb.genesissearchengine.libs.netcipher.proxy;
-
-import android.app.Activity;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.net.Uri;
-import android.os.Handler;
-import android.os.Looper;
-import android.text.TextUtils;
-import android.util.Log;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-
-/**
- * Utility class to simplify setting up a proxy connection
- * to Orbot.
- *
- * If you are using classes in the info.guardianproject.netcipher.client
- * package, call OrbotHelper.get(this).init(); from onCreate()
- * of a custom Application subclass, or from some other guaranteed
- * entry point to your app. At that point, the
- * info.guardianproject.netcipher.client classes will be ready
- * for use.
- */
-public class OrbotHelper implements ProxyHelper {
-
- private final static int REQUEST_CODE_STATUS = 100;
-
- public final static String ORBOT_PACKAGE_NAME = "org.torproject.android";
- public final static String ORBOT_MARKET_URI = "market://details?id=" + ORBOT_PACKAGE_NAME;
- public final static String ORBOT_FDROID_URI = "https://f-droid.org/repository/browse/?fdid="
- + ORBOT_PACKAGE_NAME;
- public final static String ORBOT_PLAY_URI = "https://play.google.com/store/apps/details?id="
- + ORBOT_PACKAGE_NAME;
-
- /**
- * A request to Orbot to transparently start Tor services
- */
- public final static String ACTION_START = "org.torproject.android.intent.action.START";
-
- /**
- * {@link Intent} send by Orbot with {@code ON/OFF/STARTING/STOPPING} status
- * included as an {@link #EXTRA_STATUS} {@code String}. Your app should
- * always receive {@code ACTION_STATUS Intent}s since any other app could
- * start Orbot. Also, user-triggered starts and stops will also cause
- * {@code ACTION_STATUS Intent}s to be broadcast.
- */
- public final static String ACTION_STATUS = "org.torproject.android.intent.action.STATUS";
-
- /**
- * {@code String} that contains a status constant: {@link #STATUS_ON},
- * {@link #STATUS_OFF}, {@link #STATUS_STARTING}, or
- * {@link #STATUS_STOPPING}
- */
- public final static String EXTRA_STATUS = "org.torproject.android.intent.extra.STATUS";
- /**
- * A {@link String} {@code packageName} for Orbot to direct its status reply
- * to, used in {@link #ACTION_START} {@link Intent}s sent to Orbot
- */
- public final static String EXTRA_PACKAGE_NAME = "org.torproject.android.intent.extra.PACKAGE_NAME";
-
- public final static String EXTRA_PROXY_PORT_HTTP = "org.torproject.android.intent.extra.HTTP_PROXY_PORT";
- public final static String EXTRA_PROXY_PORT_SOCKS = "org.torproject.android.intent.extra.SOCKS_PROXY_PORT";
-
-
- /**
- * All tor-related services and daemons are stopped
- */
- public final static String STATUS_OFF = "OFF";
- /**
- * All tor-related services and daemons have completed starting
- */
- public final static String STATUS_ON = "ON";
- public final static String STATUS_STARTING = "STARTING";
- public final static String STATUS_STOPPING = "STOPPING";
- /**
- * The user has disabled the ability for background starts triggered by
- * apps. Fallback to the old Intent that brings up Orbot.
- */
- public final static String STATUS_STARTS_DISABLED = "STARTS_DISABLED";
-
- public final static String ACTION_START_TOR = "org.torproject.android.START_TOR";
- public final static String ACTION_REQUEST_HS = "org.torproject.android.REQUEST_HS_PORT";
- public final static int START_TOR_RESULT = 0x9234;
- public final static int HS_REQUEST_CODE = 9999;
-
-
-/*
- private OrbotHelper() {
- // only static utility methods, do not instantiate
- }
-*/
-
- /**
- * Test whether a {@link URL} is a Tor Hidden Service host name, also known
- * as an ".onion address".
- *
- * @return whether the host name is a Tor .onion address
- */
- public static boolean isOnionAddress(URL url) {
- return url.getHost().endsWith(".onion");
- }
-
- /**
- * Test whether a URL {@link String} is a Tor Hidden Service host name, also known
- * as an ".onion address".
- *
- * @return whether the host name is a Tor .onion address
- */
- public static boolean isOnionAddress(String urlString) {
- try {
- return isOnionAddress(new URL(urlString));
- } catch (MalformedURLException e) {
- return false;
- }
- }
-
- /**
- * Test whether a {@link Uri} is a Tor Hidden Service host name, also known
- * as an ".onion address".
- *
- * @return whether the host name is a Tor .onion address
- */
- public static boolean isOnionAddress(Uri uri) {
- return uri.getHost().endsWith(".onion");
- }
-
- /**
- * Check if the tor process is running. This method is very
- * brittle, and is therefore deprecated in favor of using the
- * {@link #ACTION_STATUS} {@code Intent} along with the
- * {@link #requestStartTor(Context)} method.
- */
- @Deprecated
- public static boolean isOrbotRunning(Context context) {
- int procId = TorServiceUtils.findProcessId(context);
-
- return (procId != -1);
- }
-
- public static boolean isOrbotInstalled(Context context) {
- return isAppInstalled(context, ORBOT_PACKAGE_NAME);
- }
-
- private static boolean isAppInstalled(Context context, String uri) {
- try {
- PackageManager pm = context.getPackageManager();
- pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
- return true;
- } catch (PackageManager.NameNotFoundException e) {
- return false;
- }
- }
-
- public static void requestHiddenServiceOnPort(Activity activity, int port) {
- Intent intent = new Intent(ACTION_REQUEST_HS);
- intent.setPackage(ORBOT_PACKAGE_NAME);
- intent.putExtra("hs_port", port);
-
- activity.startActivityForResult(intent, HS_REQUEST_CODE);
- }
-
- /**
- * First, checks whether Orbot is installed. If Orbot is installed, then a
- * broadcast {@link Intent} is sent to request Orbot to start
- * transparently in the background. When Orbot receives this {@code
- * Intent}, it will immediately reply to the app that called this method
- * with an {@link #ACTION_STATUS} {@code Intent} that is broadcast to the
- * {@code packageName} of the provided {@link Context} (i.e. {@link
- * Context#getPackageName()}.
- *
- * That reply {@link #ACTION_STATUS} {@code Intent} could say that the user
- * has disabled background starts with the status
- * {@link #STATUS_STARTS_DISABLED}. That means that Orbot ignored this
- * request. To directly prompt the user to start Tor, use
- * {@link #requestShowOrbotStart(Activity)}, which will bring up
- * Orbot itself for the user to manually start Tor. Orbot always broadcasts
- * it's status, so your app will receive those no matter how Tor gets
- * started.
- *
- * @param context the app {@link Context} will receive the reply
- * @return whether the start request was sent to Orbot
- * @see #requestShowOrbotStart(Activity activity)
- */
- public static boolean requestStartTor(Context context) {
- if (OrbotHelper.isOrbotInstalled(context)) {
- Log.i("OrbotHelper", "requestStartTor " + context.getPackageName());
- Intent intent = getOrbotStartIntent(context);
- context.sendBroadcast(intent);
- return true;
- }
- return false;
- }
-
- /**
- * Gets an {@link Intent} for starting Orbot. Orbot will reply with the
- * current status to the {@code packageName} of the app in the provided
- * {@link Context} (i.e. {@link Context#getPackageName()}.
- */
- public static Intent getOrbotStartIntent(Context context) {
- Intent intent = new Intent(ACTION_START);
- intent.setPackage(ORBOT_PACKAGE_NAME);
- intent.putExtra(EXTRA_PACKAGE_NAME, context.getPackageName());
- return intent;
- }
-
- /**
- * Gets a barebones {@link Intent} for starting Orbot. This is deprecated
- * in favor of {@link #getOrbotStartIntent(Context)}.
- */
- @Deprecated
- public static Intent getOrbotStartIntent() {
- Intent intent = new Intent(ACTION_START);
- intent.setPackage(ORBOT_PACKAGE_NAME);
- return intent;
- }
-
- /**
- * First, checks whether Orbot is installed, then checks whether Orbot is
- * running. If Orbot is installed and not running, then an {@link Intent} is
- * sent to request the user to start Orbot, which will show the main Orbot screen.
- * The result will be returned in
- * {@link Activity#onActivityResult(int requestCode, int resultCode, Intent data)}
- * with a {@code requestCode} of {@code START_TOR_RESULT}
- *
- * Orbot will also always broadcast the status of starting Tor via the
- * {@link #ACTION_STATUS} Intent, no matter how it is started.
- *
- * @param activity the {@code Activity} that gets the result of the
- * {@link #START_TOR_RESULT} request
- * @return whether the start request was sent to Orbot
- * @see #requestStartTor(Context context)
- */
- public static boolean requestShowOrbotStart(Activity activity) {
- if (OrbotHelper.isOrbotInstalled(activity)) {
- if (!OrbotHelper.isOrbotRunning(activity)) {
- Intent intent = getShowOrbotStartIntent();
- activity.startActivityForResult(intent, START_TOR_RESULT);
- return true;
- }
- }
- return false;
- }
-
- public static Intent getShowOrbotStartIntent() {
- Intent intent = new Intent(ACTION_START_TOR);
- intent.setPackage(ORBOT_PACKAGE_NAME);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- return intent;
- }
-
- public static Intent getOrbotInstallIntent(Context context) {
- final Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse(ORBOT_MARKET_URI));
-
- PackageManager pm = context.getPackageManager();
- List resInfos = pm.queryIntentActivities(intent, 0);
-
- String foundPackageName = null;
- for (ResolveInfo r : resInfos) {
- Log.i("OrbotHelper", "market: " + r.activityInfo.packageName);
- if (TextUtils.equals(r.activityInfo.packageName, FDROID_PACKAGE_NAME)
- || TextUtils.equals(r.activityInfo.packageName, PLAY_PACKAGE_NAME)) {
- foundPackageName = r.activityInfo.packageName;
- break;
- }
- }
-
- if (foundPackageName == null) {
- intent.setData(Uri.parse(ORBOT_FDROID_URI));
- } else {
- intent.setPackage(foundPackageName);
- }
- return intent;
- }
-
- @Override
- public boolean isInstalled(Context context) {
- return isOrbotInstalled(context);
- }
-
- @Override
- public void requestStatus(Context context) {
- isOrbotRunning(context);
- }
-
- @Override
- public boolean requestStart(Context context) {
- return requestStartTor(context);
- }
-
- @Override
- public Intent getInstallIntent(Context context) {
- return getOrbotInstallIntent(context);
- }
-
- @Override
- public Intent getStartIntent(Context context) {
- return getOrbotStartIntent();
- }
-
- @Override
- public String getName() {
- return "Orbot";
- }
-
- /* MLM additions */
-
- private final Context ctxt;
- private final Handler handler;
- private boolean isInstalled=false;
- private Intent lastStatusIntent=null;
- private Set statusCallbacks=
- newSetFromMap(new WeakHashMap());
- private Set installCallbacks=
- newSetFromMap(new WeakHashMap());
- private long statusTimeoutMs=30000L;
- private long installTimeoutMs=60000L;
- private boolean validateOrbot=true;
-
- abstract public static class SimpleStatusCallback
- implements StatusCallback {
- @Override
- public void onEnabled(Intent statusIntent) {
- // no-op; extend and override if needed
- }
-
- @Override
- public void onStarting() {
- // no-op; extend and override if needed
- }
-
- @Override
- public void onStopping() {
- // no-op; extend and override if needed
- }
-
- @Override
- public void onDisabled() {
- // no-op; extend and override if needed
- }
-
- @Override
- public void onNotYetInstalled() {
- // no-op; extend and override if needed
- }
- }
-
- /**
- * Callback interface used for reporting the results of an
- * attempt to install Orbot
- */
- public interface InstallCallback {
- void onInstalled();
- void onInstallTimeout();
- }
-
- private static volatile OrbotHelper INSTANCE;
-
- /**
- * Retrieves the singleton, initializing if if needed
- *
- * @param ctxt any Context will do, as we will hold onto
- * the Application
- * @return the singleton
- */
- synchronized public static OrbotHelper get(Context ctxt) {
- if (INSTANCE==null) {
- INSTANCE=new OrbotHelper(ctxt);
- }
-
- return(INSTANCE);
- }
-
- /**
- * Standard constructor
- *
- * @param ctxt any Context will do; OrbotInitializer will hold
- * onto the Application context
- */
- private OrbotHelper(Context ctxt) {
- this.ctxt=ctxt.getApplicationContext();
- this.handler=new Handler(Looper.getMainLooper());
- }
-
- /**
- * Adds a StatusCallback to be called when we find out that
- * Orbot is ready. If Orbot is ready for use, your callback
- * will be called with onEnabled() immediately, before this
- * method returns.
- *
- * @param cb a callback
- * @return the singleton, for chaining
- */
- public OrbotHelper addStatusCallback(StatusCallback cb) {
- statusCallbacks.add(cb);
-
- if (lastStatusIntent!=null) {
- String status=
- lastStatusIntent.getStringExtra(OrbotHelper.EXTRA_STATUS);
-
- if (status.equals(OrbotHelper.STATUS_ON)) {
- cb.onEnabled(lastStatusIntent);
- }
- }
-
- return(this);
- }
-
- /**
- * Removes an existing registered StatusCallback.
- *
- * @param cb the callback to remove
- * @return the singleton, for chaining
- */
- public OrbotHelper removeStatusCallback(StatusCallback cb) {
- statusCallbacks.remove(cb);
-
- return(this);
- }
-
-
- /**
- * Adds an InstallCallback to be called when we find out that
- * Orbot is installed
- *
- * @param cb a callback
- * @return the singleton, for chaining
- */
- public OrbotHelper addInstallCallback(InstallCallback cb) {
- installCallbacks.add(cb);
-
- return(this);
- }
-
- /**
- * Removes an existing registered InstallCallback.
- *
- * @param cb the callback to remove
- * @return the singleton, for chaining
- */
- public OrbotHelper removeInstallCallback(InstallCallback cb) {
- installCallbacks.remove(cb);
-
- return(this);
- }
-
- /**
- * Sets how long of a delay, in milliseconds, after trying
- * to get a status from Orbot before we give up.
- * Defaults to 30000ms = 30 seconds = 0.000347222 days
- *
- * @param timeoutMs delay period in milliseconds
- * @return the singleton, for chaining
- */
- public OrbotHelper statusTimeout(long timeoutMs) {
- statusTimeoutMs=timeoutMs;
-
- return(this);
- }
-
- /**
- * Sets how long of a delay, in milliseconds, after trying
- * to install Orbot do we assume that it's not happening.
- * Defaults to 60000ms = 60 seconds = 1 minute = 1.90259e-6 years
- *
- * @param timeoutMs delay period in milliseconds
- * @return the singleton, for chaining
- */
- public OrbotHelper installTimeout(long timeoutMs) {
- installTimeoutMs=timeoutMs;
-
- return(this);
- }
-
- /**
- * By default, NetCipher ensures that the Orbot on the
- * device is one of the official builds. Call this method
- * to skip that validation. Mostly, this is for developers
- * who have their own custom Orbot builds (e.g., for
- * dedicated hardware).
- *
- * @return the singleton, for chaining
- */
- public OrbotHelper skipOrbotValidation() {
- validateOrbot=false;
-
- return(this);
- }
-
- /**
- * @return true if Orbot is installed (the last time we checked),
- * false otherwise
- */
- public boolean isInstalled() {
- return(isInstalled);
- }
-
- /**
- * Initializes the connection to Orbot, revalidating that it
- * is installed and requesting fresh status broadcasts.
- *
- * @return true if initialization is proceeding, false if
- * Orbot is not installed
- */
- public boolean init() {
- Intent orbot=OrbotHelper.getOrbotStartIntent(ctxt);
-
- if (validateOrbot) {
- ArrayList hashes=new ArrayList();
-
- hashes.add("A4:54:B8:7A:18:47:A8:9E:D7:F5:E7:0F:BA:6B:BA:96:F3:EF:29:C2:6E:09:81:20:4F:E3:47:BF:23:1D:FD:5B");
- hashes.add("A7:02:07:92:4F:61:FF:09:37:1D:54:84:14:5C:4B:EE:77:2C:55:C1:9E:EE:23:2F:57:70:E1:82:71:F7:CB:AE");
-
- orbot=
- SignatureUtils.validateBroadcastIntent(ctxt, orbot,
- hashes, false);
- }
-
- if (orbot!=null) {
- isInstalled=true;
- handler.postDelayed(onStatusTimeout, statusTimeoutMs);
- ctxt.registerReceiver(orbotStatusReceiver,
- new IntentFilter(OrbotHelper.ACTION_STATUS));
- ctxt.sendBroadcast(orbot);
- }
- else {
- isInstalled=false;
-
- for (StatusCallback cb : statusCallbacks) {
- cb.onNotYetInstalled();
- }
- }
-
- return(isInstalled);
- }
-
- /**
- * Given that init() returned false, calling installOrbot()
- * will trigger an attempt to install Orbot from an available
- * distribution channel (e.g., the Play Store). Only call this
- * if the user is expecting it, such as in response to tapping
- * a dialog button or an action bar item.
- *
- * Note that installation may take a long time, even if
- * the user is proceeding with the installation, due to network
- * speeds, waiting for user input, and so on. Either specify
- * a long timeout, or consider the timeout to be merely advisory
- * and use some other user input to cause you to try
- * init() again after, presumably, Orbot has been installed
- * and configured by the user.
- *
- * If the user does install Orbot, we will attempt init()
- * again automatically. Hence, you will probably need user input
- * to tell you when the user has gotten Orbot up and going.
- *
- * @param host the Activity that is triggering this work
- */
- public void installOrbot(Activity host) {
- handler.postDelayed(onInstallTimeout, installTimeoutMs);
-
- IntentFilter filter=
- new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
-
- filter.addDataScheme("package");
-
- ctxt.registerReceiver(orbotInstallReceiver, filter);
- host.startActivity(OrbotHelper.getOrbotInstallIntent(ctxt));
- }
-
- private BroadcastReceiver orbotStatusReceiver=new BroadcastReceiver() {
- @Override
- public void onReceive(Context ctxt, Intent intent) {
- if (TextUtils.equals(intent.getAction(),
- OrbotHelper.ACTION_STATUS)) {
- String status=intent.getStringExtra(OrbotHelper.EXTRA_STATUS);
-
- if (status.equals(OrbotHelper.STATUS_ON)) {
- lastStatusIntent=intent;
- handler.removeCallbacks(onStatusTimeout);
-
- for (StatusCallback cb : statusCallbacks) {
- cb.onEnabled(intent);
- }
- }
- else if (status.equals(OrbotHelper.STATUS_OFF)) {
- for (StatusCallback cb : statusCallbacks) {
- cb.onDisabled();
- }
- }
- else if (status.equals(OrbotHelper.STATUS_STARTING)) {
- for (StatusCallback cb : statusCallbacks) {
- cb.onStarting();
- }
- }
- else if (status.equals(OrbotHelper.STATUS_STOPPING)) {
- for (StatusCallback cb : statusCallbacks) {
- cb.onStopping();
- }
- }
- }
- }
- };
-
- private Runnable onStatusTimeout=new Runnable() {
- @Override
- public void run() {
- ctxt.unregisterReceiver(orbotStatusReceiver);
-
- for (StatusCallback cb : statusCallbacks) {
- cb.onStatusTimeout();
- }
- }
- };
-
- private BroadcastReceiver orbotInstallReceiver=new BroadcastReceiver() {
- @Override
- public void onReceive(Context ctxt, Intent intent) {
- if (TextUtils.equals(intent.getAction(),
- Intent.ACTION_PACKAGE_ADDED)) {
- String pkgName=intent.getData().getEncodedSchemeSpecificPart();
-
- if (OrbotHelper.ORBOT_PACKAGE_NAME.equals(pkgName)) {
- isInstalled=true;
- handler.removeCallbacks(onInstallTimeout);
- ctxt.unregisterReceiver(orbotInstallReceiver);
-
- for (InstallCallback cb : installCallbacks) {
- cb.onInstalled();
- }
-
- init();
- }
- }
- }
- };
-
- private Runnable onInstallTimeout=new Runnable() {
- @Override
- public void run() {
- ctxt.unregisterReceiver(orbotInstallReceiver);
-
- for (InstallCallback cb : installCallbacks) {
- cb.onInstallTimeout();
- }
- }
- };
-
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- static Set newSetFromMap(Map map) {
- if (map.isEmpty()) {
- return new SetFromMap(map);
- }
- throw new IllegalArgumentException("map not empty");
- }
-}
+/*
+ * Copyright 2014-2016 Hans-Christoph Steiner
+ * Copyright 2012-2016 Nathan Freitas
+ * Portions Copyright (c) 2016 CommonsWare, LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hiddenservices.genesissearchengine.production.libs.netcipher.proxy;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.net.Uri;
+import android.os.Handler;
+import android.os.Looper;
+import android.text.TextUtils;
+import android.util.Log;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+/**
+ * Utility class to simplify setting up a proxy connection
+ * to Orbot.
+ *
+ * If you are using classes in the info.guardianproject.netcipher.client
+ * package, call OrbotHelper.get(this).init(); from onCreate()
+ * of a custom Application subclass, or from some other guaranteed
+ * entry point to your app. At that point, the
+ * info.guardianproject.netcipher.client classes will be ready
+ * for use.
+ */
+public class OrbotHelper implements ProxyHelper {
+
+ private final static int REQUEST_CODE_STATUS = 100;
+
+ public final static String ORBOT_PACKAGE_NAME = "org.torproject.android";
+ public final static String ORBOT_MARKET_URI = "market://details?id=" + ORBOT_PACKAGE_NAME;
+ public final static String ORBOT_FDROID_URI = "https://f-droid.org/repository/browse/?fdid="
+ + ORBOT_PACKAGE_NAME;
+ public final static String ORBOT_PLAY_URI = "https://play.google.com/store/apps/details?id="
+ + ORBOT_PACKAGE_NAME;
+
+ /**
+ * A request to Orbot to transparently start Tor services
+ */
+ public final static String ACTION_START = "org.torproject.android.intent.action.START";
+
+ /**
+ * {@link Intent} send by Orbot with {@code ON/OFF/STARTING/STOPPING} status
+ * included as an {@link #EXTRA_STATUS} {@code String}. Your app should
+ * always receive {@code ACTION_STATUS Intent}s since any other app could
+ * start Orbot. Also, user-triggered starts and stops will also cause
+ * {@code ACTION_STATUS Intent}s to be broadcast.
+ */
+ public final static String ACTION_STATUS = "org.torproject.android.intent.action.STATUS";
+
+ /**
+ * {@code String} that contains a status constant: {@link #STATUS_ON},
+ * {@link #STATUS_OFF}, {@link #STATUS_STARTING}, or
+ * {@link #STATUS_STOPPING}
+ */
+ public final static String EXTRA_STATUS = "org.torproject.android.intent.extra.STATUS";
+ /**
+ * A {@link String} {@code packageName} for Orbot to direct its status reply
+ * to, used in {@link #ACTION_START} {@link Intent}s sent to Orbot
+ */
+ public final static String EXTRA_PACKAGE_NAME = "org.torproject.android.intent.extra.PACKAGE_NAME";
+
+ public final static String EXTRA_PROXY_PORT_HTTP = "org.torproject.android.intent.extra.HTTP_PROXY_PORT";
+ public final static String EXTRA_PROXY_PORT_SOCKS = "org.torproject.android.intent.extra.SOCKS_PROXY_PORT";
+
+
+ /**
+ * All tor-related services and daemons are stopped
+ */
+ public final static String STATUS_OFF = "OFF";
+ /**
+ * All tor-related services and daemons have completed starting
+ */
+ public final static String STATUS_ON = "ON";
+ public final static String STATUS_STARTING = "STARTING";
+ public final static String STATUS_STOPPING = "STOPPING";
+ /**
+ * The user has disabled the ability for background starts triggered by
+ * apps. Fallback to the old Intent that brings up Orbot.
+ */
+ public final static String STATUS_STARTS_DISABLED = "STARTS_DISABLED";
+
+ public final static String ACTION_START_TOR = "org.torproject.android.START_TOR";
+ public final static String ACTION_REQUEST_HS = "org.torproject.android.REQUEST_HS_PORT";
+ public final static int START_TOR_RESULT = 0x9234;
+ public final static int HS_REQUEST_CODE = 9999;
+
+
+/*
+ private OrbotHelper() {
+ // only static utility methods, do not instantiate
+ }
+*/
+
+ /**
+ * Test whether a {@link URL} is a Tor Hidden Service host name, also known
+ * as an ".onion address".
+ *
+ * @return whether the host name is a Tor .onion address
+ */
+ public static boolean isOnionAddress(URL url) {
+ return url.getHost().endsWith(".onion");
+ }
+
+ /**
+ * Test whether a URL {@link String} is a Tor Hidden Service host name, also known
+ * as an ".onion address".
+ *
+ * @return whether the host name is a Tor .onion address
+ */
+ public static boolean isOnionAddress(String urlString) {
+ try {
+ return isOnionAddress(new URL(urlString));
+ } catch (MalformedURLException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Test whether a {@link Uri} is a Tor Hidden Service host name, also known
+ * as an ".onion address".
+ *
+ * @return whether the host name is a Tor .onion address
+ */
+ public static boolean isOnionAddress(Uri uri) {
+ return uri.getHost().endsWith(".onion");
+ }
+
+ /**
+ * Check if the tor process is running. This method is very
+ * brittle, and is therefore deprecated in favor of using the
+ * {@link #ACTION_STATUS} {@code Intent} along with the
+ * {@link #requestStartTor(Context)} method.
+ */
+ @Deprecated
+ public static boolean isOrbotRunning(Context context) {
+ int procId = TorServiceUtils.findProcessId(context);
+
+ return (procId != -1);
+ }
+
+ public static boolean isOrbotInstalled(Context context) {
+ return isAppInstalled(context, ORBOT_PACKAGE_NAME);
+ }
+
+ private static boolean isAppInstalled(Context context, String uri) {
+ try {
+ PackageManager pm = context.getPackageManager();
+ pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
+ return true;
+ } catch (PackageManager.NameNotFoundException e) {
+ return false;
+ }
+ }
+
+ public static void requestHiddenServiceOnPort(Activity activity, int port) {
+ Intent intent = new Intent(ACTION_REQUEST_HS);
+ intent.setPackage(ORBOT_PACKAGE_NAME);
+ intent.putExtra("hs_port", port);
+
+ activity.startActivityForResult(intent, HS_REQUEST_CODE);
+ }
+
+ /**
+ * First, checks whether Orbot is installed. If Orbot is installed, then a
+ * broadcast {@link Intent} is sent to request Orbot to start
+ * transparently in the background. When Orbot receives this {@code
+ * Intent}, it will immediately reply to the app that called this method
+ * with an {@link #ACTION_STATUS} {@code Intent} that is broadcast to the
+ * {@code packageName} of the provided {@link Context} (i.e. {@link
+ * Context#getPackageName()}.
+ *
+ * That reply {@link #ACTION_STATUS} {@code Intent} could say that the user
+ * has disabled background starts with the status
+ * {@link #STATUS_STARTS_DISABLED}. That means that Orbot ignored this
+ * request. To directly prompt the user to start Tor, use
+ * {@link #requestShowOrbotStart(Activity)}, which will bring up
+ * Orbot itself for the user to manually start Tor. Orbot always broadcasts
+ * it's status, so your app will receive those no matter how Tor gets
+ * started.
+ *
+ * @param context the app {@link Context} will receive the reply
+ * @return whether the start request was sent to Orbot
+ * @see #requestShowOrbotStart(Activity activity)
+ */
+ public static boolean requestStartTor(Context context) {
+ if (OrbotHelper.isOrbotInstalled(context)) {
+ Log.i("OrbotHelper", "requestStartTor " + context.getPackageName());
+ Intent intent = getOrbotStartIntent(context);
+ context.sendBroadcast(intent);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Gets an {@link Intent} for starting Orbot. Orbot will reply with the
+ * current status to the {@code packageName} of the app in the provided
+ * {@link Context} (i.e. {@link Context#getPackageName()}.
+ */
+ public static Intent getOrbotStartIntent(Context context) {
+ Intent intent = new Intent(ACTION_START);
+ intent.setPackage(ORBOT_PACKAGE_NAME);
+ intent.putExtra(EXTRA_PACKAGE_NAME, context.getPackageName());
+ return intent;
+ }
+
+ /**
+ * Gets a barebones {@link Intent} for starting Orbot. This is deprecated
+ * in favor of {@link #getOrbotStartIntent(Context)}.
+ */
+ @Deprecated
+ public static Intent getOrbotStartIntent() {
+ Intent intent = new Intent(ACTION_START);
+ intent.setPackage(ORBOT_PACKAGE_NAME);
+ return intent;
+ }
+
+ /**
+ * First, checks whether Orbot is installed, then checks whether Orbot is
+ * running. If Orbot is installed and not running, then an {@link Intent} is
+ * sent to request the user to start Orbot, which will show the main Orbot screen.
+ * The result will be returned in
+ * {@link Activity#onActivityResult(int requestCode, int resultCode, Intent data)}
+ * with a {@code requestCode} of {@code START_TOR_RESULT}
+ *
+ * Orbot will also always broadcast the status of starting Tor via the
+ * {@link #ACTION_STATUS} Intent, no matter how it is started.
+ *
+ * @param activity the {@code Activity} that gets the result of the
+ * {@link #START_TOR_RESULT} request
+ * @return whether the start request was sent to Orbot
+ * @see #requestStartTor(Context context)
+ */
+ public static boolean requestShowOrbotStart(Activity activity) {
+ if (OrbotHelper.isOrbotInstalled(activity)) {
+ if (!OrbotHelper.isOrbotRunning(activity)) {
+ Intent intent = getShowOrbotStartIntent();
+ activity.startActivityForResult(intent, START_TOR_RESULT);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static Intent getShowOrbotStartIntent() {
+ Intent intent = new Intent(ACTION_START_TOR);
+ intent.setPackage(ORBOT_PACKAGE_NAME);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ return intent;
+ }
+
+ public static Intent getOrbotInstallIntent(Context context) {
+ final Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setData(Uri.parse(ORBOT_MARKET_URI));
+
+ PackageManager pm = context.getPackageManager();
+ List resInfos = pm.queryIntentActivities(intent, 0);
+
+ String foundPackageName = null;
+ for (ResolveInfo r : resInfos) {
+ Log.i("OrbotHelper", "market: " + r.activityInfo.packageName);
+ if (TextUtils.equals(r.activityInfo.packageName, FDROID_PACKAGE_NAME)
+ || TextUtils.equals(r.activityInfo.packageName, PLAY_PACKAGE_NAME)) {
+ foundPackageName = r.activityInfo.packageName;
+ break;
+ }
+ }
+
+ if (foundPackageName == null) {
+ intent.setData(Uri.parse(ORBOT_FDROID_URI));
+ } else {
+ intent.setPackage(foundPackageName);
+ }
+ return intent;
+ }
+
+ @Override
+ public boolean isInstalled(Context context) {
+ return isOrbotInstalled(context);
+ }
+
+ @Override
+ public void requestStatus(Context context) {
+ isOrbotRunning(context);
+ }
+
+ @Override
+ public boolean requestStart(Context context) {
+ return requestStartTor(context);
+ }
+
+ @Override
+ public Intent getInstallIntent(Context context) {
+ return getOrbotInstallIntent(context);
+ }
+
+ @Override
+ public Intent getStartIntent(Context context) {
+ return getOrbotStartIntent();
+ }
+
+ @Override
+ public String getName() {
+ return "Orbot";
+ }
+
+ /* MLM additions */
+
+ private final Context ctxt;
+ private final Handler handler;
+ private boolean isInstalled=false;
+ private Intent lastStatusIntent=null;
+ private Set statusCallbacks=
+ newSetFromMap(new WeakHashMap());
+ private Set installCallbacks=
+ newSetFromMap(new WeakHashMap());
+ private long statusTimeoutMs=30000L;
+ private long installTimeoutMs=60000L;
+ private boolean validateOrbot=true;
+
+ abstract public static class SimpleStatusCallback
+ implements StatusCallback {
+ @Override
+ public void onEnabled(Intent statusIntent) {
+ // no-op; extend and override if needed
+ }
+
+ @Override
+ public void onStarting() {
+ // no-op; extend and override if needed
+ }
+
+ @Override
+ public void onStopping() {
+ // no-op; extend and override if needed
+ }
+
+ @Override
+ public void onDisabled() {
+ // no-op; extend and override if needed
+ }
+
+ @Override
+ public void onNotYetInstalled() {
+ // no-op; extend and override if needed
+ }
+ }
+
+ /**
+ * Callback interface used for reporting the results of an
+ * attempt to install Orbot
+ */
+ public interface InstallCallback {
+ void onInstalled();
+ void onInstallTimeout();
+ }
+
+ private static volatile OrbotHelper INSTANCE;
+
+ /**
+ * Retrieves the singleton, initializing if if needed
+ *
+ * @param ctxt any Context will do, as we will hold onto
+ * the Application
+ * @return the singleton
+ */
+ synchronized public static OrbotHelper get(Context ctxt) {
+ if (INSTANCE==null) {
+ INSTANCE=new OrbotHelper(ctxt);
+ }
+
+ return(INSTANCE);
+ }
+
+ /**
+ * Standard constructor
+ *
+ * @param ctxt any Context will do; OrbotInitializer will hold
+ * onto the Application context
+ */
+ private OrbotHelper(Context ctxt) {
+ this.ctxt=ctxt.getApplicationContext();
+ this.handler=new Handler(Looper.getMainLooper());
+ }
+
+ /**
+ * Adds a StatusCallback to be called when we find out that
+ * Orbot is ready. If Orbot is ready for use, your callback
+ * will be called with onEnabled() immediately, before this
+ * method returns.
+ *
+ * @param cb a callback
+ * @return the singleton, for chaining
+ */
+ public OrbotHelper addStatusCallback(StatusCallback cb) {
+ statusCallbacks.add(cb);
+
+ if (lastStatusIntent!=null) {
+ String status=
+ lastStatusIntent.getStringExtra(OrbotHelper.EXTRA_STATUS);
+
+ if (status.equals(OrbotHelper.STATUS_ON)) {
+ cb.onEnabled(lastStatusIntent);
+ }
+ }
+
+ return(this);
+ }
+
+ /**
+ * Removes an existing registered StatusCallback.
+ *
+ * @param cb the callback to remove
+ * @return the singleton, for chaining
+ */
+ public OrbotHelper removeStatusCallback(StatusCallback cb) {
+ statusCallbacks.remove(cb);
+
+ return(this);
+ }
+
+
+ /**
+ * Adds an InstallCallback to be called when we find out that
+ * Orbot is installed
+ *
+ * @param cb a callback
+ * @return the singleton, for chaining
+ */
+ public OrbotHelper addInstallCallback(InstallCallback cb) {
+ installCallbacks.add(cb);
+
+ return(this);
+ }
+
+ /**
+ * Removes an existing registered InstallCallback.
+ *
+ * @param cb the callback to remove
+ * @return the singleton, for chaining
+ */
+ public OrbotHelper removeInstallCallback(InstallCallback cb) {
+ installCallbacks.remove(cb);
+
+ return(this);
+ }
+
+ /**
+ * Sets how long of a delay, in milliseconds, after trying
+ * to get a status from Orbot before we give up.
+ * Defaults to 30000ms = 30 seconds = 0.000347222 days
+ *
+ * @param timeoutMs delay period in milliseconds
+ * @return the singleton, for chaining
+ */
+ public OrbotHelper statusTimeout(long timeoutMs) {
+ statusTimeoutMs=timeoutMs;
+
+ return(this);
+ }
+
+ /**
+ * Sets how long of a delay, in milliseconds, after trying
+ * to install Orbot do we assume that it's not happening.
+ * Defaults to 60000ms = 60 seconds = 1 minute = 1.90259e-6 years
+ *
+ * @param timeoutMs delay period in milliseconds
+ * @return the singleton, for chaining
+ */
+ public OrbotHelper installTimeout(long timeoutMs) {
+ installTimeoutMs=timeoutMs;
+
+ return(this);
+ }
+
+ /**
+ * By default, NetCipher ensures that the Orbot on the
+ * device is one of the official builds. Call this method
+ * to skip that validation. Mostly, this is for developers
+ * who have their own custom Orbot builds (e.g., for
+ * dedicated hardware).
+ *
+ * @return the singleton, for chaining
+ */
+ public OrbotHelper skipOrbotValidation() {
+ validateOrbot=false;
+
+ return(this);
+ }
+
+ /**
+ * @return true if Orbot is installed (the last time we checked),
+ * false otherwise
+ */
+ public boolean isInstalled() {
+ return(isInstalled);
+ }
+
+ /**
+ * Initializes the connection to Orbot, revalidating that it
+ * is installed and requesting fresh status broadcasts.
+ *
+ * @return true if initialization is proceeding, false if
+ * Orbot is not installed
+ */
+ public boolean init() {
+ Intent orbot=OrbotHelper.getOrbotStartIntent(ctxt);
+
+ if (validateOrbot) {
+ ArrayList hashes=new ArrayList();
+
+ hashes.add("A4:54:B8:7A:18:47:A8:9E:D7:F5:E7:0F:BA:6B:BA:96:F3:EF:29:C2:6E:09:81:20:4F:E3:47:BF:23:1D:FD:5B");
+ hashes.add("A7:02:07:92:4F:61:FF:09:37:1D:54:84:14:5C:4B:EE:77:2C:55:C1:9E:EE:23:2F:57:70:E1:82:71:F7:CB:AE");
+
+ orbot=
+ SignatureUtils.validateBroadcastIntent(ctxt, orbot,
+ hashes, false);
+ }
+
+ if (orbot!=null) {
+ isInstalled=true;
+ handler.postDelayed(onStatusTimeout, statusTimeoutMs);
+ ctxt.registerReceiver(orbotStatusReceiver,
+ new IntentFilter(OrbotHelper.ACTION_STATUS));
+ ctxt.sendBroadcast(orbot);
+ }
+ else {
+ isInstalled=false;
+
+ for (StatusCallback cb : statusCallbacks) {
+ cb.onNotYetInstalled();
+ }
+ }
+
+ return(isInstalled);
+ }
+
+ /**
+ * Given that init() returned false, calling installOrbot()
+ * will trigger an attempt to install Orbot from an available
+ * distribution channel (e.g., the Play Store). Only call this
+ * if the user is expecting it, such as in response to tapping
+ * a dialog button or an action bar item.
+ *
+ * Note that installation may take a long time, even if
+ * the user is proceeding with the installation, due to network
+ * speeds, waiting for user input, and so on. Either specify
+ * a long timeout, or consider the timeout to be merely advisory
+ * and use some other user input to cause you to try
+ * init() again after, presumably, Orbot has been installed
+ * and configured by the user.
+ *
+ * If the user does install Orbot, we will attempt init()
+ * again automatically. Hence, you will probably need user input
+ * to tell you when the user has gotten Orbot up and going.
+ *
+ * @param host the Activity that is triggering this work
+ */
+ public void installOrbot(Activity host) {
+ handler.postDelayed(onInstallTimeout, installTimeoutMs);
+
+ IntentFilter filter=
+ new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
+
+ filter.addDataScheme("package");
+
+ ctxt.registerReceiver(orbotInstallReceiver, filter);
+ host.startActivity(OrbotHelper.getOrbotInstallIntent(ctxt));
+ }
+
+ private BroadcastReceiver orbotStatusReceiver=new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context ctxt, Intent intent) {
+ if (TextUtils.equals(intent.getAction(),
+ OrbotHelper.ACTION_STATUS)) {
+ String status=intent.getStringExtra(OrbotHelper.EXTRA_STATUS);
+
+ if (status.equals(OrbotHelper.STATUS_ON)) {
+ lastStatusIntent=intent;
+ handler.removeCallbacks(onStatusTimeout);
+
+ for (StatusCallback cb : statusCallbacks) {
+ cb.onEnabled(intent);
+ }
+ }
+ else if (status.equals(OrbotHelper.STATUS_OFF)) {
+ for (StatusCallback cb : statusCallbacks) {
+ cb.onDisabled();
+ }
+ }
+ else if (status.equals(OrbotHelper.STATUS_STARTING)) {
+ for (StatusCallback cb : statusCallbacks) {
+ cb.onStarting();
+ }
+ }
+ else if (status.equals(OrbotHelper.STATUS_STOPPING)) {
+ for (StatusCallback cb : statusCallbacks) {
+ cb.onStopping();
+ }
+ }
+ }
+ }
+ };
+
+ private Runnable onStatusTimeout=new Runnable() {
+ @Override
+ public void run() {
+ ctxt.unregisterReceiver(orbotStatusReceiver);
+
+ for (StatusCallback cb : statusCallbacks) {
+ cb.onStatusTimeout();
+ }
+ }
+ };
+
+ private BroadcastReceiver orbotInstallReceiver=new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context ctxt, Intent intent) {
+ if (TextUtils.equals(intent.getAction(),
+ Intent.ACTION_PACKAGE_ADDED)) {
+ String pkgName=intent.getData().getEncodedSchemeSpecificPart();
+
+ if (OrbotHelper.ORBOT_PACKAGE_NAME.equals(pkgName)) {
+ isInstalled=true;
+ handler.removeCallbacks(onInstallTimeout);
+ ctxt.unregisterReceiver(orbotInstallReceiver);
+
+ for (InstallCallback cb : installCallbacks) {
+ cb.onInstalled();
+ }
+
+ init();
+ }
+ }
+ }
+ };
+
+ private Runnable onInstallTimeout=new Runnable() {
+ @Override
+ public void run() {
+ ctxt.unregisterReceiver(orbotInstallReceiver);
+
+ for (InstallCallback cb : installCallbacks) {
+ cb.onInstallTimeout();
+ }
+ }
+ };
+
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ static Set newSetFromMap(Map map) {
+ if (map.isEmpty()) {
+ return new SetFromMap(map);
+ }
+ throw new IllegalArgumentException("map not empty");
+ }
+}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/ProxyHelper.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/ProxyHelper.java
similarity index 94%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/ProxyHelper.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/ProxyHelper.java
index c8a0a594..7d716e83 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/ProxyHelper.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/ProxyHelper.java
@@ -1,74 +1,74 @@
-/*
- * Copyright 2012-2016 Nathan Freitas
-
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.darkweb.genesissearchengine.libs.netcipher.proxy;
-
-import android.content.Context;
-import android.content.Intent;
-
-public interface ProxyHelper {
-
- public boolean isInstalled (Context context);
- public void requestStatus (Context context);
- public boolean requestStart (Context context);
- public Intent getInstallIntent (Context context);
- public Intent getStartIntent (Context context);
- public String getName ();
-
- public final static String FDROID_PACKAGE_NAME = "org.fdroid.fdroid";
- public final static String PLAY_PACKAGE_NAME = "com.android.vending";
-
- /**
- * A request to Orbot to transparently start Tor services
- */
- public final static String ACTION_START = "android.intent.action.PROXY_START";
- /**
- * {@link Intent} send by Orbot with {@code ON/OFF/STARTING/STOPPING} status
- */
- public final static String ACTION_STATUS = "android.intent.action.PROXY_STATUS";
- /**
- * {@code String} that contains a status constant: {@link #STATUS_ON},
- * {@link #STATUS_OFF}, {@link #STATUS_STARTING}, or
- * {@link #STATUS_STOPPING}
- */
- public final static String EXTRA_STATUS = "android.intent.extra.PROXY_STATUS";
-
- public final static String EXTRA_PROXY_PORT_HTTP = "android.intent.extra.PROXY_PORT_HTTP";
- public final static String EXTRA_PROXY_PORT_SOCKS = "android.intent.extra.PROXY_PORT_SOCKS";
-
- /**
- * A {@link String} {@code packageName} for Orbot to direct its status reply
- * to, used in {@link #ACTION_START} {@link Intent}s sent to Orbot
- */
- public final static String EXTRA_PACKAGE_NAME = "android.intent.extra.PROXY_PACKAGE_NAME";
-
- /**
- * All tor-related services and daemons are stopped
- */
- public final static String STATUS_OFF = "OFF";
- /**
- * All tor-related services and daemons have completed starting
- */
- public final static String STATUS_ON = "ON";
- public final static String STATUS_STARTING = "STARTING";
- public final static String STATUS_STOPPING = "STOPPING";
- /**
- * The user has disabled the ability for background starts triggered by
- * apps. Fallback to the old Intent that brings up Orbot.
- */
- public final static String STATUS_STARTS_DISABLED = "STARTS_DISABLED";
-}
-
+/*
+ * Copyright 2012-2016 Nathan Freitas
+
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.hiddenservices.genesissearchengine.production.libs.netcipher.proxy;
+
+import android.content.Context;
+import android.content.Intent;
+
+public interface ProxyHelper {
+
+ public boolean isInstalled (Context context);
+ public void requestStatus (Context context);
+ public boolean requestStart (Context context);
+ public Intent getInstallIntent (Context context);
+ public Intent getStartIntent (Context context);
+ public String getName ();
+
+ public final static String FDROID_PACKAGE_NAME = "org.fdroid.fdroid";
+ public final static String PLAY_PACKAGE_NAME = "com.android.vending";
+
+ /**
+ * A request to Orbot to transparently start Tor services
+ */
+ public final static String ACTION_START = "android.intent.action.PROXY_START";
+ /**
+ * {@link Intent} send by Orbot with {@code ON/OFF/STARTING/STOPPING} status
+ */
+ public final static String ACTION_STATUS = "android.intent.action.PROXY_STATUS";
+ /**
+ * {@code String} that contains a status constant: {@link #STATUS_ON},
+ * {@link #STATUS_OFF}, {@link #STATUS_STARTING}, or
+ * {@link #STATUS_STOPPING}
+ */
+ public final static String EXTRA_STATUS = "android.intent.extra.PROXY_STATUS";
+
+ public final static String EXTRA_PROXY_PORT_HTTP = "android.intent.extra.PROXY_PORT_HTTP";
+ public final static String EXTRA_PROXY_PORT_SOCKS = "android.intent.extra.PROXY_PORT_SOCKS";
+
+ /**
+ * A {@link String} {@code packageName} for Orbot to direct its status reply
+ * to, used in {@link #ACTION_START} {@link Intent}s sent to Orbot
+ */
+ public final static String EXTRA_PACKAGE_NAME = "android.intent.extra.PROXY_PACKAGE_NAME";
+
+ /**
+ * All tor-related services and daemons are stopped
+ */
+ public final static String STATUS_OFF = "OFF";
+ /**
+ * All tor-related services and daemons have completed starting
+ */
+ public final static String STATUS_ON = "ON";
+ public final static String STATUS_STARTING = "STARTING";
+ public final static String STATUS_STOPPING = "STOPPING";
+ /**
+ * The user has disabled the ability for background starts triggered by
+ * apps. Fallback to the old Intent that brings up Orbot.
+ */
+ public final static String STATUS_STARTS_DISABLED = "STARTS_DISABLED";
+}
+
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/ProxySelector.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/ProxySelector.java
similarity index 91%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/ProxySelector.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/ProxySelector.java
index a0e15ef5..143b86ea 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/ProxySelector.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/ProxySelector.java
@@ -1,59 +1,59 @@
-/*
- * Copyright 2012-2016 Nathan Freitas
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.darkweb.genesissearchengine.libs.netcipher.proxy;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.Proxy;
-import java.net.SocketAddress;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import android.util.Log;
-
-public class ProxySelector extends java.net.ProxySelector {
-
- private ArrayList listProxies;
-
- public ProxySelector ()
- {
- super ();
-
- listProxies = new ArrayList();
-
-
- }
-
- public void addProxy (Proxy.Type type,String host, int port)
- {
- Proxy proxy = new Proxy(type,new InetSocketAddress(host, port));
- listProxies.add(proxy);
- }
-
- @Override
- public void connectFailed(URI uri, SocketAddress address,
- IOException failure) {
- Log.w("ProxySelector","could not connect to " + address.toString() + ": " + failure.getMessage());
- }
-
- @Override
- public List select(URI uri) {
-
- return listProxies;
- }
-
-}
+/*
+ * Copyright 2012-2016 Nathan Freitas
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.hiddenservices.genesissearchengine.production.libs.netcipher.proxy;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.net.SocketAddress;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import android.util.Log;
+
+public class ProxySelector extends java.net.ProxySelector {
+
+ private ArrayList listProxies;
+
+ public ProxySelector ()
+ {
+ super ();
+
+ listProxies = new ArrayList();
+
+
+ }
+
+ public void addProxy (Proxy.Type type,String host, int port)
+ {
+ Proxy proxy = new Proxy(type,new InetSocketAddress(host, port));
+ listProxies.add(proxy);
+ }
+
+ @Override
+ public void connectFailed(URI uri, SocketAddress address,
+ IOException failure) {
+ Log.w("ProxySelector","could not connect to " + address.toString() + ": " + failure.getMessage());
+ }
+
+ @Override
+ public List select(URI uri) {
+
+ return listProxies;
+ }
+
+}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/PsiphonHelper.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/PsiphonHelper.java
similarity index 95%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/PsiphonHelper.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/PsiphonHelper.java
index 8bbf26de..a2b29d36 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/PsiphonHelper.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/PsiphonHelper.java
@@ -1,177 +1,177 @@
-/*
- * Copyright 2012-2016 Nathan Freitas
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.darkweb.genesissearchengine.libs.netcipher.proxy;
-
-import java.net.ConnectException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.util.List;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.net.Uri;
-import android.text.TextUtils;
-
-public class PsiphonHelper implements ProxyHelper {
-
- public final static String PACKAGE_NAME = "com.psiphon3";
- public final static String COMPONENT_NAME = "com.psiphon3.StatusActivity";
-
-
- public final static String MARKET_URI = "market://details?id=" + PACKAGE_NAME;
- public final static String FDROID_URI = "https://f-droid.org/repository/browse/?fdid="
- + PACKAGE_NAME;
- public final static String ORBOT_PLAY_URI = "https://play.google.com/store/apps/details?id="
- + PACKAGE_NAME;
-
- public final static int DEFAULT_SOCKS_PORT = 1080;
- public final static int DEFAULT_HTTP_PORT = 8080;
-
- @Override
- public boolean isInstalled(Context context) {
- return isAppInstalled(context, PACKAGE_NAME);
- }
-
-
- private static boolean isAppInstalled(Context context, String uri) {
- try {
- PackageManager pm = context.getPackageManager();
- pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
- return true;
- } catch (PackageManager.NameNotFoundException e) {
- return false;
- }
- }
-
- @Override
- public void requestStatus(final Context context) {
-
- Thread thread = new Thread ()
- {
- public void run ()
- {
- //can connect to default HTTP proxy port?
- boolean isSocksOpen = false;
- boolean isHttpOpen = false;
-
- int socksPort = DEFAULT_SOCKS_PORT;
- int httpPort = DEFAULT_HTTP_PORT;
-
- for (int i = 0; i < 10 && (!isSocksOpen); i++)
- isSocksOpen = isPortOpen("127.0.0.1",socksPort++,100);
-
- for (int i = 0; i < 10 && (!isHttpOpen); i++)
- isHttpOpen = isPortOpen("127.0.0.1",httpPort++,100);
-
- //any other check?
-
- Intent intent = new Intent(ProxyHelper.ACTION_STATUS);
- intent.putExtra(EXTRA_PACKAGE_NAME, PACKAGE_NAME);
-
- if (isSocksOpen && isHttpOpen)
- {
- intent.putExtra(EXTRA_STATUS, STATUS_ON);
-
- intent.putExtra(EXTRA_PROXY_PORT_HTTP, httpPort-1);
- intent.putExtra(EXTRA_PROXY_PORT_SOCKS, socksPort-1);
-
-
- }
- else
- {
- intent.putExtra(EXTRA_STATUS, STATUS_OFF);
- }
-
- context.sendBroadcast(intent);
- }
- };
-
- thread.start();
-
- }
-
- @Override
- public boolean requestStart(Context context) {
-
- Intent intent = getStartIntent(context);
- // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(intent);
-
- return true;
- }
-
- @Override
- public Intent getInstallIntent(Context context) {
- final Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(Uri.parse(MARKET_URI));
-
- PackageManager pm = context.getPackageManager();
- List resInfos = pm.queryIntentActivities(intent, 0);
-
- String foundPackageName = null;
- for (ResolveInfo r : resInfos) {
- if (TextUtils.equals(r.activityInfo.packageName, FDROID_PACKAGE_NAME)
- || TextUtils.equals(r.activityInfo.packageName, PLAY_PACKAGE_NAME)) {
- foundPackageName = r.activityInfo.packageName;
- break;
- }
- }
-
- if (foundPackageName == null) {
- intent.setData(Uri.parse(FDROID_URI));
- } else {
- intent.setPackage(foundPackageName);
- }
- return intent;
- }
-
- @Override
- public Intent getStartIntent(Context context) {
- Intent intent = new Intent();
- intent.setComponent(new ComponentName(PACKAGE_NAME, COMPONENT_NAME));
-
- return intent;
- }
-
- public static boolean isPortOpen(final String ip, final int port, final int timeout) {
- try {
- Socket socket = new Socket();
- socket.connect(new InetSocketAddress(ip, port), timeout);
- socket.close();
- return true;
- }
-
- catch(ConnectException ce){
- ce.printStackTrace();
- return false;
- }
-
- catch (Exception ex) {
- ex.printStackTrace();
- return false;
- }
- }
-
-
- @Override
- public String getName() {
- return PACKAGE_NAME;
- }
-
-}
+/*
+ * Copyright 2012-2016 Nathan Freitas
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.hiddenservices.genesissearchengine.production.libs.netcipher.proxy;
+
+import java.net.ConnectException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.util.List;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.net.Uri;
+import android.text.TextUtils;
+
+public class PsiphonHelper implements ProxyHelper {
+
+ public final static String PACKAGE_NAME = "com.psiphon3";
+ public final static String COMPONENT_NAME = "com.psiphon3.StatusActivity";
+
+
+ public final static String MARKET_URI = "market://details?id=" + PACKAGE_NAME;
+ public final static String FDROID_URI = "https://f-droid.org/repository/browse/?fdid="
+ + PACKAGE_NAME;
+ public final static String ORBOT_PLAY_URI = "https://play.google.com/store/apps/details?id="
+ + PACKAGE_NAME;
+
+ public final static int DEFAULT_SOCKS_PORT = 1080;
+ public final static int DEFAULT_HTTP_PORT = 8080;
+
+ @Override
+ public boolean isInstalled(Context context) {
+ return isAppInstalled(context, PACKAGE_NAME);
+ }
+
+
+ private static boolean isAppInstalled(Context context, String uri) {
+ try {
+ PackageManager pm = context.getPackageManager();
+ pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
+ return true;
+ } catch (PackageManager.NameNotFoundException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public void requestStatus(final Context context) {
+
+ Thread thread = new Thread ()
+ {
+ public void run ()
+ {
+ //can connect to default HTTP proxy port?
+ boolean isSocksOpen = false;
+ boolean isHttpOpen = false;
+
+ int socksPort = DEFAULT_SOCKS_PORT;
+ int httpPort = DEFAULT_HTTP_PORT;
+
+ for (int i = 0; i < 10 && (!isSocksOpen); i++)
+ isSocksOpen = isPortOpen("127.0.0.1",socksPort++,100);
+
+ for (int i = 0; i < 10 && (!isHttpOpen); i++)
+ isHttpOpen = isPortOpen("127.0.0.1",httpPort++,100);
+
+ //any other check?
+
+ Intent intent = new Intent(ProxyHelper.ACTION_STATUS);
+ intent.putExtra(EXTRA_PACKAGE_NAME, PACKAGE_NAME);
+
+ if (isSocksOpen && isHttpOpen)
+ {
+ intent.putExtra(EXTRA_STATUS, STATUS_ON);
+
+ intent.putExtra(EXTRA_PROXY_PORT_HTTP, httpPort-1);
+ intent.putExtra(EXTRA_PROXY_PORT_SOCKS, socksPort-1);
+
+
+ }
+ else
+ {
+ intent.putExtra(EXTRA_STATUS, STATUS_OFF);
+ }
+
+ context.sendBroadcast(intent);
+ }
+ };
+
+ thread.start();
+
+ }
+
+ @Override
+ public boolean requestStart(Context context) {
+
+ Intent intent = getStartIntent(context);
+ // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(intent);
+
+ return true;
+ }
+
+ @Override
+ public Intent getInstallIntent(Context context) {
+ final Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setData(Uri.parse(MARKET_URI));
+
+ PackageManager pm = context.getPackageManager();
+ List resInfos = pm.queryIntentActivities(intent, 0);
+
+ String foundPackageName = null;
+ for (ResolveInfo r : resInfos) {
+ if (TextUtils.equals(r.activityInfo.packageName, FDROID_PACKAGE_NAME)
+ || TextUtils.equals(r.activityInfo.packageName, PLAY_PACKAGE_NAME)) {
+ foundPackageName = r.activityInfo.packageName;
+ break;
+ }
+ }
+
+ if (foundPackageName == null) {
+ intent.setData(Uri.parse(FDROID_URI));
+ } else {
+ intent.setPackage(foundPackageName);
+ }
+ return intent;
+ }
+
+ @Override
+ public Intent getStartIntent(Context context) {
+ Intent intent = new Intent();
+ intent.setComponent(new ComponentName(PACKAGE_NAME, COMPONENT_NAME));
+
+ return intent;
+ }
+
+ public static boolean isPortOpen(final String ip, final int port, final int timeout) {
+ try {
+ Socket socket = new Socket();
+ socket.connect(new InetSocketAddress(ip, port), timeout);
+ socket.close();
+ return true;
+ }
+
+ catch(ConnectException ce){
+ ce.printStackTrace();
+ return false;
+ }
+
+ catch (Exception ex) {
+ ex.printStackTrace();
+ return false;
+ }
+ }
+
+
+ @Override
+ public String getName() {
+ return PACKAGE_NAME;
+ }
+
+}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/SetFromMap.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/SetFromMap.java
similarity index 94%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/SetFromMap.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/SetFromMap.java
index b24caf2f..790255e3 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/SetFromMap.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/SetFromMap.java
@@ -1,88 +1,88 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.darkweb.genesissearchengine.libs.netcipher.proxy;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-import java.util.AbstractSet;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-class SetFromMap extends AbstractSet
- implements Serializable {
- private static final long serialVersionUID = 2454657854757543876L;
- // Must be named as is, to pass serialization compatibility test.
- private final Map m;
- private transient Set backingSet;
- SetFromMap(final Map map) {
- m = map;
- backingSet = map.keySet();
- }
- @Override public boolean equals(Object object) {
- return backingSet.equals(object);
- }
- @Override public int hashCode() {
- return backingSet.hashCode();
- }
- @Override public boolean add(E object) {
- return m.put(object, Boolean.TRUE) == null;
- }
- @Override public void clear() {
- m.clear();
- }
- @Override public String toString() {
- return backingSet.toString();
- }
- @Override public boolean contains(Object object) {
- return backingSet.contains(object);
- }
- @Override public boolean containsAll(Collection> collection) {
- return backingSet.containsAll(collection);
- }
- @Override public boolean isEmpty() {
- return m.isEmpty();
- }
- @Override public boolean remove(Object object) {
- return m.remove(object) != null;
- }
- @Override public boolean retainAll(Collection> collection) {
- return backingSet.retainAll(collection);
- }
- @Override public Object[] toArray() {
- return backingSet.toArray();
- }
- @Override
- public T[] toArray(T[] contents) {
- return backingSet.toArray(contents);
- }
- @Override public Iterator iterator() {
- return backingSet.iterator();
- }
- @Override public int size() {
- return m.size();
- }
- @SuppressWarnings("unchecked")
- private void readObject(ObjectInputStream stream)
- throws IOException, ClassNotFoundException {
- stream.defaultReadObject();
- backingSet = m.keySet();
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hiddenservices.genesissearchengine.production.libs.netcipher.proxy;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.util.AbstractSet;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+class SetFromMap extends AbstractSet
+ implements Serializable {
+ private static final long serialVersionUID = 2454657854757543876L;
+ // Must be named as is, to pass serialization compatibility test.
+ private final Map m;
+ private transient Set backingSet;
+ SetFromMap(final Map map) {
+ m = map;
+ backingSet = map.keySet();
+ }
+ @Override public boolean equals(Object object) {
+ return backingSet.equals(object);
+ }
+ @Override public int hashCode() {
+ return backingSet.hashCode();
+ }
+ @Override public boolean add(E object) {
+ return m.put(object, Boolean.TRUE) == null;
+ }
+ @Override public void clear() {
+ m.clear();
+ }
+ @Override public String toString() {
+ return backingSet.toString();
+ }
+ @Override public boolean contains(Object object) {
+ return backingSet.contains(object);
+ }
+ @Override public boolean containsAll(Collection> collection) {
+ return backingSet.containsAll(collection);
+ }
+ @Override public boolean isEmpty() {
+ return m.isEmpty();
+ }
+ @Override public boolean remove(Object object) {
+ return m.remove(object) != null;
+ }
+ @Override public boolean retainAll(Collection> collection) {
+ return backingSet.retainAll(collection);
+ }
+ @Override public Object[] toArray() {
+ return backingSet.toArray();
+ }
+ @Override
+ public T[] toArray(T[] contents) {
+ return backingSet.toArray(contents);
+ }
+ @Override public Iterator iterator() {
+ return backingSet.iterator();
+ }
+ @Override public int size() {
+ return m.size();
+ }
+ @SuppressWarnings("unchecked")
+ private void readObject(ObjectInputStream stream)
+ throws IOException, ClassNotFoundException {
+ stream.defaultReadObject();
+ backingSet = m.keySet();
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/SignatureUtils.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/SignatureUtils.java
similarity index 97%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/SignatureUtils.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/SignatureUtils.java
index e282e77d..bb9972c7 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/SignatureUtils.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/SignatureUtils.java
@@ -1,476 +1,476 @@
-/***
- Copyright (c) 2014 CommonsWare, LLC
-
- Licensed under the Apache License, Version 2.0 (the "License"); you may
- not use this file except in compliance with the License. You may obtain
- a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-package com.darkweb.genesissearchengine.libs.netcipher.proxy;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.ResolveInfo;
-import android.content.pm.Signature;
-import android.util.Log;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class SignatureUtils {
- public static String getOwnSignatureHash(Context ctxt)
- throws
- NameNotFoundException,
- NoSuchAlgorithmException {
- return(getSignatureHash(ctxt, ctxt.getPackageName()));
- }
-
- public static String getSignatureHash(Context ctxt, String packageName)
- throws
- NameNotFoundException,
- NoSuchAlgorithmException {
- MessageDigest md=MessageDigest.getInstance("SHA-256");
- Signature sig=
- ctxt.getPackageManager()
- .getPackageInfo(packageName, PackageManager.GET_SIGNATURES).signatures[0];
-
- return(toHexStringWithColons(md.digest(sig.toByteArray())));
- }
-
- // based on https://stackoverflow.com/a/2197650/115145
-
- public static String toHexStringWithColons(byte[] bytes) {
- char[] hexArray=
- { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
- 'C', 'D', 'E', 'F' };
- char[] hexChars=new char[(bytes.length * 3) - 1];
- int v;
-
- for (int j=0; j < bytes.length; j++) {
- v=bytes[j] & 0xFF;
- hexChars[j * 3]=hexArray[v / 16];
- hexChars[j * 3 + 1]=hexArray[v % 16];
-
- if (j < bytes.length - 1) {
- hexChars[j * 3 + 2]=':';
- }
- }
-
- return new String(hexChars);
- }
-
- /**
- * Confirms that the broadcast receiver for a given Intent
- * has the desired signature hash.
- *
- * If you know the package name of the receiver, call
- * setPackage() on the Intent before passing into this method.
- * That will validate whether the package is installed and whether
- * it has the proper signature hash. You can distinguish between
- * these cases by passing true for the failIfHack parameter.
- *
- * In general, there are three possible outcomes of calling
- * this method:
- *
- * 1. You get a SecurityException, because failIfHack is true,
- * and we found some receiver whose app does not match the
- * desired hash. The user may have installed a repackaged
- * version of this app that is signed by the wrong key.
- *
- * 2. You get null. If failIfHack is true, this means that no
- * receiver was found that matches the Intent. If failIfHack
- * is false, this means that no receiver was found that matches
- * the Intent and has a valid matching signature.
- *
- * 3. You get an Intent. This means we found a matching receiver
- * that has a matching signature. The Intent will be a copy of
- * the passed-in Intent, with the component name set to the
- * matching receiver, so the "broadcast" will only go to this
- * one component.
- *
- * @param ctxt any Context will do; the value is not retained
- * @param toValidate the Intent that you intend to broadcast
- * @param sigHash the signature hash of the app that you expect
- * to handle this broadcast
- * @param failIfHack true if you want a SecurityException if
- * a matching receiver is found but it has
- * the wrong signature hash, false otherwise
- * @return null if there is no matching receiver with the correct
- * hash, or a copy of the toValidate parameter with the full component
- * name of the target receiver added to the Intent
- */
- public static Intent validateBroadcastIntent(Context ctxt,
- Intent toValidate,
- String sigHash,
- boolean failIfHack) {
- ArrayList sigHashes=new ArrayList();
-
- sigHashes.add(sigHash);
-
- return(validateBroadcastIntent(ctxt, toValidate, sigHashes,
- failIfHack));
- }
-
- /**
- * Confirms that the broadcast receiver for a given Intent
- * has a desired signature hash.
- *
- * If you know the package name of the receiver, call
- * setPackage() on the Intent before passing into this method.
- * That will validate whether the package is installed and whether
- * it has a proper signature hash. You can distinguish between
- * these cases by passing true for the failIfHack parameter.
- *
- * In general, there are three possible outcomes of calling
- * this method:
- *
- * 1. You get a SecurityException, because failIfHack is true,
- * and we found some receiver whose app does not match the
- * desired hash. The user may have installed a repackaged
- * version of this app that is signed by the wrong key.
- *
- * 2. You get null. If failIfHack is true, this means that no
- * receiver was found that matches the Intent. If failIfHack
- * is false, this means that no receiver was found that matches
- * the Intent and has a valid matching signature.
- *
- * 3. You get an Intent. This means we found a matching receiver
- * that has a matching signature. The Intent will be a copy of
- * the passed-in Intent, with the component name set to the
- * matching receiver, so the "broadcast" will only go to this
- * one component.
- *
- * @param ctxt any Context will do; the value is not retained
- * @param toValidate the Intent that you intend to broadcast
- * @param sigHashes the possible signature hashes of the app
- * that you expect to handle this broadcast
- * @param failIfHack true if you want a SecurityException if
- * a matching receiver is found but it has
- * the wrong signature hash, false otherwise
- * @return null if there is no matching receiver with the correct
- * hash, or a copy of the toValidate parameter with the full component
- * name of the target receiver added to the Intent
- */
- public static Intent validateBroadcastIntent(Context ctxt,
- Intent toValidate,
- List sigHashes,
- boolean failIfHack) {
- PackageManager pm=ctxt.getPackageManager();
- Intent result=null;
- List receivers=
- pm.queryBroadcastReceivers(toValidate, 0);
-
- if (receivers!=null) {
- for (ResolveInfo info : receivers) {
- try {
- if (sigHashes.contains(getSignatureHash(ctxt,
- info.activityInfo.packageName))) {
- ComponentName cn=
- new ComponentName(info.activityInfo.packageName,
- info.activityInfo.name);
-
- result=new Intent(toValidate).setComponent(cn);
- break;
- }
- else if (failIfHack) {
- throw new SecurityException(
- "Package has signature hash mismatch: "+
- info.activityInfo.packageName);
- }
- }
- catch (NoSuchAlgorithmException e) {
- Log.w("SignatureUtils",
- "Exception when computing signature hash", e);
- }
- catch (NameNotFoundException e) {
- Log.w("SignatureUtils",
- "Exception when computing signature hash", e);
- }
- }
- }
-
- return(result);
- }
-
- /**
- * Confirms that the activity for a given Intent has the
- * desired signature hash.
- *
- * If you know the package name of the activity, call
- * setPackage() on the Intent before passing into this method.
- * That will validate whether the package is installed and whether
- * it has the proper signature hash. You can distinguish between
- * these cases by passing true for the failIfHack parameter.
- *
- * In general, there are three possible outcomes of calling
- * this method:
- *
- * 1. You get a SecurityException, because failIfHack is true,
- * and we found some activity whose app does not match the
- * desired hash. The user may have installed a repackaged
- * version of this app that is signed by the wrong key.
- *
- * 2. You get null. If failIfHack is true, this means that no
- * activity was found that matches the Intent. If failIfHack
- * is false, this means that no activity was found that matches
- * the Intent and has a valid matching signature.
- *
- * 3. You get an Intent. This means we found a matching activity
- * that has a matching signature. The Intent will be a copy of
- * the passed-in Intent, with the component name set to the
- * matching activity, so a call to startActivity() for this
- * Intent is guaranteed to go to this specific activity.
- *
- * @param ctxt any Context will do; the value is not retained
- * @param toValidate the Intent that you intend to use with
- * startActivity()
- * @param sigHash the signature hash of the app that you expect
- * to handle this activity
- * @param failIfHack true if you want a SecurityException if
- * a matching activity is found but it has
- * the wrong signature hash, false otherwise
- * @return null if there is no matching activity with the correct
- * hash, or a copy of the toValidate parameter with the full component
- * name of the target activity added to the Intent
- */
- public static Intent validateActivityIntent(Context ctxt,
- Intent toValidate,
- String sigHash,
- boolean failIfHack) {
- ArrayList sigHashes=new ArrayList();
-
- sigHashes.add(sigHash);
-
- return(validateActivityIntent(ctxt, toValidate, sigHashes,
- failIfHack));
- }
-
- /**
- * Confirms that the activity for a given Intent has the
- * desired signature hash.
- *
- * If you know the package name of the activity, call
- * setPackage() on the Intent before passing into this method.
- * That will validate whether the package is installed and whether
- * it has the proper signature hash. You can distinguish between
- * these cases by passing true for the failIfHack parameter.
- *
- * In general, there are three possible outcomes of calling
- * this method:
- *
- * 1. You get a SecurityException, because failIfHack is true,
- * and we found some activity whose app does not match the
- * desired hash. The user may have installed a repackaged
- * version of this app that is signed by the wrong key.
- *
- * 2. You get null. If failIfHack is true, this means that no
- * activity was found that matches the Intent. If failIfHack
- * is false, this means that no activity was found that matches
- * the Intent and has a valid matching signature.
- *
- * 3. You get an Intent. This means we found a matching activity
- * that has a matching signature. The Intent will be a copy of
- * the passed-in Intent, with the component name set to the
- * matching activity, so a call to startActivity() for this
- * Intent is guaranteed to go to this specific activity.
- *
- * @param ctxt any Context will do; the value is not retained
- * @param toValidate the Intent that you intend to use with
- * startActivity()
- * @param sigHashes the signature hashes of the app that you expect
- * to handle this activity
- * @param failIfHack true if you want a SecurityException if
- * a matching activity is found but it has
- * the wrong signature hash, false otherwise
- * @return null if there is no matching activity with the correct
- * hash, or a copy of the toValidate parameter with the full component
- * name of the target activity added to the Intent
- */
- public static Intent validateActivityIntent(Context ctxt,
- Intent toValidate,
- List sigHashes,
- boolean failIfHack) {
- PackageManager pm=ctxt.getPackageManager();
- Intent result=null;
- List activities=
- pm.queryIntentActivities(toValidate, 0);
-
- if (activities!=null) {
- for (ResolveInfo info : activities) {
- try {
- if (sigHashes.contains(getSignatureHash(ctxt,
- info.activityInfo.packageName))) {
- ComponentName cn=
- new ComponentName(info.activityInfo.packageName,
- info.activityInfo.name);
-
- result=new Intent(toValidate).setComponent(cn);
- break;
- }
- else if (failIfHack) {
- throw new SecurityException(
- "Package has signature hash mismatch: "+
- info.activityInfo.packageName);
- }
- }
- catch (NoSuchAlgorithmException e) {
- Log.w("SignatureUtils",
- "Exception when computing signature hash", e);
- }
- catch (NameNotFoundException e) {
- Log.w("SignatureUtils",
- "Exception when computing signature hash", e);
- }
- }
- }
-
- return(result);
- }
-
- /**
- * Confirms that the service for a given Intent has the
- * desired signature hash.
- *
- * If you know the package name of the service, call
- * setPackage() on the Intent before passing into this method.
- * That will validate whether the package is installed and whether
- * it has the proper signature hash. You can distinguish between
- * these cases by passing true for the failIfHack parameter.
- *
- * In general, there are three possible outcomes of calling
- * this method:
- *
- * 1. You get a SecurityException, because failIfHack is true,
- * and we found some service whose app does not match the
- * desired hash. The user may have installed a repackaged
- * version of this app that is signed by the wrong key.
- *
- * 2. You get null. If failIfHack is true, this means that no
- * service was found that matches the Intent. If failIfHack
- * is false, this means that no service was found that matches
- * the Intent and has a valid matching signature.
- *
- * 3. You get an Intent. This means we found a matching service
- * that has a matching signature. The Intent will be a copy of
- * the passed-in Intent, with the component name set to the
- * matching service, so a call to startService() or
- * bindService() for this Intent is guaranteed to go to this
- * specific service.
- *
- * @param ctxt any Context will do; the value is not retained
- * @param toValidate the Intent that you intend to use with
- * startService() or bindService()
- * @param sigHash the signature hash of the app that you expect
- * to handle this service
- * @param failIfHack true if you want a SecurityException if
- * a matching service is found but it has
- * the wrong signature hash, false otherwise
- * @return null if there is no matching service with the correct
- * hash, or a copy of the toValidate parameter with the full component
- * name of the target service added to the Intent
- */
- public static Intent validateServiceIntent(Context ctxt,
- Intent toValidate,
- String sigHash,
- boolean failIfHack) {
- ArrayList sigHashes=new ArrayList();
-
- sigHashes.add(sigHash);
-
- return(validateServiceIntent(ctxt, toValidate, sigHashes,
- failIfHack));
- }
-
- /**
- * Confirms that the service for a given Intent has the
- * desired signature hash.
- *
- * If you know the package name of the service, call
- * setPackage() on the Intent before passing into this method.
- * That will validate whether the package is installed and whether
- * it has the proper signature hash. You can distinguish between
- * these cases by passing true for the failIfHack parameter.
- *
- * In general, there are three possible outcomes of calling
- * this method:
- *
- * 1. You get a SecurityException, because failIfHack is true,
- * and we found some service whose app does not match the
- * desired hash. The user may have installed a repackaged
- * version of this app that is signed by the wrong key.
- *
- * 2. You get null. If failIfHack is true, this means that no
- * service was found that matches the Intent. If failIfHack
- * is false, this means that no service was found that matches
- * the Intent and has a valid matching signature.
- *
- * 3. You get an Intent. This means we found a matching service
- * that has a matching signature. The Intent will be a copy of
- * the passed-in Intent, with the component name set to the
- * matching service, so a call to startService() or
- * bindService() for this Intent is guaranteed to go to this
- * specific service.
- *
- * @param ctxt any Context will do; the value is not retained
- * @param toValidate the Intent that you intend to use with
- * startService() or bindService()
- * @param sigHashes the signature hash of the app that you expect
- * to handle this service
- * @param failIfHack true if you want a SecurityException if
- * a matching service is found but it has
- * the wrong signature hash, false otherwise
- * @return null if there is no matching service with the correct
- * hash, or a copy of the toValidate parameter with the full component
- * name of the target service added to the Intent
- */
- public static Intent validateServiceIntent(Context ctxt,
- Intent toValidate,
- List sigHashes,
- boolean failIfHack) {
- PackageManager pm=ctxt.getPackageManager();
- Intent result=null;
- List services=
- pm.queryIntentServices(toValidate, 0);
-
- if (services!=null) {
- for (ResolveInfo info : services) {
- try {
- if (sigHashes.contains(getSignatureHash(ctxt,
- info.serviceInfo.packageName))) {
- ComponentName cn=
- new ComponentName(info.serviceInfo.packageName,
- info.serviceInfo.name);
-
- result=new Intent(toValidate).setComponent(cn);
- break;
- }
- else if (failIfHack) {
- throw new SecurityException(
- "Package has signature hash mismatch: "+
- info.activityInfo.packageName);
- }
- }
- catch (NoSuchAlgorithmException e) {
- Log.w("SignatureUtils",
- "Exception when computing signature hash", e);
- }
- catch (NameNotFoundException e) {
- Log.w("SignatureUtils",
- "Exception when computing signature hash", e);
- }
- }
- }
-
- return(result);
- }
-}
+/***
+ Copyright (c) 2014 CommonsWare, LLC
+
+ Licensed under the Apache License, Version 2.0 (the "License"); you may
+ not use this file except in compliance with the License. You may obtain
+ a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+package com.hiddenservices.genesissearchengine.production.libs.netcipher.proxy;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.pm.ResolveInfo;
+import android.content.pm.Signature;
+import android.util.Log;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class SignatureUtils {
+ public static String getOwnSignatureHash(Context ctxt)
+ throws
+ NameNotFoundException,
+ NoSuchAlgorithmException {
+ return(getSignatureHash(ctxt, ctxt.getPackageName()));
+ }
+
+ public static String getSignatureHash(Context ctxt, String packageName)
+ throws
+ NameNotFoundException,
+ NoSuchAlgorithmException {
+ MessageDigest md=MessageDigest.getInstance("SHA-256");
+ Signature sig=
+ ctxt.getPackageManager()
+ .getPackageInfo(packageName, PackageManager.GET_SIGNATURES).signatures[0];
+
+ return(toHexStringWithColons(md.digest(sig.toByteArray())));
+ }
+
+ // based on https://stackoverflow.com/a/2197650/115145
+
+ public static String toHexStringWithColons(byte[] bytes) {
+ char[] hexArray=
+ { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B',
+ 'C', 'D', 'E', 'F' };
+ char[] hexChars=new char[(bytes.length * 3) - 1];
+ int v;
+
+ for (int j=0; j < bytes.length; j++) {
+ v=bytes[j] & 0xFF;
+ hexChars[j * 3]=hexArray[v / 16];
+ hexChars[j * 3 + 1]=hexArray[v % 16];
+
+ if (j < bytes.length - 1) {
+ hexChars[j * 3 + 2]=':';
+ }
+ }
+
+ return new String(hexChars);
+ }
+
+ /**
+ * Confirms that the broadcast receiver for a given Intent
+ * has the desired signature hash.
+ *
+ * If you know the package name of the receiver, call
+ * setPackage() on the Intent before passing into this method.
+ * That will validate whether the package is installed and whether
+ * it has the proper signature hash. You can distinguish between
+ * these cases by passing true for the failIfHack parameter.
+ *
+ * In general, there are three possible outcomes of calling
+ * this method:
+ *
+ * 1. You get a SecurityException, because failIfHack is true,
+ * and we found some receiver whose app does not match the
+ * desired hash. The user may have installed a repackaged
+ * version of this app that is signed by the wrong key.
+ *
+ * 2. You get null. If failIfHack is true, this means that no
+ * receiver was found that matches the Intent. If failIfHack
+ * is false, this means that no receiver was found that matches
+ * the Intent and has a valid matching signature.
+ *
+ * 3. You get an Intent. This means we found a matching receiver
+ * that has a matching signature. The Intent will be a copy of
+ * the passed-in Intent, with the component name set to the
+ * matching receiver, so the "broadcast" will only go to this
+ * one component.
+ *
+ * @param ctxt any Context will do; the value is not retained
+ * @param toValidate the Intent that you intend to broadcast
+ * @param sigHash the signature hash of the app that you expect
+ * to handle this broadcast
+ * @param failIfHack true if you want a SecurityException if
+ * a matching receiver is found but it has
+ * the wrong signature hash, false otherwise
+ * @return null if there is no matching receiver with the correct
+ * hash, or a copy of the toValidate parameter with the full component
+ * name of the target receiver added to the Intent
+ */
+ public static Intent validateBroadcastIntent(Context ctxt,
+ Intent toValidate,
+ String sigHash,
+ boolean failIfHack) {
+ ArrayList sigHashes=new ArrayList();
+
+ sigHashes.add(sigHash);
+
+ return(validateBroadcastIntent(ctxt, toValidate, sigHashes,
+ failIfHack));
+ }
+
+ /**
+ * Confirms that the broadcast receiver for a given Intent
+ * has a desired signature hash.
+ *
+ * If you know the package name of the receiver, call
+ * setPackage() on the Intent before passing into this method.
+ * That will validate whether the package is installed and whether
+ * it has a proper signature hash. You can distinguish between
+ * these cases by passing true for the failIfHack parameter.
+ *
+ * In general, there are three possible outcomes of calling
+ * this method:
+ *
+ * 1. You get a SecurityException, because failIfHack is true,
+ * and we found some receiver whose app does not match the
+ * desired hash. The user may have installed a repackaged
+ * version of this app that is signed by the wrong key.
+ *
+ * 2. You get null. If failIfHack is true, this means that no
+ * receiver was found that matches the Intent. If failIfHack
+ * is false, this means that no receiver was found that matches
+ * the Intent and has a valid matching signature.
+ *
+ * 3. You get an Intent. This means we found a matching receiver
+ * that has a matching signature. The Intent will be a copy of
+ * the passed-in Intent, with the component name set to the
+ * matching receiver, so the "broadcast" will only go to this
+ * one component.
+ *
+ * @param ctxt any Context will do; the value is not retained
+ * @param toValidate the Intent that you intend to broadcast
+ * @param sigHashes the possible signature hashes of the app
+ * that you expect to handle this broadcast
+ * @param failIfHack true if you want a SecurityException if
+ * a matching receiver is found but it has
+ * the wrong signature hash, false otherwise
+ * @return null if there is no matching receiver with the correct
+ * hash, or a copy of the toValidate parameter with the full component
+ * name of the target receiver added to the Intent
+ */
+ public static Intent validateBroadcastIntent(Context ctxt,
+ Intent toValidate,
+ List sigHashes,
+ boolean failIfHack) {
+ PackageManager pm=ctxt.getPackageManager();
+ Intent result=null;
+ List receivers=
+ pm.queryBroadcastReceivers(toValidate, 0);
+
+ if (receivers!=null) {
+ for (ResolveInfo info : receivers) {
+ try {
+ if (sigHashes.contains(getSignatureHash(ctxt,
+ info.activityInfo.packageName))) {
+ ComponentName cn=
+ new ComponentName(info.activityInfo.packageName,
+ info.activityInfo.name);
+
+ result=new Intent(toValidate).setComponent(cn);
+ break;
+ }
+ else if (failIfHack) {
+ throw new SecurityException(
+ "Package has signature hash mismatch: "+
+ info.activityInfo.packageName);
+ }
+ }
+ catch (NoSuchAlgorithmException e) {
+ Log.w("SignatureUtils",
+ "Exception when computing signature hash", e);
+ }
+ catch (NameNotFoundException e) {
+ Log.w("SignatureUtils",
+ "Exception when computing signature hash", e);
+ }
+ }
+ }
+
+ return(result);
+ }
+
+ /**
+ * Confirms that the activity for a given Intent has the
+ * desired signature hash.
+ *
+ * If you know the package name of the activity, call
+ * setPackage() on the Intent before passing into this method.
+ * That will validate whether the package is installed and whether
+ * it has the proper signature hash. You can distinguish between
+ * these cases by passing true for the failIfHack parameter.
+ *
+ * In general, there are three possible outcomes of calling
+ * this method:
+ *
+ * 1. You get a SecurityException, because failIfHack is true,
+ * and we found some activity whose app does not match the
+ * desired hash. The user may have installed a repackaged
+ * version of this app that is signed by the wrong key.
+ *
+ * 2. You get null. If failIfHack is true, this means that no
+ * activity was found that matches the Intent. If failIfHack
+ * is false, this means that no activity was found that matches
+ * the Intent and has a valid matching signature.
+ *
+ * 3. You get an Intent. This means we found a matching activity
+ * that has a matching signature. The Intent will be a copy of
+ * the passed-in Intent, with the component name set to the
+ * matching activity, so a call to startActivity() for this
+ * Intent is guaranteed to go to this specific activity.
+ *
+ * @param ctxt any Context will do; the value is not retained
+ * @param toValidate the Intent that you intend to use with
+ * startActivity()
+ * @param sigHash the signature hash of the app that you expect
+ * to handle this activity
+ * @param failIfHack true if you want a SecurityException if
+ * a matching activity is found but it has
+ * the wrong signature hash, false otherwise
+ * @return null if there is no matching activity with the correct
+ * hash, or a copy of the toValidate parameter with the full component
+ * name of the target activity added to the Intent
+ */
+ public static Intent validateActivityIntent(Context ctxt,
+ Intent toValidate,
+ String sigHash,
+ boolean failIfHack) {
+ ArrayList sigHashes=new ArrayList();
+
+ sigHashes.add(sigHash);
+
+ return(validateActivityIntent(ctxt, toValidate, sigHashes,
+ failIfHack));
+ }
+
+ /**
+ * Confirms that the activity for a given Intent has the
+ * desired signature hash.
+ *
+ * If you know the package name of the activity, call
+ * setPackage() on the Intent before passing into this method.
+ * That will validate whether the package is installed and whether
+ * it has the proper signature hash. You can distinguish between
+ * these cases by passing true for the failIfHack parameter.
+ *
+ * In general, there are three possible outcomes of calling
+ * this method:
+ *
+ * 1. You get a SecurityException, because failIfHack is true,
+ * and we found some activity whose app does not match the
+ * desired hash. The user may have installed a repackaged
+ * version of this app that is signed by the wrong key.
+ *
+ * 2. You get null. If failIfHack is true, this means that no
+ * activity was found that matches the Intent. If failIfHack
+ * is false, this means that no activity was found that matches
+ * the Intent and has a valid matching signature.
+ *
+ * 3. You get an Intent. This means we found a matching activity
+ * that has a matching signature. The Intent will be a copy of
+ * the passed-in Intent, with the component name set to the
+ * matching activity, so a call to startActivity() for this
+ * Intent is guaranteed to go to this specific activity.
+ *
+ * @param ctxt any Context will do; the value is not retained
+ * @param toValidate the Intent that you intend to use with
+ * startActivity()
+ * @param sigHashes the signature hashes of the app that you expect
+ * to handle this activity
+ * @param failIfHack true if you want a SecurityException if
+ * a matching activity is found but it has
+ * the wrong signature hash, false otherwise
+ * @return null if there is no matching activity with the correct
+ * hash, or a copy of the toValidate parameter with the full component
+ * name of the target activity added to the Intent
+ */
+ public static Intent validateActivityIntent(Context ctxt,
+ Intent toValidate,
+ List sigHashes,
+ boolean failIfHack) {
+ PackageManager pm=ctxt.getPackageManager();
+ Intent result=null;
+ List activities=
+ pm.queryIntentActivities(toValidate, 0);
+
+ if (activities!=null) {
+ for (ResolveInfo info : activities) {
+ try {
+ if (sigHashes.contains(getSignatureHash(ctxt,
+ info.activityInfo.packageName))) {
+ ComponentName cn=
+ new ComponentName(info.activityInfo.packageName,
+ info.activityInfo.name);
+
+ result=new Intent(toValidate).setComponent(cn);
+ break;
+ }
+ else if (failIfHack) {
+ throw new SecurityException(
+ "Package has signature hash mismatch: "+
+ info.activityInfo.packageName);
+ }
+ }
+ catch (NoSuchAlgorithmException e) {
+ Log.w("SignatureUtils",
+ "Exception when computing signature hash", e);
+ }
+ catch (NameNotFoundException e) {
+ Log.w("SignatureUtils",
+ "Exception when computing signature hash", e);
+ }
+ }
+ }
+
+ return(result);
+ }
+
+ /**
+ * Confirms that the service for a given Intent has the
+ * desired signature hash.
+ *
+ * If you know the package name of the service, call
+ * setPackage() on the Intent before passing into this method.
+ * That will validate whether the package is installed and whether
+ * it has the proper signature hash. You can distinguish between
+ * these cases by passing true for the failIfHack parameter.
+ *
+ * In general, there are three possible outcomes of calling
+ * this method:
+ *
+ * 1. You get a SecurityException, because failIfHack is true,
+ * and we found some service whose app does not match the
+ * desired hash. The user may have installed a repackaged
+ * version of this app that is signed by the wrong key.
+ *
+ * 2. You get null. If failIfHack is true, this means that no
+ * service was found that matches the Intent. If failIfHack
+ * is false, this means that no service was found that matches
+ * the Intent and has a valid matching signature.
+ *
+ * 3. You get an Intent. This means we found a matching service
+ * that has a matching signature. The Intent will be a copy of
+ * the passed-in Intent, with the component name set to the
+ * matching service, so a call to startService() or
+ * bindService() for this Intent is guaranteed to go to this
+ * specific service.
+ *
+ * @param ctxt any Context will do; the value is not retained
+ * @param toValidate the Intent that you intend to use with
+ * startService() or bindService()
+ * @param sigHash the signature hash of the app that you expect
+ * to handle this service
+ * @param failIfHack true if you want a SecurityException if
+ * a matching service is found but it has
+ * the wrong signature hash, false otherwise
+ * @return null if there is no matching service with the correct
+ * hash, or a copy of the toValidate parameter with the full component
+ * name of the target service added to the Intent
+ */
+ public static Intent validateServiceIntent(Context ctxt,
+ Intent toValidate,
+ String sigHash,
+ boolean failIfHack) {
+ ArrayList sigHashes=new ArrayList();
+
+ sigHashes.add(sigHash);
+
+ return(validateServiceIntent(ctxt, toValidate, sigHashes,
+ failIfHack));
+ }
+
+ /**
+ * Confirms that the service for a given Intent has the
+ * desired signature hash.
+ *
+ * If you know the package name of the service, call
+ * setPackage() on the Intent before passing into this method.
+ * That will validate whether the package is installed and whether
+ * it has the proper signature hash. You can distinguish between
+ * these cases by passing true for the failIfHack parameter.
+ *
+ * In general, there are three possible outcomes of calling
+ * this method:
+ *
+ * 1. You get a SecurityException, because failIfHack is true,
+ * and we found some service whose app does not match the
+ * desired hash. The user may have installed a repackaged
+ * version of this app that is signed by the wrong key.
+ *
+ * 2. You get null. If failIfHack is true, this means that no
+ * service was found that matches the Intent. If failIfHack
+ * is false, this means that no service was found that matches
+ * the Intent and has a valid matching signature.
+ *
+ * 3. You get an Intent. This means we found a matching service
+ * that has a matching signature. The Intent will be a copy of
+ * the passed-in Intent, with the component name set to the
+ * matching service, so a call to startService() or
+ * bindService() for this Intent is guaranteed to go to this
+ * specific service.
+ *
+ * @param ctxt any Context will do; the value is not retained
+ * @param toValidate the Intent that you intend to use with
+ * startService() or bindService()
+ * @param sigHashes the signature hash of the app that you expect
+ * to handle this service
+ * @param failIfHack true if you want a SecurityException if
+ * a matching service is found but it has
+ * the wrong signature hash, false otherwise
+ * @return null if there is no matching service with the correct
+ * hash, or a copy of the toValidate parameter with the full component
+ * name of the target service added to the Intent
+ */
+ public static Intent validateServiceIntent(Context ctxt,
+ Intent toValidate,
+ List sigHashes,
+ boolean failIfHack) {
+ PackageManager pm=ctxt.getPackageManager();
+ Intent result=null;
+ List services=
+ pm.queryIntentServices(toValidate, 0);
+
+ if (services!=null) {
+ for (ResolveInfo info : services) {
+ try {
+ if (sigHashes.contains(getSignatureHash(ctxt,
+ info.serviceInfo.packageName))) {
+ ComponentName cn=
+ new ComponentName(info.serviceInfo.packageName,
+ info.serviceInfo.name);
+
+ result=new Intent(toValidate).setComponent(cn);
+ break;
+ }
+ else if (failIfHack) {
+ throw new SecurityException(
+ "Package has signature hash mismatch: "+
+ info.activityInfo.packageName);
+ }
+ }
+ catch (NoSuchAlgorithmException e) {
+ Log.w("SignatureUtils",
+ "Exception when computing signature hash", e);
+ }
+ catch (NameNotFoundException e) {
+ Log.w("SignatureUtils",
+ "Exception when computing signature hash", e);
+ }
+ }
+ }
+
+ return(result);
+ }
+}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/StatusCallback.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/StatusCallback.java
similarity index 92%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/StatusCallback.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/StatusCallback.java
index 8540b1cc..509cb9bb 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/StatusCallback.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/StatusCallback.java
@@ -1,64 +1,64 @@
-/*
- * Copyright (c) 2016 CommonsWare, LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.darkweb.genesissearchengine.libs.netcipher.proxy;
-
-import android.content.Intent;
-
-/**
- * Callback interface used for reporting Orbot status
- */
-public interface StatusCallback {
- /**
- * Called when Orbot is operational
- *
- * @param statusIntent an Intent containing information about
- * Orbot, including proxy ports
- */
- void onEnabled(Intent statusIntent);
-
- /**
- * Called when Orbot reports that it is starting up
- */
- void onStarting();
-
- /**
- * Called when Orbot reports that it is shutting down
- */
- void onStopping();
-
- /**
- * Called when Orbot reports that it is no longer running
- */
- void onDisabled();
-
- /**
- * Called if our attempt to get a status from Orbot failed
- * after a defined period of time. See statusTimeout() on
- * OrbotInitializer.
- */
- void onStatusTimeout();
-
- /**
- * Called if Orbot is not yet installed. Usually, you handle
- * this by checking the return value from init() on OrbotInitializer
- * or calling isInstalled() on OrbotInitializer. However, if
- * you have need for it, if a callback is registered before
- * an init() call determines that Orbot is not installed, your
- * callback will be called with onNotYetInstalled().
- */
- void onNotYetInstalled();
-}
+/*
+ * Copyright (c) 2016 CommonsWare, LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hiddenservices.genesissearchengine.production.libs.netcipher.proxy;
+
+import android.content.Intent;
+
+/**
+ * Callback interface used for reporting Orbot status
+ */
+public interface StatusCallback {
+ /**
+ * Called when Orbot is operational
+ *
+ * @param statusIntent an Intent containing information about
+ * Orbot, including proxy ports
+ */
+ void onEnabled(Intent statusIntent);
+
+ /**
+ * Called when Orbot reports that it is starting up
+ */
+ void onStarting();
+
+ /**
+ * Called when Orbot reports that it is shutting down
+ */
+ void onStopping();
+
+ /**
+ * Called when Orbot reports that it is no longer running
+ */
+ void onDisabled();
+
+ /**
+ * Called if our attempt to get a status from Orbot failed
+ * after a defined period of time. See statusTimeout() on
+ * OrbotInitializer.
+ */
+ void onStatusTimeout();
+
+ /**
+ * Called if Orbot is not yet installed. Usually, you handle
+ * this by checking the return value from init() on OrbotInitializer
+ * or calling isInstalled() on OrbotInitializer. However, if
+ * you have need for it, if a callback is registered before
+ * an init() call determines that Orbot is not installed, your
+ * callback will be called with onNotYetInstalled().
+ */
+ void onNotYetInstalled();
+}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/TorServiceUtils.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/TorServiceUtils.java
similarity index 95%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/TorServiceUtils.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/TorServiceUtils.java
index f8ee2d6c..d9e124c0 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/proxy/TorServiceUtils.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/proxy/TorServiceUtils.java
@@ -1,246 +1,246 @@
-/*
- * Copyright 2009-2016 Nathan Freitas
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.darkweb.genesissearchengine.libs.netcipher.proxy;
-
-import android.content.Context;
-import android.util.Log;
-
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.net.URLEncoder;
-import java.util.StringTokenizer;
-
-public class TorServiceUtils {
-
- private final static String TAG = "TorUtils";
- // various console cmds
- public final static String SHELL_CMD_CHMOD = "chmod";
- public final static String SHELL_CMD_KILL = "kill -9";
- public final static String SHELL_CMD_RM = "rm";
- public final static String SHELL_CMD_PS = "ps";
- public final static String SHELL_CMD_PIDOF = "pidof";
-
- public final static String CHMOD_EXE_VALUE = "700";
-
- public static boolean isRootPossible()
- {
-
- StringBuilder log = new StringBuilder();
-
- try {
-
- // Check if Superuser.apk exists
- File fileSU = new File("/system/app/Superuser.apk");
- if (fileSU.exists())
- return true;
-
- fileSU = new File("/system/app/superuser.apk");
- if (fileSU.exists())
- return true;
-
- fileSU = new File("/system/bin/su");
- if (fileSU.exists())
- {
- String[] cmd = {
- "su"
- };
- int exitCode = TorServiceUtils.doShellCommand(cmd, log, false, true);
- if (exitCode != 0)
- return false;
- else
- return true;
- }
-
- // Check for 'su' binary
- String[] cmd = {
- "which su"
- };
- int exitCode = TorServiceUtils.doShellCommand(cmd, log, false, true);
-
- if (exitCode == 0) {
- Log.d(TAG, "root exists, but not sure about permissions");
- return true;
-
- }
-
- } catch (IOException e) {
- // this means that there is no root to be had (normally) so we won't
- // log anything
- Log.e(TAG, "Error checking for root access", e);
-
- } catch (Exception e) {
- Log.e(TAG, "Error checking for root access", e);
- // this means that there is no root to be had (normally)
- }
-
- Log.e(TAG, "Could not acquire root permissions");
-
- return false;
- }
-
- public static int findProcessId(Context context) {
- String dataPath = context.getFilesDir().getParentFile().getParentFile().getAbsolutePath();
- String command = dataPath + "/" + OrbotHelper.ORBOT_PACKAGE_NAME + "/app_bin/tor";
- int procId = -1;
-
- try {
- procId = findProcessIdWithPidOf(command);
-
- if (procId == -1)
- procId = findProcessIdWithPS(command);
- } catch (Exception e) {
- try {
- procId = findProcessIdWithPS(command);
- } catch (Exception e2) {
- Log.e(TAG, "Unable to get proc id for command: " + URLEncoder.encode(command), e2);
- }
- }
-
- return procId;
- }
-
- // use 'pidof' command
- public static int findProcessIdWithPidOf(String command) throws Exception
- {
-
- int procId = -1;
-
- Runtime r = Runtime.getRuntime();
-
- Process procPs = null;
-
- String baseName = new File(command).getName();
- // fix contributed my mikos on 2010.12.10
- procPs = r.exec(new String[] {
- SHELL_CMD_PIDOF, baseName
- });
- // procPs = r.exec(SHELL_CMD_PIDOF);
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
- String line = null;
-
- while ((line = reader.readLine()) != null)
- {
-
- try
- {
- // this line should just be the process id
- procId = Integer.parseInt(line.trim());
- break;
- } catch (NumberFormatException e)
- {
- Log.e("TorServiceUtils", "unable to parse process pid: " + line, e);
- }
- }
-
- return procId;
-
- }
-
- // use 'ps' command
- public static int findProcessIdWithPS(String command) throws Exception
- {
-
- int procId = -1;
-
- Runtime r = Runtime.getRuntime();
-
- Process procPs = null;
-
- procPs = r.exec(SHELL_CMD_PS);
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
- String line = null;
-
- while ((line = reader.readLine()) != null)
- {
- if (line.indexOf(' ' + command) != -1)
- {
-
- StringTokenizer st = new StringTokenizer(line, " ");
- st.nextToken(); // proc owner
-
- procId = Integer.parseInt(st.nextToken().trim());
-
- break;
- }
- }
-
- return procId;
-
- }
-
- public static int doShellCommand(String[] cmds, StringBuilder log, boolean runAsRoot,
- boolean waitFor) throws Exception
- {
-
- Process proc = null;
- int exitCode = -1;
-
- if (runAsRoot)
- proc = Runtime.getRuntime().exec("su");
- else
- proc = Runtime.getRuntime().exec("sh");
-
- OutputStreamWriter out = new OutputStreamWriter(proc.getOutputStream());
-
- for (int i = 0; i < cmds.length; i++)
- {
- // TorService.logMessage("executing shell cmd: " + cmds[i] +
- // "; runAsRoot=" + runAsRoot + ";waitFor=" + waitFor);
-
- out.write(cmds[i]);
- out.write("\n");
- }
-
- out.flush();
- out.write("exit\n");
- out.flush();
-
- if (waitFor)
- {
-
- final char buf[] = new char[10];
-
- // Consume the "stdout"
- InputStreamReader reader = new InputStreamReader(proc.getInputStream());
- int read = 0;
- while ((read = reader.read(buf)) != -1) {
- if (log != null)
- log.append(buf, 0, read);
- }
-
- // Consume the "stderr"
- reader = new InputStreamReader(proc.getErrorStream());
- read = 0;
- while ((read = reader.read(buf)) != -1) {
- if (log != null)
- log.append(buf, 0, read);
- }
-
- exitCode = proc.waitFor();
-
- }
-
- return exitCode;
-
- }
-}
+/*
+ * Copyright 2009-2016 Nathan Freitas
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hiddenservices.genesissearchengine.production.libs.netcipher.proxy;
+
+import android.content.Context;
+import android.util.Log;
+
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.net.URLEncoder;
+import java.util.StringTokenizer;
+
+public class TorServiceUtils {
+
+ private final static String TAG = "TorUtils";
+ // various console cmds
+ public final static String SHELL_CMD_CHMOD = "chmod";
+ public final static String SHELL_CMD_KILL = "kill -9";
+ public final static String SHELL_CMD_RM = "rm";
+ public final static String SHELL_CMD_PS = "ps";
+ public final static String SHELL_CMD_PIDOF = "pidof";
+
+ public final static String CHMOD_EXE_VALUE = "700";
+
+ public static boolean isRootPossible()
+ {
+
+ StringBuilder log = new StringBuilder();
+
+ try {
+
+ // Check if Superuser.apk exists
+ File fileSU = new File("/system/app/Superuser.apk");
+ if (fileSU.exists())
+ return true;
+
+ fileSU = new File("/system/app/superuser.apk");
+ if (fileSU.exists())
+ return true;
+
+ fileSU = new File("/system/bin/su");
+ if (fileSU.exists())
+ {
+ String[] cmd = {
+ "su"
+ };
+ int exitCode = TorServiceUtils.doShellCommand(cmd, log, false, true);
+ if (exitCode != 0)
+ return false;
+ else
+ return true;
+ }
+
+ // Check for 'su' binary
+ String[] cmd = {
+ "which su"
+ };
+ int exitCode = TorServiceUtils.doShellCommand(cmd, log, false, true);
+
+ if (exitCode == 0) {
+ Log.d(TAG, "root exists, but not sure about permissions");
+ return true;
+
+ }
+
+ } catch (IOException e) {
+ // this means that there is no root to be had (normally) so we won't
+ // log anything
+ Log.e(TAG, "Error checking for root access", e);
+
+ } catch (Exception e) {
+ Log.e(TAG, "Error checking for root access", e);
+ // this means that there is no root to be had (normally)
+ }
+
+ Log.e(TAG, "Could not acquire root permissions");
+
+ return false;
+ }
+
+ public static int findProcessId(Context context) {
+ String dataPath = context.getFilesDir().getParentFile().getParentFile().getAbsolutePath();
+ String command = dataPath + "/" + OrbotHelper.ORBOT_PACKAGE_NAME + "/app_bin/tor";
+ int procId = -1;
+
+ try {
+ procId = findProcessIdWithPidOf(command);
+
+ if (procId == -1)
+ procId = findProcessIdWithPS(command);
+ } catch (Exception e) {
+ try {
+ procId = findProcessIdWithPS(command);
+ } catch (Exception e2) {
+ Log.e(TAG, "Unable to get proc id for command: " + URLEncoder.encode(command), e2);
+ }
+ }
+
+ return procId;
+ }
+
+ // use 'pidof' command
+ public static int findProcessIdWithPidOf(String command) throws Exception
+ {
+
+ int procId = -1;
+
+ Runtime r = Runtime.getRuntime();
+
+ Process procPs = null;
+
+ String baseName = new File(command).getName();
+ // fix contributed my mikos on 2010.12.10
+ procPs = r.exec(new String[] {
+ SHELL_CMD_PIDOF, baseName
+ });
+ // procPs = r.exec(SHELL_CMD_PIDOF);
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
+ String line = null;
+
+ while ((line = reader.readLine()) != null)
+ {
+
+ try
+ {
+ // this line should just be the process id
+ procId = Integer.parseInt(line.trim());
+ break;
+ } catch (NumberFormatException e)
+ {
+ Log.e("TorServiceUtils", "unable to parse process pid: " + line, e);
+ }
+ }
+
+ return procId;
+
+ }
+
+ // use 'ps' command
+ public static int findProcessIdWithPS(String command) throws Exception
+ {
+
+ int procId = -1;
+
+ Runtime r = Runtime.getRuntime();
+
+ Process procPs = null;
+
+ procPs = r.exec(SHELL_CMD_PS);
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
+ String line = null;
+
+ while ((line = reader.readLine()) != null)
+ {
+ if (line.indexOf(' ' + command) != -1)
+ {
+
+ StringTokenizer st = new StringTokenizer(line, " ");
+ st.nextToken(); // proc owner
+
+ procId = Integer.parseInt(st.nextToken().trim());
+
+ break;
+ }
+ }
+
+ return procId;
+
+ }
+
+ public static int doShellCommand(String[] cmds, StringBuilder log, boolean runAsRoot,
+ boolean waitFor) throws Exception
+ {
+
+ Process proc = null;
+ int exitCode = -1;
+
+ if (runAsRoot)
+ proc = Runtime.getRuntime().exec("su");
+ else
+ proc = Runtime.getRuntime().exec("sh");
+
+ OutputStreamWriter out = new OutputStreamWriter(proc.getOutputStream());
+
+ for (int i = 0; i < cmds.length; i++)
+ {
+ // TorService.logMessage("executing shell cmd: " + cmds[i] +
+ // "; runAsRoot=" + runAsRoot + ";waitFor=" + waitFor);
+
+ out.write(cmds[i]);
+ out.write("\n");
+ }
+
+ out.flush();
+ out.write("exit\n");
+ out.flush();
+
+ if (waitFor)
+ {
+
+ final char buf[] = new char[10];
+
+ // Consume the "stdout"
+ InputStreamReader reader = new InputStreamReader(proc.getInputStream());
+ int read = 0;
+ while ((read = reader.read(buf)) != -1) {
+ if (log != null)
+ log.append(buf, 0, read);
+ }
+
+ // Consume the "stderr"
+ reader = new InputStreamReader(proc.getErrorStream());
+ read = 0;
+ while ((read = reader.read(buf)) != -1) {
+ if (log != null)
+ log.append(buf, 0, read);
+ }
+
+ exitCode = proc.waitFor();
+
+ }
+
+ return exitCode;
+
+ }
+}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/web/WebkitProxy.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/web/WebkitProxy.java
similarity index 96%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/web/WebkitProxy.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/web/WebkitProxy.java
index 8bb0e1b0..b4d0aa53 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/netcipher/web/WebkitProxy.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/netcipher/web/WebkitProxy.java
@@ -1,834 +1,834 @@
-/*
- * Copyright 2015 Anthony Restaino
- * Copyright 2012-2016 Nathan Freitas
-
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.darkweb.genesissearchengine.libs.netcipher.web;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import android.annotation.TargetApi;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.ActivityNotFoundException;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.net.Proxy;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Parcelable;
-import android.util.ArrayMap;
-import android.util.Log;
-import android.webkit.WebView;
-
-import org.torproject.android.service.wrapper.orbotLocalConstants;
-
-import ch.boye.httpclientandroidlib.HttpHost;
-
-public class WebkitProxy {
-
- private final static String DEFAULT_HOST = "localhost";//"127.0.0.1";
- private final static int DEFAULT_PORT = orbotLocalConstants.mHTTPPort;
- private final static int DEFAULT_SOCKS_PORT = orbotLocalConstants.mSOCKSPort;
-
- private final static int REQUEST_CODE = 0;
-
- private final static String TAG = "OrbotHelpher";
-
- public static boolean setProxy(String appClass, Context ctx, WebView wView, String host, int port) throws Exception
- {
-
- setSystemProperties(host, port);
-
- boolean worked = false;
-
- if (Build.VERSION.SDK_INT < 13)
- {
-// worked = setWebkitProxyGingerbread(ctx, host, port);
- setProxyUpToHC(wView, host, port);
- }
- else if (Build.VERSION.SDK_INT < 19)
- {
- worked = setWebkitProxyICS(ctx, host, port);
- }
- else if (Build.VERSION.SDK_INT < 20)
- {
- worked = setKitKatProxy(appClass, ctx, host, port);
-
- if (!worked) //some kitkat's still use ICS browser component (like Cyanogen 11)
- worked = setWebkitProxyICS(ctx, host, port);
-
- }
- else if (Build.VERSION.SDK_INT >= 21)
- {
- worked = setWebkitProxyLollipop(ctx, host, port);
-
- }
-
- return worked;
- }
-
- private static void setSystemProperties(String host, int port)
- {
-
- System.setProperty("proxyHost", host);
- System.setProperty("proxyPort", Integer.toString(port));
-
- System.setProperty("http.proxyHost", host);
- System.setProperty("http.proxyPort", Integer.toString(port));
-
- System.setProperty("https.proxyHost", host);
- System.setProperty("https.proxyPort", Integer.toString(port));
-
-
- System.setProperty("socks.proxyHost", host);
- System.setProperty("socks.proxyPort", Integer.toString(DEFAULT_SOCKS_PORT));
-
- System.setProperty("socksProxyHost", host);
- System.setProperty("socksProxyPort", Integer.toString(DEFAULT_SOCKS_PORT));
-
-
- /*
- ProxySelector pSelect = new ProxySelector();
- pSelect.addProxy(Proxy.Type.HTTP, host, port);
- ProxySelector.setDefault(pSelect);
- */
- /*
- System.setProperty("http_proxy", "http://" + host + ":" + port);
- System.setProperty("proxy-server", "http://" + host + ":" + port);
- System.setProperty("host-resolver-rules","MAP * 0.0.0.0 , EXCLUDE myproxy");
-
- System.getProperty("networkaddress.cache.ttl", "-1");
- */
-
- }
-
- private static void resetSystemProperties()
- {
-
- System.setProperty("proxyHost", "");
- System.setProperty("proxyPort", "");
-
- System.setProperty("http.proxyHost", "");
- System.setProperty("http.proxyPort", "");
-
- System.setProperty("https.proxyHost", "");
- System.setProperty("https.proxyPort", "");
-
-
- System.setProperty("socks.proxyHost", "");
- System.setProperty("socks.proxyPort", Integer.toString(DEFAULT_SOCKS_PORT));
-
- System.setProperty("socksProxyHost", "");
- System.setProperty("socksProxyPort", Integer.toString(DEFAULT_SOCKS_PORT));
-
- }
-
- /**
- * Override WebKit Proxy settings
- *
- * @param ctx Android ApplicationContext
- * @param host
- * @param port
- * @return true if Proxy was successfully set
- */
- private static boolean setWebkitProxyGingerbread(Context ctx, String host, int port)
- throws Exception
- {
-
- boolean ret = false;
-
- Object requestQueueObject = getRequestQueue(ctx);
- if (requestQueueObject != null) {
- // Create Proxy config object and set it into request Q
- HttpHost httpHost = new HttpHost(host, port, "http");
- setDeclaredField(requestQueueObject, "mProxyHost", httpHost);
- return true;
- }
- return false;
-
- }
-
-
-/**
- * Set Proxy for Android 3.2 and below.
- */
-@SuppressWarnings("all")
-private static boolean setProxyUpToHC(WebView webview, String host, int port) {
- Log.d(TAG, "Setting proxy with <= 3.2 API.");
-
- HttpHost proxyServer = new HttpHost(host, port);
- // Getting network
- Class networkClass = null;
- Object network = null;
- try {
- networkClass = Class.forName("android.webkit.Network");
- if (networkClass == null) {
- Log.e(TAG, "failed to get class for android.webkit.Network");
- return false;
- }
- Method getInstanceMethod = networkClass.getMethod("getInstance", Context.class);
- if (getInstanceMethod == null) {
- Log.e(TAG, "failed to get getInstance method");
- }
- network = getInstanceMethod.invoke(networkClass, new Object[]{webview.getContext()});
- } catch (Exception ex) {
- Log.e(TAG, "error getting network: " + ex);
- return false;
- }
- if (network == null) {
- Log.e(TAG, "error getting network: network is null");
- return false;
- }
- Object requestQueue = null;
- try {
- Field requestQueueField = networkClass
- .getDeclaredField("mRequestQueue");
- requestQueue = getFieldValueSafely(requestQueueField, network);
- } catch (Exception ex) {
- Log.e(TAG, "error getting field value");
- return false;
- }
- if (requestQueue == null) {
- Log.e(TAG, "Request queue is null");
- return false;
- }
- Field proxyHostField = null;
- try {
- Class requestQueueClass = Class.forName("android.net.http.RequestQueue");
- proxyHostField = requestQueueClass
- .getDeclaredField("mProxyHost");
- } catch (Exception ex) {
- Log.e(TAG, "error getting proxy host field");
- return false;
- }
-
- boolean temp = proxyHostField.isAccessible();
- try {
- proxyHostField.setAccessible(true);
- proxyHostField.set(requestQueue, proxyServer);
- } catch (Exception ex) {
- Log.e(TAG, "error setting proxy host");
- } finally {
- proxyHostField.setAccessible(temp);
- }
-
- Log.d(TAG, "Setting proxy with <= 3.2 API successful!");
- return true;
-}
-
-
-private static Object getFieldValueSafely(Field field, Object classInstance) throws IllegalArgumentException, IllegalAccessException {
- boolean oldAccessibleValue = field.isAccessible();
- field.setAccessible(true);
- Object result = field.get(classInstance);
- field.setAccessible(oldAccessibleValue);
- return result;
-}
-
- private static boolean setWebkitProxyICS(Context ctx, String host, int port)
- {
-
- // PSIPHON: added support for Android 4.x WebView proxy
- try
- {
- Class webViewCoreClass = Class.forName("android.webkit.WebViewCore");
-
- Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
- if (webViewCoreClass != null && proxyPropertiesClass != null)
- {
- Method m = webViewCoreClass.getDeclaredMethod("sendStaticMessage", Integer.TYPE,
- Object.class);
- Constructor c = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE,
- String.class);
-
- if (m != null && c != null)
- {
- m.setAccessible(true);
- c.setAccessible(true);
- Object properties = c.newInstance(host, port, null);
-
- // android.webkit.WebViewCore.EventHub.PROXY_CHANGED = 193;
- m.invoke(null, 193, properties);
-
-
- return true;
- }
-
-
- }
- } catch (Exception e)
- {
- Log.e("ProxySettings",
- "Exception setting WebKit proxy through android.net.ProxyProperties: "
- + e.toString());
- } catch (Error e)
- {
- Log.e("ProxySettings",
- "Exception setting WebKit proxy through android.webkit.Network: "
- + e.toString());
- }
-
- return false;
-
- }
-
- @TargetApi(19)
- public static boolean resetKitKatProxy(String appClass, Context appContext) {
-
- return setKitKatProxy(appClass, appContext,null,0);
- }
-
- @TargetApi(19)
- private static boolean setKitKatProxy(String appClass, Context appContext, String host, int port) {
- //Context appContext = webView.getContext().getApplicationContext();
-
- if (host != null)
- {
- System.setProperty("http.proxyHost", host);
- System.setProperty("http.proxyPort", Integer.toString(port));
- System.setProperty("https.proxyHost", host);
- System.setProperty("https.proxyPort", Integer.toString(port));
- }
-
- try {
- Class applictionCls = Class.forName(appClass);
- Field loadedApkField = applictionCls.getField("mLoadedApk");
- loadedApkField.setAccessible(true);
- Object loadedApk = loadedApkField.get(appContext);
- Class loadedApkCls = Class.forName("android.app.LoadedApk");
- Field receiversField = loadedApkCls.getDeclaredField("mReceivers");
- receiversField.setAccessible(true);
- ArrayMap receivers = (ArrayMap) receiversField.get(loadedApk);
- for (Object receiverMap : receivers.values()) {
- for (Object rec : ((ArrayMap) receiverMap).keySet()) {
- Class clazz = rec.getClass();
- if (clazz.getName().contains("ProxyChangeListener")) {
- Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class);
- Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
-
- if (host != null)
- {
- /*********** optional, may be need in future *************/
- final String CLASS_NAME = "android.net.ProxyProperties";
- Class cls = Class.forName(CLASS_NAME);
- Constructor constructor = cls.getConstructor(String.class, Integer.TYPE, String.class);
- constructor.setAccessible(true);
- Object proxyProperties = constructor.newInstance(host, port, null);
- intent.putExtra("proxy", (Parcelable) proxyProperties);
- /*********** optional, may be need in future *************/
- }
-
- onReceiveMethod.invoke(rec, appContext, intent);
- }
- }
- }
- return true;
- } catch (ClassNotFoundException e) {
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
- String exceptionAsString = sw.toString();
- Log.v(TAG, e.getMessage());
- Log.v(TAG, exceptionAsString);
- } catch (NoSuchFieldException e) {
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
- String exceptionAsString = sw.toString();
- Log.v(TAG, e.getMessage());
- Log.v(TAG, exceptionAsString);
- } catch (IllegalAccessException e) {
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
- String exceptionAsString = sw.toString();
- Log.v(TAG, e.getMessage());
- Log.v(TAG, exceptionAsString);
- } catch (IllegalArgumentException e) {
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
- String exceptionAsString = sw.toString();
- Log.v(TAG, e.getMessage());
- Log.v(TAG, exceptionAsString);
- } catch (NoSuchMethodException e) {
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
- String exceptionAsString = sw.toString();
- Log.v(TAG, e.getMessage());
- Log.v(TAG, exceptionAsString);
- } catch (InvocationTargetException e) {
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
- String exceptionAsString = sw.toString();
- Log.v(TAG, e.getMessage());
- Log.v(TAG, exceptionAsString);
- } catch (InstantiationException e) {
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
- String exceptionAsString = sw.toString();
- Log.v(TAG, e.getMessage());
- Log.v(TAG, exceptionAsString);
- }
- return false; }
-
- @TargetApi(21)
- public static boolean resetLollipopProxy(String appClass, Context appContext) {
-
- return setWebkitProxyLollipop(appContext,null,0);
- }
-
- // http://stackanswers.com/questions/25272393/android-webview-set-proxy-programmatically-on-android-l
- @TargetApi(21) // for android.util.ArrayMap methods
- @SuppressWarnings("rawtypes")
- private static boolean setWebkitProxyLollipop(Context appContext, String host, int port)
- {
- System.setProperty("http.proxyHost", host);
- System.setProperty("http.proxyPort", Integer.toString(port));
- System.setProperty("https.proxyHost", host);
- System.setProperty("https.proxyPort", Integer.toString(port));
- try {
- Class applictionClass = Class.forName("android.app.Application");
- Field mLoadedApkField = applictionClass.getDeclaredField("mLoadedApk");
- mLoadedApkField.setAccessible(true);
- Object mloadedApk = mLoadedApkField.get(appContext);
- Class loadedApkClass = Class.forName("android.app.LoadedApk");
- Field mReceiversField = loadedApkClass.getDeclaredField("mReceivers");
- mReceiversField.setAccessible(true);
- ArrayMap receivers = (ArrayMap) mReceiversField.get(mloadedApk);
- for (Object receiverMap : receivers.values())
- {
- for (Object receiver : ((ArrayMap) receiverMap).keySet())
- {
- Class clazz = receiver.getClass();
- if (clazz.getName().contains("ProxyChangeListener"))
- {
- Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class);
- Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
- onReceiveMethod.invoke(receiver, appContext, intent);
- }
- }
- }
- return true;
- }
- catch (ClassNotFoundException e)
- {
- Log.d("ProxySettings","Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString());
- }
- catch (NoSuchFieldException e)
- {
- Log.d("ProxySettings","Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString());
- }
- catch (IllegalAccessException e)
- {
- Log.d("ProxySettings","Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString());
- }
- catch (NoSuchMethodException e)
- {
- Log.d("ProxySettings","Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString());
- }
- catch (InvocationTargetException e)
- {
- Log.d("ProxySettings","Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString());
- }
- return false;
- }
-
- private static boolean sendProxyChangedIntent(Context ctx, String host, int port)
- {
-
- try
- {
- Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
- if (proxyPropertiesClass != null)
- {
- Constructor c = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE,
- String.class);
-
- if (c != null)
- {
- c.setAccessible(true);
- Object properties = c.newInstance(host, port, null);
-
- Intent intent = new Intent(android.net.Proxy.PROXY_CHANGE_ACTION);
- intent.putExtra("proxy",(Parcelable)properties);
- ctx.sendBroadcast(intent);
-
- }
-
- }
- } catch (Exception e)
- {
- Log.e("ProxySettings",
- "Exception sending Intent ",e);
- } catch (Error e)
- {
- Log.e("ProxySettings",
- "Exception sending Intent ",e);
- }
-
- return false;
-
- }
-
- /**
- private static boolean setKitKatProxy0(Context ctx, String host, int port)
- {
-
- try
- {
- Class cmClass = Class.forName("android.net.ConnectivityManager");
-
- Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
- if (cmClass != null && proxyPropertiesClass != null)
- {
- Constructor c = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE,
- String.class);
-
- if (c != null)
- {
- c.setAccessible(true);
-
- Object proxyProps = c.newInstance(host, port, null);
- ConnectivityManager cm =
- (ConnectivityManager)ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
-
- Method mSetGlobalProxy = cmClass.getDeclaredMethod("setGlobalProxy", proxyPropertiesClass);
-
- mSetGlobalProxy.invoke(cm, proxyProps);
-
- return true;
- }
-
- }
- } catch (Exception e)
- {
- Log.e("ProxySettings",
- "ConnectivityManager.setGlobalProxy ",e);
- }
-
- return false;
-
- }
- */
- //CommandLine.initFromFile(COMMAND_LINE_FILE);
-
- /**
- private static boolean setKitKatProxy2 (Context ctx, String host, int port)
- {
-
- String commandLinePath = "/data/local/tmp/orweb.conf";
- try
- {
- Class webViewCoreClass = Class.forName("org.chromium.content.common.CommandLine");
-
- if (webViewCoreClass != null)
- {
- for (Method method : webViewCoreClass.getDeclaredMethods())
- {
- Log.d("Orweb","Proxy methods: " + method.getName());
- }
-
- Method m = webViewCoreClass.getDeclaredMethod("initFromFile",
- String.class);
-
- if (m != null)
- {
- m.setAccessible(true);
- m.invoke(null, commandLinePath);
- return true;
- }
- else
- return false;
- }
- } catch (Exception e)
- {
- Log.e("ProxySettings",
- "Exception setting WebKit proxy through android.net.ProxyProperties: "
- + e.toString());
- } catch (Error e)
- {
- Log.e("ProxySettings",
- "Exception setting WebKit proxy through android.webkit.Network: "
- + e.toString());
- }
-
- return false;
- }
-
- /**
- private static boolean setKitKatProxy (Context ctx, String host, int port)
- {
-
- try
- {
- Class webViewCoreClass = Class.forName("android.net.Proxy");
-
- Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
- if (webViewCoreClass != null && proxyPropertiesClass != null)
- {
- for (Method method : webViewCoreClass.getDeclaredMethods())
- {
- Log.d("Orweb","Proxy methods: " + method.getName());
- }
-
- Method m = webViewCoreClass.getDeclaredMethod("setHttpProxySystemProperty",
- proxyPropertiesClass);
- Constructor c = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE,
- String.class);
-
- if (m != null && c != null)
- {
- m.setAccessible(true);
- c.setAccessible(true);
- Object properties = c.newInstance(host, port, null);
-
- m.invoke(null, properties);
- return true;
- }
- else
- return false;
- }
- } catch (Exception e)
- {
- Log.e("ProxySettings",
- "Exception setting WebKit proxy through android.net.ProxyProperties: "
- + e.toString());
- } catch (Error e)
- {
- Log.e("ProxySettings",
- "Exception setting WebKit proxy through android.webkit.Network: "
- + e.toString());
- }
-
- return false;
- }
-
- private static boolean resetProxyForKitKat ()
- {
-
- try
- {
- Class webViewCoreClass = Class.forName("android.net.Proxy");
-
- Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
- if (webViewCoreClass != null && proxyPropertiesClass != null)
- {
- for (Method method : webViewCoreClass.getDeclaredMethods())
- {
- Log.d("Orweb","Proxy methods: " + method.getName());
- }
-
- Method m = webViewCoreClass.getDeclaredMethod("setHttpProxySystemProperty",
- proxyPropertiesClass);
-
- if (m != null)
- {
- m.setAccessible(true);
-
- m.invoke(null, null);
- return true;
- }
- else
- return false;
- }
- } catch (Exception e)
- {
- Log.e("ProxySettings",
- "Exception setting WebKit proxy through android.net.ProxyProperties: "
- + e.toString());
- } catch (Error e)
- {
- Log.e("ProxySettings",
- "Exception setting WebKit proxy through android.webkit.Network: "
- + e.toString());
- }
-
- return false;
- }**/
-
- public static void resetProxy(String appClass, Context ctx) throws Exception {
-
- resetSystemProperties();
-
- if (Build.VERSION.SDK_INT < 14)
- {
- resetProxyForGingerBread(ctx);
- }
- else if (Build.VERSION.SDK_INT < 19)
- {
- resetProxyForICS();
- }
- else
- {
- resetKitKatProxy(appClass, ctx);
- }
-
- }
-
- private static void resetProxyForICS() throws Exception{
- try
- {
- Class webViewCoreClass = Class.forName("android.webkit.WebViewCore");
- Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
- if (webViewCoreClass != null && proxyPropertiesClass != null)
- {
- Method m = webViewCoreClass.getDeclaredMethod("sendStaticMessage", Integer.TYPE,
- Object.class);
-
- if (m != null)
- {
- m.setAccessible(true);
-
- // android.webkit.WebViewCore.EventHub.PROXY_CHANGED = 193;
- m.invoke(null, 193, null);
- }
- }
- } catch (Exception e)
- {
- Log.e("ProxySettings",
- "Exception setting WebKit proxy through android.net.ProxyProperties: "
- + e.toString());
- throw e;
- } catch (Error e)
- {
- Log.e("ProxySettings",
- "Exception setting WebKit proxy through android.webkit.Network: "
- + e.toString());
- throw e;
- }
- }
-
- private static void resetProxyForGingerBread(Context ctx) throws Exception {
- Object requestQueueObject = getRequestQueue(ctx);
- if (requestQueueObject != null) {
- setDeclaredField(requestQueueObject, "mProxyHost", null);
- }
- }
-
- public static Object getRequestQueue(Context ctx) throws Exception {
- Object ret = null;
- Class networkClass = Class.forName("android.webkit.Network");
- if (networkClass != null) {
- Object networkObj = invokeMethod(networkClass, "getInstance", new Object[] {
- ctx
- }, Context.class);
- if (networkObj != null) {
- ret = getDeclaredField(networkObj, "mRequestQueue");
- }
- }
- return ret;
- }
-
- private static Object getDeclaredField(Object obj, String name)
- throws SecurityException, NoSuchFieldException,
- IllegalArgumentException, IllegalAccessException {
- Field f = obj.getClass().getDeclaredField(name);
- f.setAccessible(true);
- Object out = f.get(obj);
- // System.out.println(obj.getClass().getName() + "." + name + " = "+
- // out);
- return out;
- }
-
- private static void setDeclaredField(Object obj, String name, Object value)
- throws SecurityException, NoSuchFieldException,
- IllegalArgumentException, IllegalAccessException {
- Field f = obj.getClass().getDeclaredField(name);
- f.setAccessible(true);
- f.set(obj, value);
- }
-
- private static Object invokeMethod(Object object, String methodName, Object[] params,
- Class... types) throws Exception {
- Object out = null;
- Class c = object instanceof Class ? (Class) object : object.getClass();
- if (types != null) {
- Method method = c.getMethod(methodName, types);
- out = method.invoke(object, params);
- } else {
- Method method = c.getMethod(methodName);
- out = method.invoke(object);
- }
- // System.out.println(object.getClass().getName() + "." + methodName +
- // "() = "+ out);
- return out;
- }
-
- public static Socket getSocket(Context context, String proxyHost, int proxyPort)
- throws IOException
- {
- Socket sock = new Socket();
-
- sock.connect(new InetSocketAddress(proxyHost, proxyPort), 10000);
-
- return sock;
- }
-
- public static Socket getSocket(Context context) throws IOException
- {
- return getSocket(context, DEFAULT_HOST, DEFAULT_SOCKS_PORT);
-
- }
-
- public static AlertDialog initOrbot(Activity activity,
- CharSequence stringTitle,
- CharSequence stringMessage,
- CharSequence stringButtonYes,
- CharSequence stringButtonNo,
- CharSequence stringDesiredBarcodeFormats) {
- Intent intentScan = new Intent("org.torproject.android.START_TOR");
- intentScan.addCategory(Intent.CATEGORY_DEFAULT);
-
- try {
- activity.startActivityForResult(intentScan, REQUEST_CODE);
- return null;
- } catch (ActivityNotFoundException e) {
- return showDownloadDialog(activity, stringTitle, stringMessage, stringButtonYes,
- stringButtonNo);
- }
- }
-
- private static AlertDialog showDownloadDialog(final Activity activity,
- CharSequence stringTitle,
- CharSequence stringMessage,
- CharSequence stringButtonYes,
- CharSequence stringButtonNo) {
- AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity);
- downloadDialog.setTitle(stringTitle);
- downloadDialog.setMessage(stringMessage);
- downloadDialog.setPositiveButton(stringButtonYes, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialogInterface, int i) {
- Uri uri = Uri.parse("market://search?q=pname:org.torproject.android");
- Intent intent = new Intent(Intent.ACTION_VIEW, uri);
- activity.startActivity(intent);
- }
- });
- downloadDialog.setNegativeButton(stringButtonNo, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialogInterface, int i) {
- }
- });
- return downloadDialog.show();
- }
-
-
-
-}
+/*
+ * Copyright 2015 Anthony Restaino
+ * Copyright 2012-2016 Nathan Freitas
+
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hiddenservices.genesissearchengine.production.libs.netcipher.web;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.ActivityNotFoundException;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.net.Proxy;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Parcelable;
+import android.util.ArrayMap;
+import android.util.Log;
+import android.webkit.WebView;
+
+import org.orbotproject.android.service.wrapper.orbotLocalConstants;
+
+import ch.boye.httpclientandroidlib.HttpHost;
+
+public class WebkitProxy {
+
+ private final static String DEFAULT_HOST = "localhost";//"127.0.0.1";
+ private final static int DEFAULT_PORT = orbotLocalConstants.mHTTPPort;
+ private final static int DEFAULT_SOCKS_PORT = orbotLocalConstants.mSOCKSPort;
+
+ private final static int REQUEST_CODE = 0;
+
+ private final static String TAG = "OrbotHelpher";
+
+ public static boolean setProxy(String appClass, Context ctx, WebView wView, String host, int port) throws Exception
+ {
+
+ setSystemProperties(host, port);
+
+ boolean worked = false;
+
+ if (Build.VERSION.SDK_INT < 13)
+ {
+// worked = setWebkitProxyGingerbread(ctx, host, port);
+ setProxyUpToHC(wView, host, port);
+ }
+ else if (Build.VERSION.SDK_INT < 19)
+ {
+ worked = setWebkitProxyICS(ctx, host, port);
+ }
+ else if (Build.VERSION.SDK_INT < 20)
+ {
+ worked = setKitKatProxy(appClass, ctx, host, port);
+
+ if (!worked) //some kitkat's still use ICS browser component (like Cyanogen 11)
+ worked = setWebkitProxyICS(ctx, host, port);
+
+ }
+ else if (Build.VERSION.SDK_INT >= 21)
+ {
+ worked = setWebkitProxyLollipop(ctx, host, port);
+
+ }
+
+ return worked;
+ }
+
+ private static void setSystemProperties(String host, int port)
+ {
+
+ System.setProperty("proxyHost", host);
+ System.setProperty("proxyPort", Integer.toString(port));
+
+ System.setProperty("http.proxyHost", host);
+ System.setProperty("http.proxyPort", Integer.toString(port));
+
+ System.setProperty("https.proxyHost", host);
+ System.setProperty("https.proxyPort", Integer.toString(port));
+
+
+ System.setProperty("socks.proxyHost", host);
+ System.setProperty("socks.proxyPort", Integer.toString(DEFAULT_SOCKS_PORT));
+
+ System.setProperty("socksProxyHost", host);
+ System.setProperty("socksProxyPort", Integer.toString(DEFAULT_SOCKS_PORT));
+
+
+ /*
+ ProxySelector pSelect = new ProxySelector();
+ pSelect.addProxy(Proxy.Type.HTTP, host, port);
+ ProxySelector.setDefault(pSelect);
+ */
+ /*
+ System.setProperty("http_proxy", "http://" + host + ":" + port);
+ System.setProperty("proxy-server", "http://" + host + ":" + port);
+ System.setProperty("host-resolver-rules","MAP * 0.0.0.0 , EXCLUDE myproxy");
+
+ System.getProperty("networkaddress.cache.ttl", "-1");
+ */
+
+ }
+
+ private static void resetSystemProperties()
+ {
+
+ System.setProperty("proxyHost", "");
+ System.setProperty("proxyPort", "");
+
+ System.setProperty("http.proxyHost", "");
+ System.setProperty("http.proxyPort", "");
+
+ System.setProperty("https.proxyHost", "");
+ System.setProperty("https.proxyPort", "");
+
+
+ System.setProperty("socks.proxyHost", "");
+ System.setProperty("socks.proxyPort", Integer.toString(DEFAULT_SOCKS_PORT));
+
+ System.setProperty("socksProxyHost", "");
+ System.setProperty("socksProxyPort", Integer.toString(DEFAULT_SOCKS_PORT));
+
+ }
+
+ /**
+ * Override WebKit Proxy settings
+ *
+ * @param ctx Android ApplicationContext
+ * @param host
+ * @param port
+ * @return true if Proxy was successfully set
+ */
+ private static boolean setWebkitProxyGingerbread(Context ctx, String host, int port)
+ throws Exception
+ {
+
+ boolean ret = false;
+
+ Object requestQueueObject = getRequestQueue(ctx);
+ if (requestQueueObject != null) {
+ // Create Proxy config object and set it into request Q
+ HttpHost httpHost = new HttpHost(host, port, "http");
+ setDeclaredField(requestQueueObject, "mProxyHost", httpHost);
+ return true;
+ }
+ return false;
+
+ }
+
+
+/**
+ * Set Proxy for Android 3.2 and below.
+ */
+@SuppressWarnings("all")
+private static boolean setProxyUpToHC(WebView webview, String host, int port) {
+ Log.d(TAG, "Setting proxy with <= 3.2 API.");
+
+ HttpHost proxyServer = new HttpHost(host, port);
+ // Getting network
+ Class networkClass = null;
+ Object network = null;
+ try {
+ networkClass = Class.forName("android.webkit.Network");
+ if (networkClass == null) {
+ Log.e(TAG, "failed to get class for android.webkit.Network");
+ return false;
+ }
+ Method getInstanceMethod = networkClass.getMethod("getInstance", Context.class);
+ if (getInstanceMethod == null) {
+ Log.e(TAG, "failed to get getInstance method");
+ }
+ network = getInstanceMethod.invoke(networkClass, new Object[]{webview.getContext()});
+ } catch (Exception ex) {
+ Log.e(TAG, "error getting network: " + ex);
+ return false;
+ }
+ if (network == null) {
+ Log.e(TAG, "error getting network: network is null");
+ return false;
+ }
+ Object requestQueue = null;
+ try {
+ Field requestQueueField = networkClass
+ .getDeclaredField("mRequestQueue");
+ requestQueue = getFieldValueSafely(requestQueueField, network);
+ } catch (Exception ex) {
+ Log.e(TAG, "error getting field value");
+ return false;
+ }
+ if (requestQueue == null) {
+ Log.e(TAG, "Request queue is null");
+ return false;
+ }
+ Field proxyHostField = null;
+ try {
+ Class requestQueueClass = Class.forName("android.net.http.RequestQueue");
+ proxyHostField = requestQueueClass
+ .getDeclaredField("mProxyHost");
+ } catch (Exception ex) {
+ Log.e(TAG, "error getting proxy host field");
+ return false;
+ }
+
+ boolean temp = proxyHostField.isAccessible();
+ try {
+ proxyHostField.setAccessible(true);
+ proxyHostField.set(requestQueue, proxyServer);
+ } catch (Exception ex) {
+ Log.e(TAG, "error setting proxy host");
+ } finally {
+ proxyHostField.setAccessible(temp);
+ }
+
+ Log.d(TAG, "Setting proxy with <= 3.2 API successful!");
+ return true;
+}
+
+
+private static Object getFieldValueSafely(Field field, Object classInstance) throws IllegalArgumentException, IllegalAccessException {
+ boolean oldAccessibleValue = field.isAccessible();
+ field.setAccessible(true);
+ Object result = field.get(classInstance);
+ field.setAccessible(oldAccessibleValue);
+ return result;
+}
+
+ private static boolean setWebkitProxyICS(Context ctx, String host, int port)
+ {
+
+ // PSIPHON: added support for Android 4.x WebView proxy
+ try
+ {
+ Class webViewCoreClass = Class.forName("android.webkit.WebViewCore");
+
+ Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
+ if (webViewCoreClass != null && proxyPropertiesClass != null)
+ {
+ Method m = webViewCoreClass.getDeclaredMethod("sendStaticMessage", Integer.TYPE,
+ Object.class);
+ Constructor c = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE,
+ String.class);
+
+ if (m != null && c != null)
+ {
+ m.setAccessible(true);
+ c.setAccessible(true);
+ Object properties = c.newInstance(host, port, null);
+
+ // android.webkit.WebViewCore.EventHub.PROXY_CHANGED = 193;
+ m.invoke(null, 193, properties);
+
+
+ return true;
+ }
+
+
+ }
+ } catch (Exception e)
+ {
+ Log.e("ProxySettings",
+ "Exception setting WebKit proxy through android.net.ProxyProperties: "
+ + e.toString());
+ } catch (Error e)
+ {
+ Log.e("ProxySettings",
+ "Exception setting WebKit proxy through android.webkit.Network: "
+ + e.toString());
+ }
+
+ return false;
+
+ }
+
+ @TargetApi(19)
+ public static boolean resetKitKatProxy(String appClass, Context appContext) {
+
+ return setKitKatProxy(appClass, appContext,null,0);
+ }
+
+ @TargetApi(19)
+ private static boolean setKitKatProxy(String appClass, Context appContext, String host, int port) {
+ //Context appContext = webView.getContext().getApplicationContext();
+
+ if (host != null)
+ {
+ System.setProperty("http.proxyHost", host);
+ System.setProperty("http.proxyPort", Integer.toString(port));
+ System.setProperty("https.proxyHost", host);
+ System.setProperty("https.proxyPort", Integer.toString(port));
+ }
+
+ try {
+ Class applictionCls = Class.forName(appClass);
+ Field loadedApkField = applictionCls.getField("mLoadedApk");
+ loadedApkField.setAccessible(true);
+ Object loadedApk = loadedApkField.get(appContext);
+ Class loadedApkCls = Class.forName("android.app.LoadedApk");
+ Field receiversField = loadedApkCls.getDeclaredField("mReceivers");
+ receiversField.setAccessible(true);
+ ArrayMap receivers = (ArrayMap) receiversField.get(loadedApk);
+ for (Object receiverMap : receivers.values()) {
+ for (Object rec : ((ArrayMap) receiverMap).keySet()) {
+ Class clazz = rec.getClass();
+ if (clazz.getName().contains("ProxyChangeListener")) {
+ Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class);
+ Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
+
+ if (host != null)
+ {
+ /*********** optional, may be need in future *************/
+ final String CLASS_NAME = "android.net.ProxyProperties";
+ Class cls = Class.forName(CLASS_NAME);
+ Constructor constructor = cls.getConstructor(String.class, Integer.TYPE, String.class);
+ constructor.setAccessible(true);
+ Object proxyProperties = constructor.newInstance(host, port, null);
+ intent.putExtra("proxy", (Parcelable) proxyProperties);
+ /*********** optional, may be need in future *************/
+ }
+
+ onReceiveMethod.invoke(rec, appContext, intent);
+ }
+ }
+ }
+ return true;
+ } catch (ClassNotFoundException e) {
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ String exceptionAsString = sw.toString();
+ Log.v(TAG, e.getMessage());
+ Log.v(TAG, exceptionAsString);
+ } catch (NoSuchFieldException e) {
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ String exceptionAsString = sw.toString();
+ Log.v(TAG, e.getMessage());
+ Log.v(TAG, exceptionAsString);
+ } catch (IllegalAccessException e) {
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ String exceptionAsString = sw.toString();
+ Log.v(TAG, e.getMessage());
+ Log.v(TAG, exceptionAsString);
+ } catch (IllegalArgumentException e) {
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ String exceptionAsString = sw.toString();
+ Log.v(TAG, e.getMessage());
+ Log.v(TAG, exceptionAsString);
+ } catch (NoSuchMethodException e) {
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ String exceptionAsString = sw.toString();
+ Log.v(TAG, e.getMessage());
+ Log.v(TAG, exceptionAsString);
+ } catch (InvocationTargetException e) {
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ String exceptionAsString = sw.toString();
+ Log.v(TAG, e.getMessage());
+ Log.v(TAG, exceptionAsString);
+ } catch (InstantiationException e) {
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ String exceptionAsString = sw.toString();
+ Log.v(TAG, e.getMessage());
+ Log.v(TAG, exceptionAsString);
+ }
+ return false; }
+
+ @TargetApi(21)
+ public static boolean resetLollipopProxy(String appClass, Context appContext) {
+
+ return setWebkitProxyLollipop(appContext,null,0);
+ }
+
+ // http://stackanswers.com/questions/25272393/android-webview-set-proxy-programmatically-on-android-l
+ @TargetApi(21) // for android.util.ArrayMap methods
+ @SuppressWarnings("rawtypes")
+ private static boolean setWebkitProxyLollipop(Context appContext, String host, int port)
+ {
+ System.setProperty("http.proxyHost", host);
+ System.setProperty("http.proxyPort", Integer.toString(port));
+ System.setProperty("https.proxyHost", host);
+ System.setProperty("https.proxyPort", Integer.toString(port));
+ try {
+ Class applictionClass = Class.forName("android.app.Application");
+ Field mLoadedApkField = applictionClass.getDeclaredField("mLoadedApk");
+ mLoadedApkField.setAccessible(true);
+ Object mloadedApk = mLoadedApkField.get(appContext);
+ Class loadedApkClass = Class.forName("android.app.LoadedApk");
+ Field mReceiversField = loadedApkClass.getDeclaredField("mReceivers");
+ mReceiversField.setAccessible(true);
+ ArrayMap receivers = (ArrayMap) mReceiversField.get(mloadedApk);
+ for (Object receiverMap : receivers.values())
+ {
+ for (Object receiver : ((ArrayMap) receiverMap).keySet())
+ {
+ Class clazz = receiver.getClass();
+ if (clazz.getName().contains("ProxyChangeListener"))
+ {
+ Method onReceiveMethod = clazz.getDeclaredMethod("onReceive", Context.class, Intent.class);
+ Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
+ onReceiveMethod.invoke(receiver, appContext, intent);
+ }
+ }
+ }
+ return true;
+ }
+ catch (ClassNotFoundException e)
+ {
+ Log.d("ProxySettings","Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString());
+ }
+ catch (NoSuchFieldException e)
+ {
+ Log.d("ProxySettings","Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString());
+ }
+ catch (IllegalAccessException e)
+ {
+ Log.d("ProxySettings","Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString());
+ }
+ catch (NoSuchMethodException e)
+ {
+ Log.d("ProxySettings","Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString());
+ }
+ catch (InvocationTargetException e)
+ {
+ Log.d("ProxySettings","Exception setting WebKit proxy on Lollipop through ProxyChangeListener: " + e.toString());
+ }
+ return false;
+ }
+
+ private static boolean sendProxyChangedIntent(Context ctx, String host, int port)
+ {
+
+ try
+ {
+ Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
+ if (proxyPropertiesClass != null)
+ {
+ Constructor c = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE,
+ String.class);
+
+ if (c != null)
+ {
+ c.setAccessible(true);
+ Object properties = c.newInstance(host, port, null);
+
+ Intent intent = new Intent(android.net.Proxy.PROXY_CHANGE_ACTION);
+ intent.putExtra("proxy",(Parcelable)properties);
+ ctx.sendBroadcast(intent);
+
+ }
+
+ }
+ } catch (Exception e)
+ {
+ Log.e("ProxySettings",
+ "Exception sending Intent ",e);
+ } catch (Error e)
+ {
+ Log.e("ProxySettings",
+ "Exception sending Intent ",e);
+ }
+
+ return false;
+
+ }
+
+ /**
+ private static boolean setKitKatProxy0(Context ctx, String host, int port)
+ {
+
+ try
+ {
+ Class cmClass = Class.forName("android.net.ConnectivityManager");
+
+ Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
+ if (cmClass != null && proxyPropertiesClass != null)
+ {
+ Constructor c = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE,
+ String.class);
+
+ if (c != null)
+ {
+ c.setAccessible(true);
+
+ Object proxyProps = c.newInstance(host, port, null);
+ ConnectivityManager cm =
+ (ConnectivityManager)ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
+
+ Method mSetGlobalProxy = cmClass.getDeclaredMethod("setGlobalProxy", proxyPropertiesClass);
+
+ mSetGlobalProxy.invoke(cm, proxyProps);
+
+ return true;
+ }
+
+ }
+ } catch (Exception e)
+ {
+ Log.e("ProxySettings",
+ "ConnectivityManager.setGlobalProxy ",e);
+ }
+
+ return false;
+
+ }
+ */
+ //CommandLine.initFromFile(COMMAND_LINE_FILE);
+
+ /**
+ private static boolean setKitKatProxy2 (Context ctx, String host, int port)
+ {
+
+ String commandLinePath = "/data/local/tmp/orweb.conf";
+ try
+ {
+ Class webViewCoreClass = Class.forName("org.chromium.content.common.CommandLine");
+
+ if (webViewCoreClass != null)
+ {
+ for (Method method : webViewCoreClass.getDeclaredMethods())
+ {
+ Log.d("Orweb","Proxy methods: " + method.getName());
+ }
+
+ Method m = webViewCoreClass.getDeclaredMethod("initFromFile",
+ String.class);
+
+ if (m != null)
+ {
+ m.setAccessible(true);
+ m.invoke(null, commandLinePath);
+ return true;
+ }
+ else
+ return false;
+ }
+ } catch (Exception e)
+ {
+ Log.e("ProxySettings",
+ "Exception setting WebKit proxy through android.net.ProxyProperties: "
+ + e.toString());
+ } catch (Error e)
+ {
+ Log.e("ProxySettings",
+ "Exception setting WebKit proxy through android.webkit.Network: "
+ + e.toString());
+ }
+
+ return false;
+ }
+
+ /**
+ private static boolean setKitKatProxy (Context ctx, String host, int port)
+ {
+
+ try
+ {
+ Class webViewCoreClass = Class.forName("android.net.Proxy");
+
+ Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
+ if (webViewCoreClass != null && proxyPropertiesClass != null)
+ {
+ for (Method method : webViewCoreClass.getDeclaredMethods())
+ {
+ Log.d("Orweb","Proxy methods: " + method.getName());
+ }
+
+ Method m = webViewCoreClass.getDeclaredMethod("setHttpProxySystemProperty",
+ proxyPropertiesClass);
+ Constructor c = proxyPropertiesClass.getConstructor(String.class, Integer.TYPE,
+ String.class);
+
+ if (m != null && c != null)
+ {
+ m.setAccessible(true);
+ c.setAccessible(true);
+ Object properties = c.newInstance(host, port, null);
+
+ m.invoke(null, properties);
+ return true;
+ }
+ else
+ return false;
+ }
+ } catch (Exception e)
+ {
+ Log.e("ProxySettings",
+ "Exception setting WebKit proxy through android.net.ProxyProperties: "
+ + e.toString());
+ } catch (Error e)
+ {
+ Log.e("ProxySettings",
+ "Exception setting WebKit proxy through android.webkit.Network: "
+ + e.toString());
+ }
+
+ return false;
+ }
+
+ private static boolean resetProxyForKitKat ()
+ {
+
+ try
+ {
+ Class webViewCoreClass = Class.forName("android.net.Proxy");
+
+ Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
+ if (webViewCoreClass != null && proxyPropertiesClass != null)
+ {
+ for (Method method : webViewCoreClass.getDeclaredMethods())
+ {
+ Log.d("Orweb","Proxy methods: " + method.getName());
+ }
+
+ Method m = webViewCoreClass.getDeclaredMethod("setHttpProxySystemProperty",
+ proxyPropertiesClass);
+
+ if (m != null)
+ {
+ m.setAccessible(true);
+
+ m.invoke(null, null);
+ return true;
+ }
+ else
+ return false;
+ }
+ } catch (Exception e)
+ {
+ Log.e("ProxySettings",
+ "Exception setting WebKit proxy through android.net.ProxyProperties: "
+ + e.toString());
+ } catch (Error e)
+ {
+ Log.e("ProxySettings",
+ "Exception setting WebKit proxy through android.webkit.Network: "
+ + e.toString());
+ }
+
+ return false;
+ }**/
+
+ public static void resetProxy(String appClass, Context ctx) throws Exception {
+
+ resetSystemProperties();
+
+ if (Build.VERSION.SDK_INT < 14)
+ {
+ resetProxyForGingerBread(ctx);
+ }
+ else if (Build.VERSION.SDK_INT < 19)
+ {
+ resetProxyForICS();
+ }
+ else
+ {
+ resetKitKatProxy(appClass, ctx);
+ }
+
+ }
+
+ private static void resetProxyForICS() throws Exception{
+ try
+ {
+ Class webViewCoreClass = Class.forName("android.webkit.WebViewCore");
+ Class proxyPropertiesClass = Class.forName("android.net.ProxyProperties");
+ if (webViewCoreClass != null && proxyPropertiesClass != null)
+ {
+ Method m = webViewCoreClass.getDeclaredMethod("sendStaticMessage", Integer.TYPE,
+ Object.class);
+
+ if (m != null)
+ {
+ m.setAccessible(true);
+
+ // android.webkit.WebViewCore.EventHub.PROXY_CHANGED = 193;
+ m.invoke(null, 193, null);
+ }
+ }
+ } catch (Exception e)
+ {
+ Log.e("ProxySettings",
+ "Exception setting WebKit proxy through android.net.ProxyProperties: "
+ + e.toString());
+ throw e;
+ } catch (Error e)
+ {
+ Log.e("ProxySettings",
+ "Exception setting WebKit proxy through android.webkit.Network: "
+ + e.toString());
+ throw e;
+ }
+ }
+
+ private static void resetProxyForGingerBread(Context ctx) throws Exception {
+ Object requestQueueObject = getRequestQueue(ctx);
+ if (requestQueueObject != null) {
+ setDeclaredField(requestQueueObject, "mProxyHost", null);
+ }
+ }
+
+ public static Object getRequestQueue(Context ctx) throws Exception {
+ Object ret = null;
+ Class networkClass = Class.forName("android.webkit.Network");
+ if (networkClass != null) {
+ Object networkObj = invokeMethod(networkClass, "getInstance", new Object[] {
+ ctx
+ }, Context.class);
+ if (networkObj != null) {
+ ret = getDeclaredField(networkObj, "mRequestQueue");
+ }
+ }
+ return ret;
+ }
+
+ private static Object getDeclaredField(Object obj, String name)
+ throws SecurityException, NoSuchFieldException,
+ IllegalArgumentException, IllegalAccessException {
+ Field f = obj.getClass().getDeclaredField(name);
+ f.setAccessible(true);
+ Object out = f.get(obj);
+ // System.out.println(obj.getClass().getName() + "." + name + " = "+
+ // out);
+ return out;
+ }
+
+ private static void setDeclaredField(Object obj, String name, Object value)
+ throws SecurityException, NoSuchFieldException,
+ IllegalArgumentException, IllegalAccessException {
+ Field f = obj.getClass().getDeclaredField(name);
+ f.setAccessible(true);
+ f.set(obj, value);
+ }
+
+ private static Object invokeMethod(Object object, String methodName, Object[] params,
+ Class... types) throws Exception {
+ Object out = null;
+ Class c = object instanceof Class ? (Class) object : object.getClass();
+ if (types != null) {
+ Method method = c.getMethod(methodName, types);
+ out = method.invoke(object, params);
+ } else {
+ Method method = c.getMethod(methodName);
+ out = method.invoke(object);
+ }
+ // System.out.println(object.getClass().getName() + "." + methodName +
+ // "() = "+ out);
+ return out;
+ }
+
+ public static Socket getSocket(Context context, String proxyHost, int proxyPort)
+ throws IOException
+ {
+ Socket sock = new Socket();
+
+ sock.connect(new InetSocketAddress(proxyHost, proxyPort), 10000);
+
+ return sock;
+ }
+
+ public static Socket getSocket(Context context) throws IOException
+ {
+ return getSocket(context, DEFAULT_HOST, DEFAULT_SOCKS_PORT);
+
+ }
+
+ public static AlertDialog initOrbot(Activity activity,
+ CharSequence stringTitle,
+ CharSequence stringMessage,
+ CharSequence stringButtonYes,
+ CharSequence stringButtonNo,
+ CharSequence stringDesiredBarcodeFormats) {
+ Intent intentScan = new Intent("org.torproject.android.START_TOR");
+ intentScan.addCategory(Intent.CATEGORY_DEFAULT);
+
+ try {
+ activity.startActivityForResult(intentScan, REQUEST_CODE);
+ return null;
+ } catch (ActivityNotFoundException e) {
+ return showDownloadDialog(activity, stringTitle, stringMessage, stringButtonYes,
+ stringButtonNo);
+ }
+ }
+
+ private static AlertDialog showDownloadDialog(final Activity activity,
+ CharSequence stringTitle,
+ CharSequence stringMessage,
+ CharSequence stringButtonYes,
+ CharSequence stringButtonNo) {
+ AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity);
+ downloadDialog.setTitle(stringTitle);
+ downloadDialog.setMessage(stringMessage);
+ downloadDialog.setPositiveButton(stringButtonYes, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialogInterface, int i) {
+ Uri uri = Uri.parse("market://search?q=pname:org.torproject.android");
+ Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+ activity.startActivity(intent);
+ }
+ });
+ downloadDialog.setNegativeButton(stringButtonNo, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialogInterface, int i) {
+ }
+ });
+ return downloadDialog.show();
+ }
+
+
+
+}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/providers/ClientAuthContentProviderGenesis.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/ClientAuthContentProviderGenesis.java
similarity index 94%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/providers/ClientAuthContentProviderGenesis.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/ClientAuthContentProviderGenesis.java
index 46d4db5d..5521e390 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/providers/ClientAuthContentProviderGenesis.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/ClientAuthContentProviderGenesis.java
@@ -1,104 +1,104 @@
-package com.darkweb.genesissearchengine.libs.providers;
-
-import android.content.ContentProvider;
-import android.content.ContentUris;
-import android.content.ContentValues;
-import android.content.UriMatcher;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.net.Uri;
-import android.provider.BaseColumns;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-public class ClientAuthContentProviderGenesis extends ContentProvider {
- public static final String[] PROJECTION = {
- V3ClientAuth._ID,
- V3ClientAuth.DOMAIN,
- V3ClientAuth.HASH,
- V3ClientAuth.ENABLED,
- };
- private static final String AUTH = "org.torproject.android.ui.v3onionservice.genesis.clientauth";
- public static final Uri CONTENT_URI = Uri.parse("content://" + AUTH + "/v3auth");
- private static final int V3AUTHS = 1, V3AUTH_ID = 2;
-
- private static final UriMatcher uriMatcher;
-
- static {
- uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
- uriMatcher.addURI(AUTH, "v3auth", V3AUTHS);
- uriMatcher.addURI(AUTH, "v3auth/#", V3AUTH_ID);
- }
-
- private ClientAuthDatabase mDatabase;
-
- @Override
- public boolean onCreate() {
- mDatabase = new ClientAuthDatabase(getContext());
- return true;
- }
-
- @Nullable
- @Override
- public String getType(@NonNull Uri uri) {
- int match = uriMatcher.match(uri);
- switch (match) {
- case V3AUTHS:
- return "vnd.android.cursor.dir/vnd.torproject.v3auths";
- case V3AUTH_ID:
- return "vnd.android.cursor.item/vnd.torproject.v3auth";
- default:
- return null;
- }
- }
-
- @Nullable
- @Override
- public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
- if (uriMatcher.match(uri) == V3AUTH_ID)
- selection = "_id=" + uri.getLastPathSegment();
- SQLiteDatabase db = mDatabase.getReadableDatabase();
- return db.query(ClientAuthDatabase.DATABASE_NAME, projection, selection, selectionArgs, null, null, sortOrder);
- }
-
- @Nullable
- @Override
- public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
- SQLiteDatabase db = mDatabase.getWritableDatabase();
- long regId = db.insert(ClientAuthDatabase.DATABASE_NAME, null, values);
- getContext().getContentResolver().notifyChange(CONTENT_URI, null);
- return ContentUris.withAppendedId(CONTENT_URI, regId);
- }
-
- @Override
- public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
- if (uriMatcher.match(uri) == V3AUTH_ID)
- selection = "_id=" + uri.getLastPathSegment();
- SQLiteDatabase db = mDatabase.getWritableDatabase();
- int rows = db.delete(ClientAuthDatabase.DATABASE_NAME, selection, selectionArgs);
- getContext().getContentResolver().notifyChange(CONTENT_URI, null);
- return rows;
- }
-
- @Override
- public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
- SQLiteDatabase db = mDatabase.getWritableDatabase();
- if (uriMatcher.match(uri) == V3AUTH_ID)
- selection = "id_=" + uri.getLastPathSegment();
- int rows = db.update(ClientAuthDatabase.DATABASE_NAME, values, selection, null);
- getContext().getContentResolver().notifyChange(CONTENT_URI, null);
- return rows;
- }
-
- public static final class V3ClientAuth implements BaseColumns {
- private V3ClientAuth() {
- } // no-op
-
- public static final String
- DOMAIN = "domain",
- HASH = "hash",
- ENABLED = "enabled";
- }
-
+package com.hiddenservices.genesissearchengine.production.libs.providers;
+
+import android.content.ContentProvider;
+import android.content.ContentUris;
+import android.content.ContentValues;
+import android.content.UriMatcher;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.net.Uri;
+import android.provider.BaseColumns;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+public class ClientAuthContentProviderGenesis extends ContentProvider {
+ public static final String[] PROJECTION = {
+ V3ClientAuth._ID,
+ V3ClientAuth.DOMAIN,
+ V3ClientAuth.HASH,
+ V3ClientAuth.ENABLED,
+ };
+ private static final String AUTH = "org.torproject.android.ui.v3onionservice.genesishiddenservices.clientauth";
+ public static final Uri CONTENT_URI = Uri.parse("content://" + AUTH + "/v3auth");
+ private static final int V3AUTHS = 1, V3AUTH_ID = 2;
+
+ private static final UriMatcher uriMatcher;
+
+ static {
+ uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
+ uriMatcher.addURI(AUTH, "v3auth", V3AUTHS);
+ uriMatcher.addURI(AUTH, "v3auth/#", V3AUTH_ID);
+ }
+
+ private ClientAuthDatabase mDatabase;
+
+ @Override
+ public boolean onCreate() {
+ mDatabase = new ClientAuthDatabase(getContext());
+ return true;
+ }
+
+ @Nullable
+ @Override
+ public String getType(@NonNull Uri uri) {
+ int match = uriMatcher.match(uri);
+ switch (match) {
+ case V3AUTHS:
+ return "vnd.android.cursor.dir/vnd.torproject.v3auths";
+ case V3AUTH_ID:
+ return "vnd.android.cursor.item/vnd.torproject.v3auth";
+ default:
+ return null;
+ }
+ }
+
+ @Nullable
+ @Override
+ public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
+ if (uriMatcher.match(uri) == V3AUTH_ID)
+ selection = "_id=" + uri.getLastPathSegment();
+ SQLiteDatabase db = mDatabase.getReadableDatabase();
+ return db.query(ClientAuthDatabase.DATABASE_NAME, projection, selection, selectionArgs, null, null, sortOrder);
+ }
+
+ @Nullable
+ @Override
+ public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
+ SQLiteDatabase db = mDatabase.getWritableDatabase();
+ long regId = db.insert(ClientAuthDatabase.DATABASE_NAME, null, values);
+ getContext().getContentResolver().notifyChange(CONTENT_URI, null);
+ return ContentUris.withAppendedId(CONTENT_URI, regId);
+ }
+
+ @Override
+ public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
+ if (uriMatcher.match(uri) == V3AUTH_ID)
+ selection = "_id=" + uri.getLastPathSegment();
+ SQLiteDatabase db = mDatabase.getWritableDatabase();
+ int rows = db.delete(ClientAuthDatabase.DATABASE_NAME, selection, selectionArgs);
+ getContext().getContentResolver().notifyChange(CONTENT_URI, null);
+ return rows;
+ }
+
+ @Override
+ public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
+ SQLiteDatabase db = mDatabase.getWritableDatabase();
+ if (uriMatcher.match(uri) == V3AUTH_ID)
+ selection = "id_=" + uri.getLastPathSegment();
+ int rows = db.update(ClientAuthDatabase.DATABASE_NAME, values, selection, null);
+ getContext().getContentResolver().notifyChange(CONTENT_URI, null);
+ return rows;
+ }
+
+ public static final class V3ClientAuth implements BaseColumns {
+ private V3ClientAuth() {
+ } // no-op
+
+ public static final String
+ DOMAIN = "domain",
+ HASH = "hash",
+ ENABLED = "enabled";
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/providers/ClientAuthDatabase.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/ClientAuthDatabase.java
similarity index 89%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/providers/ClientAuthDatabase.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/ClientAuthDatabase.java
index eea4273b..c27763cc 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/providers/ClientAuthDatabase.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/ClientAuthDatabase.java
@@ -1,30 +1,30 @@
-package com.darkweb.genesissearchengine.libs.providers;
-
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-
-public class ClientAuthDatabase extends SQLiteOpenHelper {
- static final String DATABASE_NAME = "v3_client_auths";
- private static final int DATABASE_VERSION = 1;
-
- private static final String V3_AUTHS_CREATE_SQL =
- "CREATE TABLE " + DATABASE_NAME + " (" +
- "_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
- "domain TEXT, " +
- "hash TEXT, " +
- "enabled INTEGER DEFAULT 1);";
-
- ClientAuthDatabase(Context context) {
- super(context, DATABASE_NAME, null, DATABASE_VERSION);
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- db.execSQL(V3_AUTHS_CREATE_SQL);
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- }
-}
+package com.hiddenservices.genesissearchengine.production.libs.providers;
+
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+
+public class ClientAuthDatabase extends SQLiteOpenHelper {
+ static final String DATABASE_NAME = "v3_client_auths";
+ private static final int DATABASE_VERSION = 1;
+
+ private static final String V3_AUTHS_CREATE_SQL =
+ "CREATE TABLE " + DATABASE_NAME + " (" +
+ "_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
+ "domain TEXT, " +
+ "hash TEXT, " +
+ "enabled INTEGER DEFAULT 1);";
+
+ ClientAuthDatabase(Context context) {
+ super(context, DATABASE_NAME, null, DATABASE_VERSION);
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+ db.execSQL(V3_AUTHS_CREATE_SQL);
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ }
+}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/providers/CookieContentProvider.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/CookieContentProvider.java
similarity index 93%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/providers/CookieContentProvider.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/CookieContentProvider.java
index 1ecfb482..1578b656 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/providers/CookieContentProvider.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/CookieContentProvider.java
@@ -1,133 +1,132 @@
-package com.darkweb.genesissearchengine.libs.providers;
-
-import android.content.ContentProvider;
-import android.content.ContentUris;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.UriMatcher;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.net.Uri;
-import android.provider.BaseColumns;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import com.darkweb.genesissearchengine.libs.providers.HSDatabase;
-
-
-public class CookieContentProvider extends ContentProvider {
- public static final String[] PROJECTION = new String[]{
- ClientCookie._ID,
- ClientCookie.DOMAIN,
- ClientCookie.AUTH_COOKIE_VALUE,
- ClientCookie.ENABLED
- };
- private static final String AUTH = "org.torproject.android.ui.hiddenservices.providers.genesis.cookie";
- public static final Uri CONTENT_URI =
- Uri.parse("content://" + AUTH + "/cookie");
- //UriMatcher
- private static final int COOKIES = 1;
- private static final int COOKIE_ID = 2;
-
- private static final UriMatcher uriMatcher;
-
- static {
- uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
- uriMatcher.addURI(AUTH, "hs", COOKIES);
- uriMatcher.addURI(AUTH, "hs/#", COOKIE_ID);
- }
-
- private HSDatabase mServervices;
- private Context mContext;
-
- @Override
- public boolean onCreate() {
- mContext = getContext();
- mServervices = new HSDatabase(mContext);
- return true;
- }
-
- @Nullable
- @Override
- public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
- String where = selection;
- if (uriMatcher.match(uri) == COOKIE_ID) {
- where = "_id=" + uri.getLastPathSegment();
- }
-
- SQLiteDatabase db = mServervices.getReadableDatabase();
-
- return db.query(HSDatabase.HS_CLIENT_COOKIE_TABLE_NAME, projection, where,
- selectionArgs, null, null, sortOrder);
- }
-
- @Nullable
- @Override
- public String getType(@NonNull Uri uri) {
- int match = uriMatcher.match(uri);
-
- switch (match) {
- case COOKIES:
- return "vnd.android.cursor.dir/vnd.torproject.cookies";
- case COOKIE_ID:
- return "vnd.android.cursor.item/vnd.torproject.cookie";
- default:
- return null;
- }
- }
-
- @Nullable
- @Override
- public Uri insert(@NonNull Uri uri, ContentValues values) {
- long regId;
-
- SQLiteDatabase db = mServervices.getWritableDatabase();
-
- regId = db.insert(HSDatabase.HS_CLIENT_COOKIE_TABLE_NAME, null, values);
-
- mContext.getContentResolver().notifyChange(CONTENT_URI, null);
-
- return ContentUris.withAppendedId(CONTENT_URI, regId);
- }
-
- @Override
- public int delete(@NonNull Uri uri, String selection, String[] selectionArgs) {
-
- String where = selection;
- if (uriMatcher.match(uri) == COOKIE_ID) {
- where = "_id=" + uri.getLastPathSegment();
- }
-
- SQLiteDatabase db = mServervices.getWritableDatabase();
-
- int rows = db.delete(HSDatabase.HS_CLIENT_COOKIE_TABLE_NAME, where, selectionArgs);
-
- mContext.getContentResolver().notifyChange(CONTENT_URI, null);
-
- return rows;
-
- }
-
- @Override
- public int update(@NonNull Uri uri, ContentValues values, String selection, String[] selectionArgs) {
- SQLiteDatabase db = mServervices.getWritableDatabase();
-
- String where = selection;
- if (uriMatcher.match(uri) == COOKIE_ID) {
- where = "_id=" + uri.getLastPathSegment();
- }
-
- int rows = db.update(HSDatabase.HS_CLIENT_COOKIE_TABLE_NAME, values, where, null);
- mContext.getContentResolver().notifyChange(CONTENT_URI, null);
-
- return rows;
- }
-
- public static final class ClientCookie implements BaseColumns {
- public static final String DOMAIN = "domain";
- public static final String AUTH_COOKIE_VALUE = "auth_cookie_value";
- public static final String ENABLED = "enabled";
-
- private ClientCookie() {
- }
- }
+package com.hiddenservices.genesissearchengine.production.libs.providers;
+
+import android.content.ContentProvider;
+import android.content.ContentUris;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.UriMatcher;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.net.Uri;
+import android.provider.BaseColumns;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+
+public class CookieContentProvider extends ContentProvider {
+ public static final String[] PROJECTION = new String[]{
+ ClientCookie._ID,
+ ClientCookie.DOMAIN,
+ ClientCookie.AUTH_COOKIE_VALUE,
+ ClientCookie.ENABLED
+ };
+ private static final String AUTH = "org.torproject.android.ui.hiddenservices.providers.genesishiddenservices.cookie";
+ public static final Uri CONTENT_URI =
+ Uri.parse("content://" + AUTH + "/cookie");
+ //UriMatcher
+ private static final int COOKIES = 1;
+ private static final int COOKIE_ID = 2;
+
+ private static final UriMatcher uriMatcher;
+
+ static {
+ uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
+ uriMatcher.addURI(AUTH, "hs", COOKIES);
+ uriMatcher.addURI(AUTH, "hs/#", COOKIE_ID);
+ }
+
+ private HSDatabase mServervices;
+ private Context mContext;
+
+ @Override
+ public boolean onCreate() {
+ mContext = getContext();
+ mServervices = new HSDatabase(mContext);
+ return true;
+ }
+
+ @Nullable
+ @Override
+ public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+ String where = selection;
+ if (uriMatcher.match(uri) == COOKIE_ID) {
+ where = "_id=" + uri.getLastPathSegment();
+ }
+
+ SQLiteDatabase db = mServervices.getReadableDatabase();
+
+ return db.query(HSDatabase.HS_CLIENT_COOKIE_TABLE_NAME, projection, where,
+ selectionArgs, null, null, sortOrder);
+ }
+
+ @Nullable
+ @Override
+ public String getType(@NonNull Uri uri) {
+ int match = uriMatcher.match(uri);
+
+ switch (match) {
+ case COOKIES:
+ return "vnd.android.cursor.dir/vnd.torproject.cookies";
+ case COOKIE_ID:
+ return "vnd.android.cursor.item/vnd.torproject.cookie";
+ default:
+ return null;
+ }
+ }
+
+ @Nullable
+ @Override
+ public Uri insert(@NonNull Uri uri, ContentValues values) {
+ long regId;
+
+ SQLiteDatabase db = mServervices.getWritableDatabase();
+
+ regId = db.insert(HSDatabase.HS_CLIENT_COOKIE_TABLE_NAME, null, values);
+
+ mContext.getContentResolver().notifyChange(CONTENT_URI, null);
+
+ return ContentUris.withAppendedId(CONTENT_URI, regId);
+ }
+
+ @Override
+ public int delete(@NonNull Uri uri, String selection, String[] selectionArgs) {
+
+ String where = selection;
+ if (uriMatcher.match(uri) == COOKIE_ID) {
+ where = "_id=" + uri.getLastPathSegment();
+ }
+
+ SQLiteDatabase db = mServervices.getWritableDatabase();
+
+ int rows = db.delete(HSDatabase.HS_CLIENT_COOKIE_TABLE_NAME, where, selectionArgs);
+
+ mContext.getContentResolver().notifyChange(CONTENT_URI, null);
+
+ return rows;
+
+ }
+
+ @Override
+ public int update(@NonNull Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ SQLiteDatabase db = mServervices.getWritableDatabase();
+
+ String where = selection;
+ if (uriMatcher.match(uri) == COOKIE_ID) {
+ where = "_id=" + uri.getLastPathSegment();
+ }
+
+ int rows = db.update(HSDatabase.HS_CLIENT_COOKIE_TABLE_NAME, values, where, null);
+ mContext.getContentResolver().notifyChange(CONTENT_URI, null);
+
+ return rows;
+ }
+
+ public static final class ClientCookie implements BaseColumns {
+ public static final String DOMAIN = "domain";
+ public static final String AUTH_COOKIE_VALUE = "auth_cookie_value";
+ public static final String ENABLED = "enabled";
+
+ private ClientCookie() {
+ }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/providers/HSContentProvider.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/HSContentProvider.java
similarity index 94%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/providers/HSContentProvider.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/HSContentProvider.java
index 124dc05a..76a82af8 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/providers/HSContentProvider.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/HSContentProvider.java
@@ -1,141 +1,140 @@
-package com.darkweb.genesissearchengine.libs.providers;
-
-import android.content.ContentProvider;
-import android.content.ContentUris;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.UriMatcher;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.net.Uri;
-import android.provider.BaseColumns;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import com.darkweb.genesissearchengine.libs.providers.HSDatabase;
-
-
-public class HSContentProvider extends ContentProvider {
- public static final String[] PROJECTION = new String[]{
- HiddenService._ID,
- HiddenService.NAME,
- HiddenService.PORT,
- HiddenService.DOMAIN,
- HiddenService.ONION_PORT,
- HiddenService.AUTH_COOKIE,
- HiddenService.AUTH_COOKIE_VALUE,
- HiddenService.CREATED_BY_USER,
- HiddenService.ENABLED
- };
- private static final String AUTH = "org.torproject.android.ui.hiddenservices.providers.genesis";
- public static final Uri CONTENT_URI = Uri.parse("content://" + AUTH + "/hs");
- //UriMatcher
- private static final int ONIONS = 1;
- private static final int ONION_ID = 2;
-
- private static final UriMatcher uriMatcher;
-
- static {
- uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
- uriMatcher.addURI(AUTH, "hs", ONIONS);
- uriMatcher.addURI(AUTH, "hs/#", ONION_ID);
- }
-
- private HSDatabase mServervices;
- private Context mContext;
-
- @Override
- public boolean onCreate() {
- mContext = getContext();
- mServervices = new HSDatabase(mContext);
- return true;
- }
-
- @Nullable
- @Override
- public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
- String where = selection;
- if (uriMatcher.match(uri) == ONION_ID) {
- where = "_id=" + uri.getLastPathSegment();
- }
-
- SQLiteDatabase db = mServervices.getReadableDatabase();
-
- return db.query(HSDatabase.HS_DATA_TABLE_NAME, projection, where, selectionArgs, null, null, sortOrder);
- }
-
- @Nullable
- @Override
- public String getType(@NonNull Uri uri) {
- int match = uriMatcher.match(uri);
-
- switch (match) {
- case ONIONS:
- return "vnd.android.cursor.dir/vnd.torproject.onions";
- case ONION_ID:
- return "vnd.android.cursor.item/vnd.torproject.onion";
- default:
- return null;
- }
- }
-
- @Nullable
- @Override
- public Uri insert(@NonNull Uri uri, ContentValues values) {
- long regId;
-
- SQLiteDatabase db = mServervices.getWritableDatabase();
-
- regId = db.insert(HSDatabase.HS_DATA_TABLE_NAME, null, values);
-
- mContext.getContentResolver().notifyChange(CONTENT_URI, null);
-
- return ContentUris.withAppendedId(CONTENT_URI, regId);
- }
-
- @Override
- public int delete(@NonNull Uri uri, String selection, String[] selectionArgs) {
-
- String where = selection;
- if (uriMatcher.match(uri) == ONION_ID) {
- where = "_id=" + uri.getLastPathSegment();
- }
-
- SQLiteDatabase db = mServervices.getWritableDatabase();
-
- int rows = db.delete(HSDatabase.HS_DATA_TABLE_NAME, where, selectionArgs);
-
- mContext.getContentResolver().notifyChange(CONTENT_URI, null);
-
- return rows;
-
- }
-
- @Override
- public int update(@NonNull Uri uri, ContentValues values, String selection, String[] selectionArgs) {
- SQLiteDatabase db = mServervices.getWritableDatabase();
-
- String where = selection;
- if (uriMatcher.match(uri) == ONION_ID) {
- where = "_id=" + uri.getLastPathSegment();
- }
-
- int rows = db.update(HSDatabase.HS_DATA_TABLE_NAME, values, where, null);
- mContext.getContentResolver().notifyChange(CONTENT_URI, null);
-
- return rows;
- }
-
- public static final class HiddenService implements BaseColumns {
- public static final String NAME = "name";
- public static final String PORT = "port";
- public static final String ONION_PORT = "onion_port";
- public static final String DOMAIN = "domain";
- public static final String AUTH_COOKIE = "auth_cookie";
- public static final String AUTH_COOKIE_VALUE = "auth_cookie_value";
- public static final String CREATED_BY_USER = "created_by_user";
- public static final String ENABLED = "enabled";
-
- private HiddenService() {
- }
- }
+package com.hiddenservices.genesissearchengine.production.libs.providers;
+
+import android.content.ContentProvider;
+import android.content.ContentUris;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.UriMatcher;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.net.Uri;
+import android.provider.BaseColumns;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+
+public class HSContentProvider extends ContentProvider {
+ public static final String[] PROJECTION = new String[]{
+ HiddenService._ID,
+ HiddenService.NAME,
+ HiddenService.PORT,
+ HiddenService.DOMAIN,
+ HiddenService.ONION_PORT,
+ HiddenService.AUTH_COOKIE,
+ HiddenService.AUTH_COOKIE_VALUE,
+ HiddenService.CREATED_BY_USER,
+ HiddenService.ENABLED
+ };
+ private static final String AUTH = "org.torproject.android.ui.hiddenservices.providers.genesishiddenservices";
+ public static final Uri CONTENT_URI = Uri.parse("content://" + AUTH + "/hs");
+ //UriMatcher
+ private static final int ONIONS = 1;
+ private static final int ONION_ID = 2;
+
+ private static final UriMatcher uriMatcher;
+
+ static {
+ uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
+ uriMatcher.addURI(AUTH, "hs", ONIONS);
+ uriMatcher.addURI(AUTH, "hs/#", ONION_ID);
+ }
+
+ private HSDatabase mServervices;
+ private Context mContext;
+
+ @Override
+ public boolean onCreate() {
+ mContext = getContext();
+ mServervices = new HSDatabase(mContext);
+ return true;
+ }
+
+ @Nullable
+ @Override
+ public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
+ String where = selection;
+ if (uriMatcher.match(uri) == ONION_ID) {
+ where = "_id=" + uri.getLastPathSegment();
+ }
+
+ SQLiteDatabase db = mServervices.getReadableDatabase();
+
+ return db.query(HSDatabase.HS_DATA_TABLE_NAME, projection, where, selectionArgs, null, null, sortOrder);
+ }
+
+ @Nullable
+ @Override
+ public String getType(@NonNull Uri uri) {
+ int match = uriMatcher.match(uri);
+
+ switch (match) {
+ case ONIONS:
+ return "vnd.android.cursor.dir/vnd.torproject.onions";
+ case ONION_ID:
+ return "vnd.android.cursor.item/vnd.torproject.onion";
+ default:
+ return null;
+ }
+ }
+
+ @Nullable
+ @Override
+ public Uri insert(@NonNull Uri uri, ContentValues values) {
+ long regId;
+
+ SQLiteDatabase db = mServervices.getWritableDatabase();
+
+ regId = db.insert(HSDatabase.HS_DATA_TABLE_NAME, null, values);
+
+ mContext.getContentResolver().notifyChange(CONTENT_URI, null);
+
+ return ContentUris.withAppendedId(CONTENT_URI, regId);
+ }
+
+ @Override
+ public int delete(@NonNull Uri uri, String selection, String[] selectionArgs) {
+
+ String where = selection;
+ if (uriMatcher.match(uri) == ONION_ID) {
+ where = "_id=" + uri.getLastPathSegment();
+ }
+
+ SQLiteDatabase db = mServervices.getWritableDatabase();
+
+ int rows = db.delete(HSDatabase.HS_DATA_TABLE_NAME, where, selectionArgs);
+
+ mContext.getContentResolver().notifyChange(CONTENT_URI, null);
+
+ return rows;
+
+ }
+
+ @Override
+ public int update(@NonNull Uri uri, ContentValues values, String selection, String[] selectionArgs) {
+ SQLiteDatabase db = mServervices.getWritableDatabase();
+
+ String where = selection;
+ if (uriMatcher.match(uri) == ONION_ID) {
+ where = "_id=" + uri.getLastPathSegment();
+ }
+
+ int rows = db.update(HSDatabase.HS_DATA_TABLE_NAME, values, where, null);
+ mContext.getContentResolver().notifyChange(CONTENT_URI, null);
+
+ return rows;
+ }
+
+ public static final class HiddenService implements BaseColumns {
+ public static final String NAME = "name";
+ public static final String PORT = "port";
+ public static final String ONION_PORT = "onion_port";
+ public static final String DOMAIN = "domain";
+ public static final String AUTH_COOKIE = "auth_cookie";
+ public static final String AUTH_COOKIE_VALUE = "auth_cookie_value";
+ public static final String CREATED_BY_USER = "created_by_user";
+ public static final String ENABLED = "enabled";
+
+ private HiddenService() {
+ }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/providers/HSDatabase.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/HSDatabase.java
similarity index 93%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/providers/HSDatabase.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/HSDatabase.java
index c08171bf..7cf776a7 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/providers/HSDatabase.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/HSDatabase.java
@@ -1,49 +1,49 @@
-package com.darkweb.genesissearchengine.libs.providers;
-
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-
-public class HSDatabase extends SQLiteOpenHelper {
-
- public static final String HS_DATA_TABLE_NAME = "hs_data";
- public static final String HS_CLIENT_COOKIE_TABLE_NAME = "hs_client_cookie";
- private static final int DATABASE_VERSION = 4;
- private static final String DATABASE_NAME = "hidden_services";
- private static final String HS_DATA_TABLE_CREATE =
- "CREATE TABLE " + HS_DATA_TABLE_NAME + " (" +
- "_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
- "name TEXT, " +
- "domain TEXT, " +
- "onion_port INTEGER, " +
- "auth_cookie INTEGER DEFAULT 0, " +
- "auth_cookie_value TEXT, " +
- "created_by_user INTEGER DEFAULT 0, " +
- "enabled INTEGER DEFAULT 1, " +
- "port INTEGER, " +
- "filepath TEXT);";
-
- private static final String HS_CLIENT_COOKIE_TABLE_CREATE =
- "CREATE TABLE " + HS_CLIENT_COOKIE_TABLE_NAME + " (" +
- "_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
- "domain TEXT, " +
- "auth_cookie_value TEXT, " +
- "enabled INTEGER DEFAULT 1);";
-
- public HSDatabase(Context context) {
- super(context, DATABASE_NAME, null, DATABASE_VERSION);
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- db.execSQL(HS_DATA_TABLE_CREATE);
- db.execSQL(HS_CLIENT_COOKIE_TABLE_CREATE);
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- if (newVersion > oldVersion) {
- db.execSQL("ALTER TABLE " + HS_DATA_TABLE_NAME + " ADD COLUMN filepath TEXT");
- }
- }
+package com.hiddenservices.genesissearchengine.production.libs.providers;
+
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+
+public class HSDatabase extends SQLiteOpenHelper {
+
+ public static final String HS_DATA_TABLE_NAME = "hs_data";
+ public static final String HS_CLIENT_COOKIE_TABLE_NAME = "hs_client_cookie";
+ private static final int DATABASE_VERSION = 4;
+ private static final String DATABASE_NAME = "hidden_services";
+ private static final String HS_DATA_TABLE_CREATE =
+ "CREATE TABLE " + HS_DATA_TABLE_NAME + " (" +
+ "_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
+ "name TEXT, " +
+ "domain TEXT, " +
+ "onion_port INTEGER, " +
+ "auth_cookie INTEGER DEFAULT 0, " +
+ "auth_cookie_value TEXT, " +
+ "created_by_user INTEGER DEFAULT 0, " +
+ "enabled INTEGER DEFAULT 1, " +
+ "port INTEGER, " +
+ "filepath TEXT);";
+
+ private static final String HS_CLIENT_COOKIE_TABLE_CREATE =
+ "CREATE TABLE " + HS_CLIENT_COOKIE_TABLE_NAME + " (" +
+ "_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
+ "domain TEXT, " +
+ "auth_cookie_value TEXT, " +
+ "enabled INTEGER DEFAULT 1);";
+
+ public HSDatabase(Context context) {
+ super(context, DATABASE_NAME, null, DATABASE_VERSION);
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+ db.execSQL(HS_DATA_TABLE_CREATE);
+ db.execSQL(HS_CLIENT_COOKIE_TABLE_CREATE);
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ if (newVersion > oldVersion) {
+ db.execSQL("ALTER TABLE " + HS_DATA_TABLE_NAME + " ADD COLUMN filepath TEXT");
+ }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/providers/OnionServiceContentProvider.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/OnionServiceContentProvider.java
similarity index 94%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/providers/OnionServiceContentProvider.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/OnionServiceContentProvider.java
index 223bba59..fc1344c8 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/providers/OnionServiceContentProvider.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/OnionServiceContentProvider.java
@@ -1,110 +1,110 @@
-package com.darkweb.genesissearchengine.libs.providers;
-
-import android.content.ContentProvider;
-import android.content.ContentUris;
-import android.content.ContentValues;
-import android.content.UriMatcher;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.net.Uri;
-import android.provider.BaseColumns;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-public class OnionServiceContentProvider extends ContentProvider {
-
- public static final String[] PROJECTION = {
- OnionService._ID,
- OnionService.NAME,
- OnionService.PORT,
- OnionService.DOMAIN,
- OnionService.ONION_PORT,
- OnionService.CREATED_BY_USER,
- OnionService.ENABLED
- };
-
- private static final int ONIONS = 1, ONION_ID = 2;
- private static final String AUTH = "org.torproject.android.ui.v3onionservice.genesis";
- public static final Uri CONTENT_URI = Uri.parse("content://" + AUTH + "/v3");
- private static final UriMatcher uriMatcher;
-
- static {
- uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
- uriMatcher.addURI(AUTH, "v3", ONIONS);
- uriMatcher.addURI(AUTH, "v3/#", ONION_ID);
- }
-
- private OnionServiceDatabase mDatabase;
-
- @Override
- public boolean onCreate() {
- mDatabase = new OnionServiceDatabase(getContext());
- return true;
- }
-
- @Nullable
- @Override
- public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
- if (uriMatcher.match(uri) == ONION_ID)
- selection = "_id=" + uri.getLastPathSegment();
- SQLiteDatabase db = mDatabase.getReadableDatabase();
- return db.query(OnionServiceDatabase.ONION_SERVICE_TABLE_NAME, projection, selection, selectionArgs, null, null, sortOrder);
- }
-
- @Nullable
- @Override
- public String getType(@NonNull Uri uri) {
- int match = uriMatcher.match(uri);
- switch (match) {
- case ONIONS:
- return "vnd.android.cursor.dir/vnd.torproject.onions";
- case ONION_ID:
- return "vnd.android.cursor.item/vnd.torproject.onion";
- default:
- return null;
- }
- }
-
- @Nullable
- @Override
- public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
- SQLiteDatabase db = mDatabase.getWritableDatabase();
- long regId = db.insert(OnionServiceDatabase.ONION_SERVICE_TABLE_NAME, null, values);
- getContext().getContentResolver().notifyChange(CONTENT_URI, null);
- return ContentUris.withAppendedId(CONTENT_URI, regId);
- }
-
- @Override
- public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
- if (uriMatcher.match(uri) == ONION_ID)
- selection = "_id=" + uri.getLastPathSegment();
- SQLiteDatabase db = mDatabase.getWritableDatabase();
- int rows = db.delete(OnionServiceDatabase.ONION_SERVICE_TABLE_NAME, selection, selectionArgs);
- getContext().getContentResolver().notifyChange(CONTENT_URI, null);
- return rows;
- }
-
- @Override
- public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
- SQLiteDatabase db = mDatabase.getWritableDatabase();
- if (uriMatcher.match(uri) == ONION_ID)
- selection = "_id=" + uri.getLastPathSegment();
- int rows = db.update(OnionServiceDatabase.ONION_SERVICE_TABLE_NAME, values, selection, null);
- getContext().getContentResolver().notifyChange(CONTENT_URI, null);
- return rows;
- }
-
- public static final class OnionService implements BaseColumns {
- public static final String NAME = "name";
- public static final String PORT = "port";
- public static final String ONION_PORT = "onion_port";
- public static final String DOMAIN = "domain";
- public static final String CREATED_BY_USER = "created_by_user";
- public static final String ENABLED = "enabled";
-
- private OnionService() { // no-op
- }
- }
-
+package com.hiddenservices.genesissearchengine.production.libs.providers;
+
+import android.content.ContentProvider;
+import android.content.ContentUris;
+import android.content.ContentValues;
+import android.content.UriMatcher;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.net.Uri;
+import android.provider.BaseColumns;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+public class OnionServiceContentProvider extends ContentProvider {
+
+ public static final String[] PROJECTION = {
+ OnionService._ID,
+ OnionService.NAME,
+ OnionService.PORT,
+ OnionService.DOMAIN,
+ OnionService.ONION_PORT,
+ OnionService.CREATED_BY_USER,
+ OnionService.ENABLED
+ };
+
+ private static final int ONIONS = 1, ONION_ID = 2;
+ private static final String AUTH = "org.torproject.android.ui.v3onionservice.genesishiddenservices";
+ public static final Uri CONTENT_URI = Uri.parse("content://" + AUTH + "/v3");
+ private static final UriMatcher uriMatcher;
+
+ static {
+ uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
+ uriMatcher.addURI(AUTH, "v3", ONIONS);
+ uriMatcher.addURI(AUTH, "v3/#", ONION_ID);
+ }
+
+ private OnionServiceDatabase mDatabase;
+
+ @Override
+ public boolean onCreate() {
+ mDatabase = new OnionServiceDatabase(getContext());
+ return true;
+ }
+
+ @Nullable
+ @Override
+ public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder) {
+ if (uriMatcher.match(uri) == ONION_ID)
+ selection = "_id=" + uri.getLastPathSegment();
+ SQLiteDatabase db = mDatabase.getReadableDatabase();
+ return db.query(OnionServiceDatabase.ONION_SERVICE_TABLE_NAME, projection, selection, selectionArgs, null, null, sortOrder);
+ }
+
+ @Nullable
+ @Override
+ public String getType(@NonNull Uri uri) {
+ int match = uriMatcher.match(uri);
+ switch (match) {
+ case ONIONS:
+ return "vnd.android.cursor.dir/vnd.torproject.onions";
+ case ONION_ID:
+ return "vnd.android.cursor.item/vnd.torproject.onion";
+ default:
+ return null;
+ }
+ }
+
+ @Nullable
+ @Override
+ public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
+ SQLiteDatabase db = mDatabase.getWritableDatabase();
+ long regId = db.insert(OnionServiceDatabase.ONION_SERVICE_TABLE_NAME, null, values);
+ getContext().getContentResolver().notifyChange(CONTENT_URI, null);
+ return ContentUris.withAppendedId(CONTENT_URI, regId);
+ }
+
+ @Override
+ public int delete(@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
+ if (uriMatcher.match(uri) == ONION_ID)
+ selection = "_id=" + uri.getLastPathSegment();
+ SQLiteDatabase db = mDatabase.getWritableDatabase();
+ int rows = db.delete(OnionServiceDatabase.ONION_SERVICE_TABLE_NAME, selection, selectionArgs);
+ getContext().getContentResolver().notifyChange(CONTENT_URI, null);
+ return rows;
+ }
+
+ @Override
+ public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) {
+ SQLiteDatabase db = mDatabase.getWritableDatabase();
+ if (uriMatcher.match(uri) == ONION_ID)
+ selection = "_id=" + uri.getLastPathSegment();
+ int rows = db.update(OnionServiceDatabase.ONION_SERVICE_TABLE_NAME, values, selection, null);
+ getContext().getContentResolver().notifyChange(CONTENT_URI, null);
+ return rows;
+ }
+
+ public static final class OnionService implements BaseColumns {
+ public static final String NAME = "name";
+ public static final String PORT = "port";
+ public static final String ONION_PORT = "onion_port";
+ public static final String DOMAIN = "domain";
+ public static final String CREATED_BY_USER = "created_by_user";
+ public static final String ENABLED = "enabled";
+
+ private OnionService() { // no-op
+ }
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/providers/OnionServiceDatabase.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/OnionServiceDatabase.java
similarity index 92%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/providers/OnionServiceDatabase.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/OnionServiceDatabase.java
index 3a037b6d..47b0e998 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/providers/OnionServiceDatabase.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/providers/OnionServiceDatabase.java
@@ -1,41 +1,41 @@
-package com.darkweb.genesissearchengine.libs.providers;
-
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-
-public class OnionServiceDatabase extends SQLiteOpenHelper {
-
- static final String DATABASE_NAME = "onion_service",
- ONION_SERVICE_TABLE_NAME = "onion_services";
- private static final int DATABASE_VERSION = 2;
-
- private static final String ONION_SERVICES_CREATE_SQL =
- "CREATE TABLE " + ONION_SERVICE_TABLE_NAME + " (" +
- "_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
- "name TEXT, " +
- "domain TEXT, " +
- "onion_port INTEGER, " +
- "created_by_user INTEGER DEFAULT 0, " +
- "enabled INTEGER DEFAULT 1, " +
- "port INTEGER, " +
- "filepath TEXT);";
-
- OnionServiceDatabase(Context context) {
- super(context, DATABASE_NAME, null, DATABASE_VERSION);
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- db.execSQL(ONION_SERVICES_CREATE_SQL);
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- if (newVersion > oldVersion) {
- db.execSQL("ALTER TABLE " + ONION_SERVICE_TABLE_NAME + " ADD COLUMN filepath text");
- }
- }
-
-
-}
+package com.hiddenservices.genesissearchengine.production.libs.providers;
+
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+
+public class OnionServiceDatabase extends SQLiteOpenHelper {
+
+ static final String DATABASE_NAME = "onion_service",
+ ONION_SERVICE_TABLE_NAME = "onion_services";
+ private static final int DATABASE_VERSION = 2;
+
+ private static final String ONION_SERVICES_CREATE_SQL =
+ "CREATE TABLE " + ONION_SERVICE_TABLE_NAME + " (" +
+ "_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
+ "name TEXT, " +
+ "domain TEXT, " +
+ "onion_port INTEGER, " +
+ "created_by_user INTEGER DEFAULT 0, " +
+ "enabled INTEGER DEFAULT 1, " +
+ "port INTEGER, " +
+ "filepath TEXT);";
+
+ OnionServiceDatabase(Context context) {
+ super(context, DATABASE_NAME, null, DATABASE_VERSION);
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+ db.execSQL(ONION_SERVICES_CREATE_SQL);
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ if (newVersion > oldVersion) {
+ db.execSQL("ALTER TABLE " + ONION_SERVICE_TABLE_NAME + " ADD COLUMN filepath text");
+ }
+ }
+
+
+}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/trueTime/trueTimeEncryption.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/trueTime/trueTimeEncryption.java
similarity index 81%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/trueTime/trueTimeEncryption.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/trueTime/trueTimeEncryption.java
index 103c1010..f6a6850e 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/trueTime/trueTimeEncryption.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/trueTime/trueTimeEncryption.java
@@ -1,11 +1,8 @@
-package com.darkweb.genesissearchengine.libs.trueTime;
+package com.hiddenservices.genesissearchengine.production.libs.trueTime;
-import android.os.Build;
-import androidx.annotation.RequiresApi;
import com.instacart.library.truetime.TrueTime;
import com.macasaet.fernet.Key;
import com.macasaet.fernet.Token;
-
import java.util.Base64;
public class trueTimeEncryption {
@@ -31,7 +28,7 @@ public class trueTimeEncryption {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
mkey = new Key(Base64.getUrlEncoder().encodeToString(S_FERNET_KEY.getBytes()));
}
- Token token = Token.generate(mkey, S_APP_BLOCK_KEY);
+ Token token = Token.generate(mkey, S_APP_BLOCK_KEY + "----" + System.currentTimeMillis()/1000);
return token.serialise();
}
}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/views/ColorAnimator.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/views/ColorAnimator.java
similarity index 90%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/views/ColorAnimator.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/views/ColorAnimator.java
index 2fff8841..002f04b0 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/views/ColorAnimator.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/views/ColorAnimator.java
@@ -1,4 +1,4 @@
-package com.darkweb.genesissearchengine.libs.views;
+package com.hiddenservices.genesissearchengine.production.libs.views;
import android.graphics.Color;
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/views/KeyboardUtils.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/views/KeyboardUtils.java
similarity index 95%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/views/KeyboardUtils.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/views/KeyboardUtils.java
index f3ea0ce8..6e6770af 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/views/KeyboardUtils.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/views/KeyboardUtils.java
@@ -1,4 +1,4 @@
-package com.darkweb.genesissearchengine.libs.views;
+package com.hiddenservices.genesissearchengine.production.libs.views;
import android.app.Activity;
import android.graphics.Rect;
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/libs/views/ThumbnailCrop.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/views/ThumbnailCrop.java
similarity index 93%
rename from app/src/main/java/com/darkweb/genesissearchengine/libs/views/ThumbnailCrop.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/views/ThumbnailCrop.java
index 8daf5b04..2015f219 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/libs/views/ThumbnailCrop.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/libs/views/ThumbnailCrop.java
@@ -1,4 +1,4 @@
-package com.darkweb.genesissearchengine.libs.views;
+package com.hiddenservices.genesissearchengine.production.libs.views;
import android.content.Context;
import android.graphics.Matrix;
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/adPluginManager/admobManager.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/adPluginManager/admobManager.java
similarity index 78%
rename from app/src/main/java/com/darkweb/genesissearchengine/pluginManager/adPluginManager/admobManager.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/adPluginManager/admobManager.java
index 68495d9c..108d0bbe 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/adPluginManager/admobManager.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/adPluginManager/admobManager.java
@@ -1,116 +1,114 @@
-package com.darkweb.genesissearchengine.pluginManager.adPluginManager;
-
-import android.content.Context;
-import android.util.Log;
-import com.darkweb.genesissearchengine.eventObserver;
-import com.darkweb.genesissearchengine.pluginManager.pluginEnums;
-import com.google.android.gms.ads.AdListener;
-import com.google.android.gms.ads.AdRequest;
-import com.google.android.gms.ads.AdView;
-import com.google.android.gms.ads.LoadAdError;
-import com.google.android.gms.ads.MobileAds;
-import com.google.android.gms.ads.RequestConfiguration;
-import java.lang.ref.WeakReference;
-import java.util.Collections;
-import java.util.List;
-import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eAdManagerCallbacks.M_ON_AD_CLICK;
-import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eAdManagerCallbacks.M_ON_AD_HIDE;
-import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eAdManagerCallbacks.M_ON_AD_LOAD;
-
-public class admobManager extends AdListener {
-
- /*Private Variables */
-
- private eventObserver.eventListener mEvent;
- private WeakReference mBannerAds;
-
- private boolean bannerAdsLoaded = false;
- private boolean mAdvertClicked = false;
- private static boolean mBannerAdvertLoadReqest = false;
-
- /*Initializations*/
-
- public admobManager(eventObserver.eventListener pEvent, AdView pBannerAds, Context pContext) {
- this.mEvent = pEvent;
- this.mBannerAds = new WeakReference(pBannerAds);
- loadAds(pContext);
- }
-
- /*Local Overrides*/
-
- @Override
- public void onAdLoaded() {
- super.onAdLoaded();
- bannerAdsLoaded = true;
- mEvent.invokeObserver(null, M_ON_AD_LOAD);
- }
-
- @Override
- public void onAdClicked(){
- super.onAdClicked();
- mEvent.invokeObserver(null, M_ON_AD_CLICK);
- onDestroy();
- mAdvertClicked = true;
- }
-
- @Override
- public void onAdOpened(){
- super.onAdClicked();
- mEvent.invokeObserver(null, M_ON_AD_CLICK);
- onDestroy();
- mAdvertClicked = true;
- }
-
- @Override
- public void onAdFailedToLoad(LoadAdError var1){
- Log.i("asd","asd");
- }
-
- /*Local Helper Methods*/
-
- private void loadAds(Context pContext){
- if(!mBannerAdvertLoadReqest){
- mBannerAdvertLoadReqest = true;
-
-
- AdRequest adRequest = new AdRequest.Builder().build();
- mBannerAds.get().setAdListener(this);
- mBannerAds.get().loadAd(adRequest);
-
-
- }else {
- onDestroy();
- mEvent.invokeObserver(null, M_ON_AD_HIDE);
- }
- }
-
-
- private boolean isAdvertLoaded(){
- if(mAdvertClicked){
- return false;
- }else {
- return bannerAdsLoaded;
- }
- }
-
- private void onDestroy(){
- mBannerAds.get().destroy();
- }
-
- /*External Triggers*/
-
- public Object onTrigger(pluginEnums.eAdManager pEventType) {
- if(pEventType.equals(pluginEnums.eAdManager.M_INITIALIZE_BANNER_ADS))
- {
- }
- else if(pEventType.equals(pluginEnums.eAdManager.M_IS_ADVERT_LOADED))
- {
- return isAdvertLoaded();
- }
- else if(pEventType.equals(pluginEnums.eAdManager.M_DESTROY))
- {
- onDestroy();
- }
- return null;
- }
-}
+package com.hiddenservices.genesissearchengine.production.pluginManager.adPluginManager;
+
+import android.content.Context;
+import android.util.Log;
+import com.hiddenservices.genesissearchengine.production.eventObserver;
+import com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums;
+import com.google.android.gms.ads.AdListener;
+import com.google.android.gms.ads.AdRequest;
+import com.google.android.gms.ads.AdView;
+import com.google.android.gms.ads.LoadAdError;
+
+import java.lang.ref.WeakReference;
+
+import static com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums.eAdManagerCallbacks.M_ON_AD_CLICK;
+import static com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums.eAdManagerCallbacks.M_ON_AD_HIDE;
+import static com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums.eAdManagerCallbacks.M_ON_AD_LOAD;
+
+public class admobManager extends AdListener {
+
+ /*Private Variables */
+
+ private eventObserver.eventListener mEvent;
+ private WeakReference mBannerAds;
+
+ private boolean bannerAdsLoaded = false;
+ private boolean mAdvertClicked = false;
+ private static boolean mBannerAdvertLoadReqest = false;
+
+ /*Initializations*/
+
+ public admobManager(eventObserver.eventListener pEvent, AdView pBannerAds, Context pContext) {
+ this.mEvent = pEvent;
+ this.mBannerAds = new WeakReference(pBannerAds);
+ loadAds(pContext);
+ }
+
+ /*Local Overrides*/
+
+ @Override
+ public void onAdLoaded() {
+ super.onAdLoaded();
+ bannerAdsLoaded = true;
+ mEvent.invokeObserver(null, M_ON_AD_LOAD);
+ }
+
+ @Override
+ public void onAdClicked(){
+ super.onAdClicked();
+ mEvent.invokeObserver(null, M_ON_AD_CLICK);
+ onDestroy();
+ mAdvertClicked = true;
+ }
+
+ @Override
+ public void onAdOpened(){
+ super.onAdClicked();
+ mEvent.invokeObserver(null, M_ON_AD_CLICK);
+ onDestroy();
+ mAdvertClicked = true;
+ }
+
+ @Override
+ public void onAdFailedToLoad(LoadAdError var1){
+ Log.i("asd","asd");
+ }
+
+ /*Local Helper Methods*/
+
+ private void loadAds(Context pContext){
+ if(!mBannerAdvertLoadReqest){
+ mBannerAdvertLoadReqest = true;
+
+
+ AdRequest adRequest = new AdRequest.Builder().build();
+ mBannerAds.get().setAdListener(this);
+ mBannerAds.get().loadAd(adRequest);
+
+
+ }else {
+ onDestroy();
+ mEvent.invokeObserver(null, M_ON_AD_HIDE);
+ }
+ }
+
+
+ private boolean isAdvertLoaded(){
+ if(mAdvertClicked){
+ return false;
+ }else {
+ return bannerAdsLoaded;
+ }
+ }
+
+ private void onDestroy(){
+ mBannerAds.get().destroy();
+ }
+
+ /*External Triggers*/
+
+ public Object onTrigger(pluginEnums.eAdManager pEventType) {
+ if(pEventType.equals(pluginEnums.eAdManager.M_INITIALIZE_BANNER_ADS))
+ {
+ }
+ else if(pEventType.equals(pluginEnums.eAdManager.M_IS_ADVERT_LOADED))
+ {
+ return isAdvertLoaded();
+ }
+ else if(pEventType.equals(pluginEnums.eAdManager.M_DESTROY))
+ {
+ onDestroy();
+ }
+ return null;
+ }
+}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/adPluginManager/facebookAdsManager.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/adPluginManager/facebookAdsManager.java
similarity index 79%
rename from app/src/main/java/com/darkweb/genesissearchengine/pluginManager/adPluginManager/facebookAdsManager.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/adPluginManager/facebookAdsManager.java
index 2cd23772..18d1a26f 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/adPluginManager/facebookAdsManager.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/adPluginManager/facebookAdsManager.java
@@ -1,87 +1,87 @@
-package com.darkweb.genesissearchengine.pluginManager.adPluginManager;
-
-import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eAdManagerCallbacks.M_ON_AD_CLICK;
-import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eAdManagerCallbacks.M_ON_AD_LOAD;
-import android.widget.LinearLayout;
-import androidx.appcompat.app.AppCompatActivity;
-import com.darkweb.genesissearchengine.eventObserver;
-import com.darkweb.genesissearchengine.pluginManager.pluginEnums;
-import com.facebook.ads.*;
-import org.mozilla.thirdparty.com.google.android.exoplayer2.util.Log;
-import java.lang.ref.WeakReference;
-
-public class facebookAdsManager implements AdListener {
-
- /*Private Variables */
-
- private eventObserver.eventListener mEvent;
- private WeakReference mBannerAds;
- private AdView adView;
-
- private boolean bannerAdsLoaded = false;
-
- /*Initializations*/
-
- public facebookAdsManager(eventObserver.eventListener pEvent, LinearLayout pBannerAds, AppCompatActivity pContext) {
- this.mEvent = pEvent;
- this.mBannerAds = new WeakReference(pBannerAds);
- loadAds(pContext, pBannerAds);
- }
-
- /*Local Overrides*/
- @Override
- public void onError(Ad ad, AdError adError) {
- Log.i("asd","asd");
- }
-
- @Override
- public void onAdLoaded(Ad ad) {
- bannerAdsLoaded = true;
- mEvent.invokeObserver(null, M_ON_AD_LOAD);
- }
-
- @Override
- public void onAdClicked(Ad ad) {
- mEvent.invokeObserver(null, M_ON_AD_CLICK);
- }
-
- @Override
- public void onLoggingImpression(Ad ad) {
- }
-
-
- /*Local Helper Methods*/
-
- private void loadAds(AppCompatActivity pContext, LinearLayout pLinearLayout){
- AudienceNetworkAds.initialize(pContext);
- adView = new AdView(pContext, "IMG_16_9_APP_INSTALL#YOUR_PLACEMENT_ID", AdSize.BANNER_HEIGHT_50);
- pLinearLayout.addView(adView);
- adView.loadAd(adView.buildLoadAdConfig().withAdListener(this).build());
- }
-
-
- private boolean isAdvertLoaded(){
- return bannerAdsLoaded;
- }
-
- private void onDestroy(){
- adView.destroy();
- }
-
- /*External Triggers*/
-
- public Object onTrigger(pluginEnums.eAdManager pEventType) {
- if(pEventType.equals(pluginEnums.eAdManager.M_INITIALIZE_BANNER_ADS))
- {
- }
- else if(pEventType.equals(pluginEnums.eAdManager.M_IS_ADVERT_LOADED))
- {
- return isAdvertLoaded();
- }
- else if(pEventType.equals(pluginEnums.eAdManager.M_DESTROY))
- {
- onDestroy();
- }
- return null;
- }
-}
+package com.hiddenservices.genesissearchengine.production.pluginManager.adPluginManager;
+
+import static com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums.eAdManagerCallbacks.M_ON_AD_CLICK;
+import static com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums.eAdManagerCallbacks.M_ON_AD_LOAD;
+import android.widget.LinearLayout;
+import androidx.appcompat.app.AppCompatActivity;
+import com.hiddenservices.genesissearchengine.production.eventObserver;
+import com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums;
+import com.facebook.ads.*;
+import org.mozilla.thirdparty.com.google.android.exoplayer2.util.Log;
+import java.lang.ref.WeakReference;
+
+public class facebookAdsManager implements AdListener {
+
+ /*Private Variables */
+
+ private eventObserver.eventListener mEvent;
+ private WeakReference mBannerAds;
+ private AdView adView;
+
+ private boolean bannerAdsLoaded = false;
+
+ /*Initializations*/
+
+ public facebookAdsManager(eventObserver.eventListener pEvent, LinearLayout pBannerAds, AppCompatActivity pContext) {
+ this.mEvent = pEvent;
+ this.mBannerAds = new WeakReference(pBannerAds);
+ loadAds(pContext, pBannerAds);
+ }
+
+ /*Local Overrides*/
+ @Override
+ public void onError(Ad ad, AdError adError) {
+ Log.i("asd","asd");
+ }
+
+ @Override
+ public void onAdLoaded(Ad ad) {
+ bannerAdsLoaded = true;
+ mEvent.invokeObserver(null, M_ON_AD_LOAD);
+ }
+
+ @Override
+ public void onAdClicked(Ad ad) {
+ mEvent.invokeObserver(null, M_ON_AD_CLICK);
+ }
+
+ @Override
+ public void onLoggingImpression(Ad ad) {
+ }
+
+
+ /*Local Helper Methods*/
+
+ private void loadAds(AppCompatActivity pContext, LinearLayout pLinearLayout){
+ AudienceNetworkAds.initialize(pContext);
+ adView = new AdView(pContext, "IMG_16_9_APP_INSTALL#YOUR_PLACEMENT_ID", AdSize.BANNER_HEIGHT_50);
+ pLinearLayout.addView(adView);
+ adView.loadAd(adView.buildLoadAdConfig().withAdListener(this).build());
+ }
+
+
+ private boolean isAdvertLoaded(){
+ return bannerAdsLoaded;
+ }
+
+ private void onDestroy(){
+ adView.destroy();
+ }
+
+ /*External Triggers*/
+
+ public Object onTrigger(pluginEnums.eAdManager pEventType) {
+ if(pEventType.equals(pluginEnums.eAdManager.M_INITIALIZE_BANNER_ADS))
+ {
+ }
+ else if(pEventType.equals(pluginEnums.eAdManager.M_IS_ADVERT_LOADED))
+ {
+ return isAdvertLoaded();
+ }
+ else if(pEventType.equals(pluginEnums.eAdManager.M_DESTROY))
+ {
+ onDestroy();
+ }
+ return null;
+ }
+}
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/adPluginManager/mopubManager.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/adPluginManager/mopubManager.java
similarity index 85%
rename from app/src/main/java/com/darkweb/genesissearchengine/pluginManager/adPluginManager/mopubManager.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/adPluginManager/mopubManager.java
index 56376ddb..8594af47 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/adPluginManager/mopubManager.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/adPluginManager/mopubManager.java
@@ -1,118 +1,118 @@
-package com.darkweb.genesissearchengine.pluginManager.adPluginManager;
-
-import android.content.Context;
-import android.os.Handler;
-import androidx.annotation.NonNull;
-import com.darkweb.genesissearchengine.constants.keys;
-import com.darkweb.genesissearchengine.eventObserver;
-import com.darkweb.genesissearchengine.pluginManager.pluginEnums;
-import com.facebook.ads.AudienceNetworkAds;
-import com.mopub.common.MoPub;
-import com.mopub.common.SdkConfiguration;
-import com.mopub.common.SdkInitializationListener;
-import com.mopub.mobileads.MoPubErrorCode;
-import com.mopub.mobileads.MoPubView;
-import java.lang.ref.WeakReference;
-import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eAdManagerCallbacks.M_ON_AD_LOAD;
-import static com.mopub.common.logging.MoPubLog.LogLevel.INFO;
-
-public class mopubManager implements MoPubView.BannerAdListener
-{
- //70f6dfc0cde14baaaa25083653700416
- /*Private Variables */
-
- private eventObserver.eventListener mEvent;
- private WeakReference mBannerAds;
- private int mRequestCount = 0;
-
- private boolean bannerAdsLoaded = false;
- private boolean bannerAdRequested = false;
-
- /*Initializations*/
-
- public mopubManager(eventObserver.eventListener pEvent, MoPubView pBannerAds, Context pContext) {
- this.mEvent = pEvent;
- this.mBannerAds = new WeakReference(pBannerAds);
- initializeBannerAds(pContext);
- }
-
- private void initializeBannerAds(Context pContext){
- final SdkConfiguration.Builder configBuilder = new SdkConfiguration.Builder(keys.ADMANAGER_APPID_KEY);
- configBuilder.withLogLevel(INFO);
-
- AudienceNetworkAds.initialize(pContext);
- MoPub.initializeSdk(pContext, configBuilder.build(), initSdkListener());
- }
-
- private SdkInitializationListener initSdkListener() {
- return () -> {
- };
- }
-
- /* Local Overrides */
-
- @Override
- public void onBannerLoaded(@NonNull MoPubView moPubView) {
- bannerAdsLoaded = true;
- mEvent.invokeObserver(null, M_ON_AD_LOAD);
- }
-
- @Override
- public void onBannerFailed(MoPubView moPubView, MoPubErrorCode moPubErrorCode) {
- new Handler().postDelayed(() ->
- {
- if(mRequestCount<=10){
- mRequestCount +=1;
- mBannerAds.get().setAdUnitId(keys.ADMANAGER_APPID_KEY);
- mBannerAds.get().setAdSize(MoPubView.MoPubAdSize.HEIGHT_50);
- mBannerAds.get().loadAd();
- mBannerAds.get().setBannerAdListener(this);
- }
- }, 10000);
- }
-
- @Override
- public void onBannerClicked(MoPubView moPubView) {
-
- }
-
- @Override
- public void onBannerExpanded(MoPubView moPubView) {
-
- }
-
- @Override
- public void onBannerCollapsed(MoPubView moPubView) {
-
- }
-
- /*Local Helper Methods*/
-
- private void loadAds(){
- if(!bannerAdRequested){
- bannerAdRequested = true;
- mBannerAds.get().setAdUnitId(keys.ADMANAGER_APPID_KEY);
- mBannerAds.get().loadAd();
- mBannerAds.get().setBannerAdListener(this);
- }
- }
-
- private boolean isAdvertLoaded(){
- return bannerAdsLoaded;
- }
-
- /*External Triggers*/
-
- public Object onTrigger(pluginEnums.eAdManager pEventType) {
- if(pEventType.equals(pluginEnums.eAdManager.M_INITIALIZE_BANNER_ADS))
- {
- loadAds();
- }
- else if(pEventType.equals(pluginEnums.eAdManager.M_IS_ADVERT_LOADED))
- {
- return isAdvertLoaded();
- }
- return null;
- }
-}
-
+package com.hiddenservices.genesissearchengine.production.pluginManager.adPluginManager;
+
+import android.content.Context;
+import android.os.Handler;
+import androidx.annotation.NonNull;
+import com.hiddenservices.genesissearchengine.production.constants.keys;
+import com.hiddenservices.genesissearchengine.production.eventObserver;
+import com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums;
+import com.facebook.ads.AudienceNetworkAds;
+import com.mopub.common.MoPub;
+import com.mopub.common.SdkConfiguration;
+import com.mopub.common.SdkInitializationListener;
+import com.mopub.mobileads.MoPubErrorCode;
+import com.mopub.mobileads.MoPubView;
+import java.lang.ref.WeakReference;
+import static com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums.eAdManagerCallbacks.M_ON_AD_LOAD;
+import static com.mopub.common.logging.MoPubLog.LogLevel.INFO;
+
+public class mopubManager implements MoPubView.BannerAdListener
+{
+ //70f6dfc0cde14baaaa25083653700416
+ /*Private Variables */
+
+ private eventObserver.eventListener mEvent;
+ private WeakReference mBannerAds;
+ private int mRequestCount = 0;
+
+ private boolean bannerAdsLoaded = false;
+ private boolean bannerAdRequested = false;
+
+ /*Initializations*/
+
+ public mopubManager(eventObserver.eventListener pEvent, MoPubView pBannerAds, Context pContext) {
+ this.mEvent = pEvent;
+ this.mBannerAds = new WeakReference(pBannerAds);
+ initializeBannerAds(pContext);
+ }
+
+ private void initializeBannerAds(Context pContext){
+ final SdkConfiguration.Builder configBuilder = new SdkConfiguration.Builder(keys.ADMANAGER_APPID_KEY);
+ configBuilder.withLogLevel(INFO);
+
+ AudienceNetworkAds.initialize(pContext);
+ MoPub.initializeSdk(pContext, configBuilder.build(), initSdkListener());
+ }
+
+ private SdkInitializationListener initSdkListener() {
+ return () -> {
+ };
+ }
+
+ /* Local Overrides */
+
+ @Override
+ public void onBannerLoaded(@NonNull MoPubView moPubView) {
+ bannerAdsLoaded = true;
+ mEvent.invokeObserver(null, M_ON_AD_LOAD);
+ }
+
+ @Override
+ public void onBannerFailed(MoPubView moPubView, MoPubErrorCode moPubErrorCode) {
+ new Handler().postDelayed(() ->
+ {
+ if(mRequestCount<=10){
+ mRequestCount +=1;
+ mBannerAds.get().setAdUnitId(keys.ADMANAGER_APPID_KEY);
+ mBannerAds.get().setAdSize(MoPubView.MoPubAdSize.HEIGHT_50);
+ mBannerAds.get().loadAd();
+ mBannerAds.get().setBannerAdListener(this);
+ }
+ }, 10000);
+ }
+
+ @Override
+ public void onBannerClicked(MoPubView moPubView) {
+
+ }
+
+ @Override
+ public void onBannerExpanded(MoPubView moPubView) {
+
+ }
+
+ @Override
+ public void onBannerCollapsed(MoPubView moPubView) {
+
+ }
+
+ /*Local Helper Methods*/
+
+ private void loadAds(){
+ if(!bannerAdRequested){
+ bannerAdRequested = true;
+ mBannerAds.get().setAdUnitId(keys.ADMANAGER_APPID_KEY);
+ mBannerAds.get().loadAd();
+ mBannerAds.get().setBannerAdListener(this);
+ }
+ }
+
+ private boolean isAdvertLoaded(){
+ return bannerAdsLoaded;
+ }
+
+ /*External Triggers*/
+
+ public Object onTrigger(pluginEnums.eAdManager pEventType) {
+ if(pEventType.equals(pluginEnums.eAdManager.M_INITIALIZE_BANNER_ADS))
+ {
+ loadAds();
+ }
+ else if(pEventType.equals(pluginEnums.eAdManager.M_IS_ADVERT_LOADED))
+ {
+ return isAdvertLoaded();
+ }
+ return null;
+ }
+}
+
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/analyticPluginManager/analyticManager.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/analyticPluginManager/analyticManager.java
similarity index 78%
rename from app/src/main/java/com/darkweb/genesissearchengine/pluginManager/analyticPluginManager/analyticManager.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/analyticPluginManager/analyticManager.java
index 61f14855..0c449ef1 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/analyticPluginManager/analyticManager.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/analyticPluginManager/analyticManager.java
@@ -1,8 +1,8 @@
-package com.darkweb.genesissearchengine.pluginManager.analyticPluginManager;
+package com.hiddenservices.genesissearchengine.production.pluginManager.analyticPluginManager;
import androidx.appcompat.app.AppCompatActivity;
-import com.darkweb.genesissearchengine.eventObserver;
-import com.darkweb.genesissearchengine.pluginManager.pluginEnums;
+import com.hiddenservices.genesissearchengine.production.eventObserver;
+import com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums;
import com.flurry.android.FlurryAgent;
import java.lang.ref.WeakReference;
import java.util.List;
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/downloadPluginManager/blobDownloader.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/downloadPluginManager/blobDownloader.java
similarity index 95%
rename from app/src/main/java/com/darkweb/genesissearchengine/pluginManager/downloadPluginManager/blobDownloader.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/downloadPluginManager/blobDownloader.java
index 045cce80..45f564bf 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/downloadPluginManager/blobDownloader.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/downloadPluginManager/blobDownloader.java
@@ -1,78 +1,78 @@
-package com.darkweb.genesissearchengine.pluginManager.downloadPluginManager;
-
-import android.app.NotificationManager;
-import android.content.Context;
-import android.os.Environment;
-import android.os.Handler;
-import android.util.Base64;
-import android.webkit.JavascriptInterface;
-import androidx.core.app.NotificationCompat;
-import com.example.myapplication.R;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.text.DateFormat;
-import java.util.Date;
-
-public class blobDownloader {
-
- private Context context;
- private NotificationManager nm;
- public blobDownloader(Context context) {
- this.context = context;
- }
-
- @JavascriptInterface
- public void getBase64FromBlobData(String base64Data) throws IOException {
- convertBase64StringToPdfAndStoreIt(base64Data);
- }
- public static String getBase64StringFromBlobUrl(String blobUrl){
- if(blobUrl.startsWith("blob")){
- return "javascript: var xhr = new XMLHttpRequest();" +
- "xhr.open('GET', 'YOUR BLOB URL GOES HERE', true);" +
- "xhr.setRequestHeader('Content-type','application/pdf');" +
- "xhr.responseType = 'blob';" +
- "xhr.onload = function(e) {" +
- " if (this.status == 200) {" +
- " var blobPdf = this.response;" +
- " var reader = new FileReader();" +
- " reader.readAsDataURL(blobPdf);" +
- " reader.onloadend = function() {" +
- " base64data = reader.result;" +
- " Android.getBase64FromBlobData(base64data);" +
- " }" +
- " }" +
- "};" +
- "xhr.send();";
- }
- return "javascript: console.log('It is not a Blob URL');";
- }
-
- private void convertBase64StringToPdfAndStoreIt(String base64PDf) throws IOException {
- final int notificationId = 1;
- String currentDateTime = DateFormat.getDateTimeInstance().format(new Date());
- final File dwldsPath = new File(Environment.getExternalStoragePublicDirectory(
- Environment.DIRECTORY_DOWNLOADS) + "/YourFileName_" + currentDateTime + "_.pdf");
- byte[] pdfAsBytes = Base64.decode(base64PDf.replaceFirst("^data:application/pdf;base64,", ""), 0);
- FileOutputStream os;
- os = new FileOutputStream(dwldsPath, false);
- os.write(pdfAsBytes);
- os.flush();
-
- if(dwldsPath.exists()) {
- NotificationCompat.Builder b = new NotificationCompat.Builder(context, "MY_DL")
- .setDefaults(NotificationCompat.DEFAULT_ALL)
- .setWhen(System.currentTimeMillis())
- .setSmallIcon(R.xml.ic_download)
- .setContentTitle("MY TITLE")
- .setContentText("MY TEXT CONTENT");
- nm = (NotificationManager) this.context.getSystemService(Context.NOTIFICATION_SERVICE);
- if(nm != null) {
- nm.notify(notificationId, b.build());
- Handler h = new Handler();
- long delayInMilliseconds = 5000;
- h.postDelayed(() -> nm.cancel(notificationId), delayInMilliseconds);
- }
- }
- }
+package com.hiddenservices.genesissearchengine.production.pluginManager.downloadPluginManager;
+
+import android.app.NotificationManager;
+import android.content.Context;
+import android.os.Environment;
+import android.os.Handler;
+import android.util.Base64;
+import android.webkit.JavascriptInterface;
+import androidx.core.app.NotificationCompat;
+import com.example.myapplication.R;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.util.Date;
+
+public class blobDownloader {
+
+ private Context context;
+ private NotificationManager nm;
+ public blobDownloader(Context context) {
+ this.context = context;
+ }
+
+ @JavascriptInterface
+ public void getBase64FromBlobData(String base64Data) throws IOException {
+ convertBase64StringToPdfAndStoreIt(base64Data);
+ }
+ public static String getBase64StringFromBlobUrl(String blobUrl){
+ if(blobUrl.startsWith("blob")){
+ return "javascript: var xhr = new XMLHttpRequest();" +
+ "xhr.open('GET', 'YOUR BLOB URL GOES HERE', true);" +
+ "xhr.setRequestHeader('Content-type','application/pdf');" +
+ "xhr.responseType = 'blob';" +
+ "xhr.onload = function(e) {" +
+ " if (this.status == 200) {" +
+ " var blobPdf = this.response;" +
+ " var reader = new FileReader();" +
+ " reader.readAsDataURL(blobPdf);" +
+ " reader.onloadend = function() {" +
+ " base64data = reader.result;" +
+ " Android.getBase64FromBlobData(base64data);" +
+ " }" +
+ " }" +
+ "};" +
+ "xhr.send();";
+ }
+ return "javascript: console.log('It is not a Blob URL');";
+ }
+
+ private void convertBase64StringToPdfAndStoreIt(String base64PDf) throws IOException {
+ final int notificationId = 1;
+ String currentDateTime = DateFormat.getDateTimeInstance().format(new Date());
+ final File dwldsPath = new File(Environment.getExternalStoragePublicDirectory(
+ Environment.DIRECTORY_DOWNLOADS) + "/YourFileName_" + currentDateTime + "_.pdf");
+ byte[] pdfAsBytes = Base64.decode(base64PDf.replaceFirst("^data:application/pdf;base64,", ""), 0);
+ FileOutputStream os;
+ os = new FileOutputStream(dwldsPath, false);
+ os.write(pdfAsBytes);
+ os.flush();
+
+ if(dwldsPath.exists()) {
+ NotificationCompat.Builder b = new NotificationCompat.Builder(context, "MY_DL")
+ .setDefaults(NotificationCompat.DEFAULT_ALL)
+ .setWhen(System.currentTimeMillis())
+ .setSmallIcon(R.xml.ic_download)
+ .setContentTitle("MY TITLE")
+ .setContentText("MY TEXT CONTENT");
+ nm = (NotificationManager) this.context.getSystemService(Context.NOTIFICATION_SERVICE);
+ if(nm != null) {
+ nm.notify(notificationId, b.build());
+ Handler h = new Handler();
+ long delayInMilliseconds = 5000;
+ h.postDelayed(() -> nm.cancel(notificationId), delayInMilliseconds);
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/downloadPluginManager/downloadManager.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/downloadPluginManager/downloadManager.java
similarity index 85%
rename from app/src/main/java/com/darkweb/genesissearchengine/pluginManager/downloadPluginManager/downloadManager.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/downloadPluginManager/downloadManager.java
index ce983d78..72f76eb8 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/downloadPluginManager/downloadManager.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/downloadPluginManager/downloadManager.java
@@ -1,4 +1,4 @@
-package com.darkweb.genesissearchengine.pluginManager.downloadPluginManager;
+package com.hiddenservices.genesissearchengine.production.pluginManager.downloadPluginManager;
import android.app.NotificationManager;
import android.content.Context;
@@ -6,17 +6,16 @@ import android.os.Environment;
import androidx.appcompat.app.AppCompatActivity;
-import com.darkweb.genesissearchengine.constants.status;
-import com.darkweb.genesissearchengine.eventObserver;
-import com.darkweb.genesissearchengine.helperManager.helperMethod;
-import com.darkweb.genesissearchengine.pluginManager.pluginEnums;
-import com.darkweb.genesissearchengine.pluginManager.pluginReciever.downloadNotificationReciever;
+import com.hiddenservices.genesissearchengine.production.constants.status;
+import com.hiddenservices.genesissearchengine.production.eventObserver;
+import com.hiddenservices.genesissearchengine.production.helperManager.helperMethod;
+import com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums;
+import com.hiddenservices.genesissearchengine.production.pluginManager.pluginReciever.downloadNotificationReciever;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import static org.webrtc.ContextUtils.getApplicationContext;
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/downloadPluginManager/downloadReciever.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/downloadPluginManager/downloadReciever.java
similarity index 91%
rename from app/src/main/java/com/darkweb/genesissearchengine/pluginManager/downloadPluginManager/downloadReciever.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/downloadPluginManager/downloadReciever.java
index 28e13e67..34727634 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/downloadPluginManager/downloadReciever.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/downloadPluginManager/downloadReciever.java
@@ -1,4 +1,4 @@
-package com.darkweb.genesissearchengine.pluginManager.downloadPluginManager;
+package com.hiddenservices.genesissearchengine.production.pluginManager.downloadPluginManager;
import android.annotation.SuppressLint;
import android.app.DownloadManager;
@@ -22,16 +22,14 @@ import android.provider.MediaStore;
import androidx.core.app.NotificationCompat;
import androidx.core.content.FileProvider;
-import com.darkweb.genesissearchengine.appManager.activityContextManager;
-import com.darkweb.genesissearchengine.constants.status;
-import com.darkweb.genesissearchengine.eventObserver;
-import com.darkweb.genesissearchengine.helperManager.helperMethod;
-import com.darkweb.genesissearchengine.libs.netcipher.client.StrongHttpsClient;
-import com.darkweb.genesissearchengine.pluginManager.pluginController;
-import com.darkweb.genesissearchengine.pluginManager.pluginEnums;
+import com.hiddenservices.genesissearchengine.production.appManager.activityContextManager;
+import com.hiddenservices.genesissearchengine.production.constants.status;
+import com.hiddenservices.genesissearchengine.production.eventObserver;
+import com.hiddenservices.genesissearchengine.production.helperManager.helperMethod;
+import com.hiddenservices.genesissearchengine.production.libs.netcipher.client.StrongHttpsClient;
import com.example.myapplication.R;
import org.mozilla.thirdparty.com.google.android.exoplayer2.util.Log;
-import org.torproject.android.service.wrapper.orbotLocalConstants;
+import org.orbotproject.android.service.wrapper.orbotLocalConstants;
import java.io.File;
import java.io.FileOutputStream;
@@ -44,13 +42,12 @@ import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.text.DecimalFormat;
-import java.util.Arrays;
import java.util.Collections;
import ch.boye.httpclientandroidlib.HttpResponse;
import ch.boye.httpclientandroidlib.client.methods.HttpGet;
-import static com.darkweb.genesissearchengine.constants.enums.etype.M_DOWNLOAD_FAILURE;
+import static com.hiddenservices.genesissearchengine.production.constants.enums.etype.M_DOWNLOAD_FAILURE;
import static java.lang.Thread.sleep;
@@ -333,7 +330,7 @@ public class downloadReciever extends AsyncTask {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
- Uri uri = FileProvider.getUriForFile(context, "com.darkweb.genesissearchengine.production.provider", mFile);
+ Uri uri = FileProvider.getUriForFile(context, "com.hiddenservices.genesissearchengine.production.provider", mFile);
ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.Downloads.TITLE, mFileName);
@@ -344,7 +341,7 @@ public class downloadReciever extends AsyncTask {
ContentResolver database = context.getContentResolver();
database.insert(MediaStore.Downloads.EXTERNAL_CONTENT_URI, contentValues);
} else {
- Uri uri = FileProvider.getUriForFile(context, "com.darkweb.genesissearchengine.production.provider", mFile);
+ Uri uri = FileProvider.getUriForFile(context, "com.hiddenservices.genesissearchengine.production.provider", mFile);
String mime = helperMethod.getMimeType(uri.toString(), context);
if(mime!=null){
dm.addCompletedDownload(mFileName, mURL, false, mime, mFile.getAbsolutePath(), mFile.length(), false);
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/downloadPluginManager/downloadService.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/downloadPluginManager/downloadService.java
similarity index 83%
rename from app/src/main/java/com/darkweb/genesissearchengine/pluginManager/downloadPluginManager/downloadService.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/downloadPluginManager/downloadService.java
index 83e2328a..f69c0f90 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/downloadPluginManager/downloadService.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/downloadPluginManager/downloadService.java
@@ -1,4 +1,4 @@
-package com.darkweb.genesissearchengine.pluginManager.downloadPluginManager;
+package com.hiddenservices.genesissearchengine.production.pluginManager.downloadPluginManager;
import android.annotation.SuppressLint;
import android.app.IntentService;
@@ -8,8 +8,8 @@ import android.content.Intent;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import com.darkweb.genesissearchengine.pluginManager.pluginController;
-import com.darkweb.genesissearchengine.pluginManager.pluginEnums;
+import com.hiddenservices.genesissearchengine.production.pluginManager.pluginController;
+import com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums;
import java.util.Arrays;
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/langPluginManager/langManager.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/langPluginManager/langManager.java
similarity index 93%
rename from app/src/main/java/com/darkweb/genesissearchengine/pluginManager/langPluginManager/langManager.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/langPluginManager/langManager.java
index a24a0b00..4587bdff 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/langPluginManager/langManager.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/langPluginManager/langManager.java
@@ -1,15 +1,14 @@
-package com.darkweb.genesissearchengine.pluginManager.langPluginManager;
+package com.hiddenservices.genesissearchengine.production.pluginManager.langPluginManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import androidx.appcompat.app.AppCompatActivity;
-import com.darkweb.genesissearchengine.appManager.activityContextManager;
-import com.darkweb.genesissearchengine.constants.status;
-import com.darkweb.genesissearchengine.eventObserver;
-import com.darkweb.genesissearchengine.helperManager.helperMethod;
-import com.darkweb.genesissearchengine.pluginManager.pluginEnums;
+import com.hiddenservices.genesissearchengine.production.constants.status;
+import com.hiddenservices.genesissearchengine.production.eventObserver;
+import com.hiddenservices.genesissearchengine.production.helperManager.helperMethod;
+import com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums;
import java.util.Collections;
import java.util.List;
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/messagePluginManager/messageManager.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/messagePluginManager/messageManager.java
similarity index 92%
rename from app/src/main/java/com/darkweb/genesissearchengine/pluginManager/messagePluginManager/messageManager.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/messagePluginManager/messageManager.java
index 36dc6969..13c064cf 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/messagePluginManager/messageManager.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/messagePluginManager/messageManager.java
@@ -1,4 +1,4 @@
-package com.darkweb.genesissearchengine.pluginManager.messagePluginManager;
+package com.hiddenservices.genesissearchengine.production.pluginManager.messagePluginManager;
import android.app.Dialog;
import android.content.DialogInterface;
@@ -25,31 +25,29 @@ import android.widget.ScrollView;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
-
-import com.darkweb.genesissearchengine.constants.enums;
-import com.darkweb.genesissearchengine.constants.status;
-import com.darkweb.genesissearchengine.constants.strings;
-import com.darkweb.genesissearchengine.eventObserver;
-import com.darkweb.genesissearchengine.helperManager.helperMethod;
-import com.darkweb.genesissearchengine.pluginManager.pluginEnums;
+import com.hiddenservices.genesissearchengine.production.constants.enums;
+import com.hiddenservices.genesissearchengine.production.constants.status;
+import com.hiddenservices.genesissearchengine.production.constants.strings;
+import com.hiddenservices.genesissearchengine.production.eventObserver;
+import com.hiddenservices.genesissearchengine.production.helperManager.helperMethod;
+import com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums;
import com.example.myapplication.R;
import com.google.android.material.switchmaterial.SwitchMaterial;
import org.mozilla.geckoview.ContentBlocking;
-
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import static com.darkweb.genesissearchengine.constants.constants.*;
-import static com.darkweb.genesissearchengine.constants.strings.BRIDGE_CUSTOM_INVALID_TYPE;
-import static com.darkweb.genesissearchengine.constants.strings.BRIDGE_CUSTOM_INVALID_TYPE_STRING;
-import static com.darkweb.genesissearchengine.constants.strings.GENERIC_EMPTY_DOT;
-import static com.darkweb.genesissearchengine.constants.strings.MESSAGE_PLAYSTORE_NOT_FOUND;
-import static com.darkweb.genesissearchengine.constants.strings.MESSAGE_SECURE_ONION_SERVICE;
-import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManager.*;
-import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManagerCallbacks.*;
-import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManagerCallbacks.M_CLEAR_BOOKMARK;
-import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManagerCallbacks.M_CLEAR_HISTORY;
-import static com.darkweb.genesissearchengine.pluginManager.pluginEnums.eMessageManagerCallbacks.M_LOAD_NEW_TAB;
+import static com.hiddenservices.genesissearchengine.production.constants.constants.*;
+import static com.hiddenservices.genesissearchengine.production.constants.strings.BRIDGE_CUSTOM_INVALID_TYPE;
+import static com.hiddenservices.genesissearchengine.production.constants.strings.BRIDGE_CUSTOM_INVALID_TYPE_STRING;
+import static com.hiddenservices.genesissearchengine.production.constants.strings.GENERIC_EMPTY_DOT;
+import static com.hiddenservices.genesissearchengine.production.constants.strings.MESSAGE_PLAYSTORE_NOT_FOUND;
+import static com.hiddenservices.genesissearchengine.production.constants.strings.MESSAGE_SECURE_ONION_SERVICE;
+import static com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums.eMessageManager.*;
+import static com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums.eMessageManagerCallbacks.*;
+import static com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums.eMessageManagerCallbacks.M_CLEAR_BOOKMARK;
+import static com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums.eMessageManagerCallbacks.M_CLEAR_HISTORY;
+import static com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums.eMessageManagerCallbacks.M_LOAD_NEW_TAB;
public class messageManager implements View.OnClickListener, DialogInterface.OnDismissListener
{
@@ -436,6 +434,18 @@ public class messageManager implements View.OnClickListener, DialogInterface.OnD
}
}
+ public String getStoreLink() {
+ if(status.sStoreType == enums.StoreType.GOOGLE_PLAY){
+ return CONST_PLAYSTORE_URL;
+ }
+ else if(status.sStoreType == enums.StoreType.AMAZON){
+ return CONST_AMAZON_URL;
+ }
+ else {
+ return CONST_SAMSUNG_URL;
+ }
+ }
+
@Override
public void onClick(View view) {
if(view.getId() == R.id.pPopupToastTrigger ||
@@ -529,7 +539,8 @@ public class messageManager implements View.OnClickListener, DialogInterface.OnD
RatingBar mPopupRateusRating = mDialog.findViewById(R.id.pPopupRateusRating);
if(mPopupRateusRating.getRating()>=3){
mEvent.invokeObserver(null, M_APP_RATED);
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(CONST_PLAYSTORE_URL));
+ String mStoreURL = getStoreLink();
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(mStoreURL));
try {
mContext.startActivity(intent);
} catch (Exception ignored) {
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/notificationPluginManager/localEngagementManager.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/notificationPluginManager/localEngagementManager.java
similarity index 89%
rename from app/src/main/java/com/darkweb/genesissearchengine/pluginManager/notificationPluginManager/localEngagementManager.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/notificationPluginManager/localEngagementManager.java
index f0758d7e..1fd30076 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/notificationPluginManager/localEngagementManager.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/notificationPluginManager/localEngagementManager.java
@@ -1,4 +1,4 @@
-package com.darkweb.genesissearchengine.pluginManager.notificationPluginManager;
+package com.hiddenservices.genesissearchengine.production.pluginManager.notificationPluginManager;
import android.app.Notification ;
import android.app.NotificationChannel ;
@@ -11,11 +11,11 @@ import android.graphics.Color;
import android.os.Build;
import android.util.Log;
import androidx.core.app.NotificationCompat;
-import com.darkweb.genesissearchengine.appManager.activityContextManager;
-import com.darkweb.genesissearchengine.constants.strings;
+import com.hiddenservices.genesissearchengine.production.appManager.activityContextManager;
+import com.hiddenservices.genesissearchengine.production.constants.strings;
import com.example.myapplication.R;
import java.util.Random;
-import static com.darkweb.genesissearchengine.constants.constants.mUserEngagementNotificationID;
+import static com.hiddenservices.genesissearchengine.production.constants.constants.mUserEngagementNotificationID;
public class localEngagementManager extends BroadcastReceiver {
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/notificationPluginManager/notifictionManager.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/notificationPluginManager/notifictionManager.java
similarity index 87%
rename from app/src/main/java/com/darkweb/genesissearchengine/pluginManager/notificationPluginManager/notifictionManager.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/notificationPluginManager/notifictionManager.java
index 8112af70..bbcdb464 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/notificationPluginManager/notifictionManager.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/notificationPluginManager/notifictionManager.java
@@ -1,4 +1,4 @@
-package com.darkweb.genesissearchengine.pluginManager.notificationPluginManager;
+package com.hiddenservices.genesissearchengine.production.pluginManager.notificationPluginManager;
import android.app.AlarmManager;
import android.app.Notification;
@@ -10,13 +10,13 @@ import android.graphics.Color;
import android.os.SystemClock;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NotificationCompat;
-import com.darkweb.genesissearchengine.constants.status;
-import com.darkweb.genesissearchengine.eventObserver;
-import com.darkweb.genesissearchengine.pluginManager.pluginEnums;
+
+import com.hiddenservices.genesissearchengine.production.eventObserver;
+import com.hiddenservices.genesissearchengine.production.pluginManager.pluginEnums;
import com.example.myapplication.R;
import java.lang.ref.WeakReference;
import java.util.List;
-import static com.darkweb.genesissearchengine.constants.constants.*;
+import static com.hiddenservices.genesissearchengine.production.constants.constants.*;
public class notifictionManager
{
diff --git a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/orbotPluginManager/orbotLogManager.java b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/orbotPluginManager/orbotLogManager.java
similarity index 74%
rename from app/src/main/java/com/darkweb/genesissearchengine/pluginManager/orbotPluginManager/orbotLogManager.java
rename to app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/orbotPluginManager/orbotLogManager.java
index d2730d81..d8445d94 100644
--- a/app/src/main/java/com/darkweb/genesissearchengine/pluginManager/orbotPluginManager/orbotLogManager.java
+++ b/app/src/main/java/com/hiddenservices/genesissearchengine.production/pluginManager/orbotPluginManager/orbotLogManager.java
@@ -1,49 +1,49 @@
-package com.darkweb.genesissearchengine.pluginManager.orbotPluginManager;
-
-import com.darkweb.genesissearchengine.constants.strings;
-import java.util.List;
-import static com.darkweb.genesissearchengine.pluginManager.orbotPluginManager.orbotPluginEnums.eLogManager.M_GET_CLEANED_LOGS;
-
-public class orbotLogManager
-{
-
- private String onGetCleanedLogs(String pLogs)
- {
- String logs = pLogs;
-
- if(logs.equals("Starting Genesis | Please Wait ...")){
- return logs;
- }
-
- if(pLogs.equals("No internet connection")){
- return "Warning | " + pLogs;
- }
-
- else if(pLogs.startsWith("Invalid Configuration")){
- return pLogs;
- }
-
- if(!logs.contains("Bootstrapped")){
- logs = "Initializing Bootstrap";
- }
-
- if(!logs.equals(strings.GENERIC_EMPTY_STR))
- {
- String Logs = logs;
- Logs="Installing | " + Logs.replace("FAILED","Securing");
- return Logs;
- }
- return "Loading Please Wait...";
- }
-
- /*External Triggers*/
-
- public Object onTrigger(List
reload
you are facing the one of the following problem. webpage or website might not be working. your internet connection might be poor. you might be using a proxy. website might be blocked by firewall
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
BBC | Israel Strikes Again
diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml
index 11c16bc6..e908d98c 100644
--- a/app/src/main/res/values-ar/strings.xml
+++ b/app/src/main/res/values-ar/strings.xml
@@ -12,7 +12,7 @@
الحرية الرقمية
إعادة تحميل
لديك واحدة من المشاكل التالية. قد لا تعمل صفحة الويب أو موقع الويب. قد يكون اتصالك بالإنترنت معطلاً. ربما كنت تستخدم وكيل. قد يتم حظر موقع الويب بواسطة جدار حماية
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
بي بي سي | هاجمت إسرائيل مرة أخرى
diff --git a/app/src/main/res/values-ca/strings.xml b/app/src/main/res/values-ca/strings.xml
index 3d7599ed..ff76254c 100644
--- a/app/src/main/res/values-ca/strings.xml
+++ b/app/src/main/res/values-ca/strings.xml
@@ -12,7 +12,7 @@
llibertat digital
recarregar
us trobeu amb el problema següent. pot ser que la pàgina web o el lloc web no funcionin. és possible que la vostra connexió a Internet sigui deficient. és possible que utilitzeu un servidor intermediari. el tallafoc podria bloquejar el lloc web
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
BBC, Israel torna a atacar
diff --git a/app/src/main/res/values-ch/strings.xml b/app/src/main/res/values-ch/strings.xml
index 174e7432..abb44159 100644
--- a/app/src/main/res/values-ch/strings.xml
+++ b/app/src/main/res/values-ch/strings.xml
@@ -12,7 +12,7 @@
digitální svoboda
Znovu načíst
čelíte jednomu z následujících problémů. webová stránka nebo web nemusí fungovat. vaše připojení k internetu může být špatné. možná používáte proxy. web může být blokován bránou firewall
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
BBC | Izrael znovu udeří
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index b0b27824..253c14cf 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -12,7 +12,7 @@
digitale Freiheit
neu laden
Sie stehen vor einem der folgenden Probleme. Webseite oder Website funktioniert möglicherweise nicht. Ihre Internetverbindung ist möglicherweise schlecht. Möglicherweise verwenden Sie einen Proxy. Die Website wird möglicherweise von der Firewall blockiert
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
BBC | Israel schlägt erneut zu
diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml
index f22acf40..0c96c5cf 100644
--- a/app/src/main/res/values-el/strings.xml
+++ b/app/src/main/res/values-el/strings.xml
@@ -12,7 +12,7 @@
ψηφιακή ελευθερία
φορτώνω πάλι
αντιμετωπίζετε ένα από τα ακόλουθα προβλήματα. η ιστοσελίδα ή ο ιστότοπος ενδέχεται να μην λειτουργούν. η σύνδεσή σας στο Διαδίκτυο μπορεί να είναι κακή. μπορεί να χρησιμοποιείτε διακομιστή μεσολάβησης. Ο ιστότοπος ενδέχεται να αποκλειστεί από το τείχος προστασίας
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
BBC | Το Ισραήλ χτυπά ξανά
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 420b37d4..ec1fb6be 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -12,7 +12,7 @@
liberté numérique
recharger
vous êtes confronté à l\'un des problèmes suivants. la page Web ou le site Web peut ne pas fonctionner. votre connexion Internet est peut-être mauvaise. vous utilisez peut-être un proxy. le site Web peut être bloqué par le pare-feu
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
BBC | Israël frappe à nouveau
diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml
index ea3c9f70..38099fe2 100644
--- a/app/src/main/res/values-hu/strings.xml
+++ b/app/src/main/res/values-hu/strings.xml
@@ -12,7 +12,7 @@
digitális szabadság
újratöltés
a következő probléma egyikével áll szemben. előfordulhat, hogy egy weboldal vagy webhely nem működik. gyenge lehet az internetkapcsolat. lehet, hogy proxyt használ. előfordulhat, hogy a webhelyet tűzfal blokkolja
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
BBC | Izrael újra sztrájkol
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 664968a5..c9e8dbce 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -12,7 +12,7 @@
libertà digitale
ricaricare
stai affrontando uno dei seguenti problemi. la pagina web o il sito web potrebbero non funzionare. la tua connessione Internet potrebbe essere scarsa. potresti utilizzare un proxy. il sito Web potrebbe essere bloccato dal firewall
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
BBC | Israele colpisce ancora
diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml
index 3be21e49..770417bb 100644
--- a/app/src/main/res/values-ja-rJP/strings.xml
+++ b/app/src/main/res/values-ja-rJP/strings.xml
@@ -12,7 +12,7 @@
デジタルの自由
リロード
次のいずれかの問題が発生しています。ウェブページまたはウェブサイトが機能していない可能性があります。インターネット接続が悪い可能性があります。プロキシを使用している可能性があります。ウェブサイトがファイアウォールによってブロックされている可能性があります
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
BBC |イスラエルが再びストライキ
diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml
index 6a7a34fa..65a869db 100644
--- a/app/src/main/res/values-ko/strings.xml
+++ b/app/src/main/res/values-ko/strings.xml
@@ -12,7 +12,7 @@
디지털 자유
재 장전
다음 문제 중 하나에 직면하고 있습니다. 웹 페이지 또는 웹 사이트가 작동하지 않을 수 있습니다. 인터넷 연결 상태가 좋지 않을 수 있습니다. 프록시를 사용하고있을 수 있습니다. 웹 사이트가 방화벽에 의해 차단 될 수 있음
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
BBC | 이스라엘이 다시 공격하다
diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml
index e91e6954..c6cb868d 100644
--- a/app/src/main/res/values-night/colors.xml
+++ b/app/src/main/res/values-night/colors.xml
@@ -64,7 +64,6 @@
#121216
#293a56
#3a5278
- #ffffff
#3385ff
#ffffff
#4d4d4d
@@ -116,8 +115,8 @@
#425e8a
#324467
#0f0f0f
- #90000000
#d9d9d9
#1c1b21
+ #141414
diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml
index 86a6e521..d718a326 100644
--- a/app/src/main/res/values-pt/strings.xml
+++ b/app/src/main/res/values-pt/strings.xml
@@ -12,7 +12,7 @@
digital freedom
recarregar
você está enfrentando um dos seguintes problemas. página da Web ou site pode não estar funcionando. sua conexão com a internet pode estar ruim. você pode estar usando um proxy. site pode estar bloqueado por firewall
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
BBC | Israel ataca novamente
diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml
index cc221f58..6ec8c39b 100644
--- a/app/src/main/res/values-ro/strings.xml
+++ b/app/src/main/res/values-ro/strings.xml
@@ -12,7 +12,7 @@
libertatea digitală
reîncărcați
vă confruntați cu una dintre următoarele probleme. este posibil ca pagina web sau site-ul web să nu funcționeze. conexiunea la internet ar putea fi slabă. s-ar putea să utilizați un proxy. site-ul web ar putea fi blocat de firewall
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
BBC | Israelul lovește din nou
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 9bdfe4fe..e50f4238 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -12,7 +12,7 @@
цифровая свобода
перезагрузить
вы столкнулись с одной из следующих проблем. веб-страница или веб-сайт могут не работать. ваше интернет-соединение может быть плохим. вы можете использовать прокси. веб-сайт может быть заблокирован брандмауэром
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
BBC | Израиль снова наносит удар
diff --git a/app/src/main/res/values-th/strings.xml b/app/src/main/res/values-th/strings.xml
index 23329df2..3cdff654 100644
--- a/app/src/main/res/values-th/strings.xml
+++ b/app/src/main/res/values-th/strings.xml
@@ -12,7 +12,7 @@
เสรีภาพดิจิทัล
โหลดใหม่
คุณกำลังประสบปัญหาอย่างใดอย่างหนึ่งต่อไปนี้ หน้าเว็บหรือเว็บไซต์อาจไม่ทำงาน การเชื่อมต่ออินเทอร์เน็ตของคุณอาจไม่ดี คุณอาจใช้พร็อกซี เว็บไซต์อาจถูกปิดกั้นโดยไฟร์วอลล์
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
BBC | อิสราเอลนัดหยุดงานอีกครั้ง
diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml
index 8cba6e70..835a7711 100644
--- a/app/src/main/res/values-tr/strings.xml
+++ b/app/src/main/res/values-tr/strings.xml
@@ -1,532 +1,532 @@
-
-
-
- Genesis
- bir şey arayın veya bir web bağlantısı yazın
- sayfada bul
- arama motoru
- https://genesis.onion
- opps! bir şeyler ters gitti
- herşey
- Genesis search engine
- dijital özgürlük
- Tekrar yükle
- aşağıdaki problemlerden biriyle karşı karşıyasınız. web sayfası veya web sitesi çalışmıyor olabilir. İnternet bağlantınız zayıf olabilir. bir proxy kullanıyor olabilirsiniz. web sitesi güvenlik duvarı tarafından engelleniyor olabilir
- com.darkweb.genesissearchengine.production.provider
- BBC | İsrail Yeniden Grevde
-
-
- Tarayıcı önbelleğini sil
- Taranan web sitesini sil
- Verilerinizi silin ve tarayıcıyı açın
- Tarayıcı önbelleğini sil
- Genesis tarayıcısını yeniden başlatın
- Tarayıcınızı Yeniden Başlatın
-
-
- Yer İşaretini Düzenle
- Yer İşareti Adı
- İşaretli URL\'nin adı burada gösterilecek
- Yer imi adını girin…
-
-
- Reddet
-
-
- "Bazen Tor ağına ulaşmak için bir Köprü gerekir"
- "BANA DAHA FAZLA ANLAT"
- "Merhaba"
- "Mobilde Genesis\'e hoş geldiniz."
- "İnternette güvenli ve güvenli bir şekilde gezinin."
- "İzleme yok. Sansür yok."
-
-
- Bağlantı güvenli
- Bilgileriniz (örneğin, şifre veya kredi kartı numaraları) bu siteye gönderildiğinde güvendedir
- Güvenlik Ayarı
- Javascript
- Kimliğinizi güvende tutun ve aşağıdaki seçenekleri kullanın
- Takip Etme
- Sitelere sizi izlememelerini söyleyeceğiz
- İzleme Koruması
- Tarafımızdan sağlanan izleme korumasını etkinleştirin
- Sertifika
-
-
- Sertifika Bilgisi
-
-
- proxy günlükleri
- Sistem Günlüğü bilgisi
- Genesis\'e başlarken bağlantı sorunu yaşıyorsanız, lütfen aşağıdaki kodu kopyalayın ve çevrimiçi sorunu bulun veya bize gönderin, böylece size yardımcı olmaya çalışabiliriz
- ~ Genesis on standby at the moment
-
-
- proxy özelleştirmek
- Sizi dünya çapında binlerce gönüllünün yönettiği Tor ağına bağlıyoruz! Bu seçenekler size yardımcı olabilir mi
- İnternet burada sansürlenir (güvenlik duvarını atlayın)
- güvenlik duvarını atla
- Bridges internetin çok yavaş çalışmasına neden olur. bunları yalnızca ülkenizde internet sansürlenmişse veya Tor ağı engellenmişse kullanın
- güvenlik özelleştir
-
-
- Güvenlik Ayarları
- "BRIDGE" Ayarlarını Değiştir
- Otomatik Olarak Oluştur
- "KÖPRÜ" ayarlarını otomatik olarak yapılandır
- Bildiğim bir "BRIDGE" sağlayın
- Özel "BRIDGE" yapıştır
- Proxy Settings | Bridge
- "BRIDGE", Tor ağına yapılan bağlantıları engellemeyi zorlaştıran, listelenmemiş Tor röleleridir. Bazı ülkelerin Tor\'u engellemeye çalışması nedeniyle, bazı "BRIDGE" bazı ülkelerde çalışır, ancak bazılarında çalışmaz
- Varsayılan "BRIDGE"yü Seç
- Talep
- obfs4 (Önerilen)
- Meek-masmavi (Çin)
-
-
- bildiğiniz bir Bridge sağlayın
- güvenilir bir kaynaktan bridge bilgi girin
- istek
-
-
- Sistem Günlüğünün görünme şeklini değiştirin
- modern liste görünümünü kullanarak Günlüğü göster
- klasik ve modern liste görünümü arasında geçiş yap
-
-
- Yer işareti kaldırıldı
- Yer imi güncellendi
- Veriler başarıyla temizlendi
- URL Panoya kopyalandı
- Uygulama bulunamadı
- Değişikliklerden sonra yeniden başlatma gerekli
- Yeniden Başlat
- Sekme Kapalı
- Yeni sekme açıldı
- Genesis proxy bağlanıyor...
- Bellek dolu ➔ Sekme temizleniyor
- Pop-up engellendi
- Hata Günlüklerini Aç
- Anahtar
- Geri al
- Yeni kimlik oluşturuldu
- ayarları aç
-
-
- BUNU DUYDUĞUM İÇİN ÜZGÜNÜM
- Bu uygulamayı kullanırken zorluk yaşıyorsanız, lütfen bize e-posta yoluyla ulaşın. Sorununuzu en kısa sürede çözmeye çalışacağız
-
-
- SORUN GİDERME
- Çalışmıyorsa, uygulamayı sıfırlayın. Yeniden çalışabilmesi için yeniden yapılandırmayı deneyeceğiz.
- Sıfırla
- Kapat
-
-
- İndirmek için bekleniyor...
- İndir
-
-
- ABD\'yi Değerlendir
- Başkalarına bu uygulama hakkında ne düşündüğünüzü söyleyin
- Puan
-
-
- Bitti
- Bridge dize (obfs4 212.21.66.66:20621 ...)
- Bridge tipi (obfs4, meek, ...)
-
-
- Yer İşareti Web Sitesi
- Bu sayfayı yer imlerinize ekleyin
- yer imi adı...
- Bitti
-
-
- URL Bildirimi
- Yeni Sekmede Aç
- Geçerli Sekmede Aç
- Panoya Kopyala
- Dosyayı İndir
-
-
- URL\'yi yeni sekmede aç
- URL\'yi geçerli sekmede aç
- URL\'yi panoya kopyala
- Resmi yeni sekmede aç
- Görüntü geçerli sekmesini aç
- Resmi panoya kopyala
- Resim dosyasını indirin
-
-
- Yeni Bridge Talebi
- REQUEST Bridge
- Bridge adresi istemek için aşağıdaki E-posta\'yı seçin. Bir adresiniz olduğunda, kopyalayıp yukarıdaki kutuya yapıştırın ve uygulamayı başlatın.
- Posta
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ru
- Sistem ayarı
- Genesis\'i varsayılan tarayıcınız yapın
- Sistem ayarı
- arama motoru
- javascript
- taranan web bağlantılarını kaldır
- yazı tipi özelleştirmek
- Sistem Yazı Tipi Konstomizasyonu
- yazı tipini otomatik olarak değiştir
- Çerez Ayarı
- kurabiye
- Sistem ayarı . Bildirim
- bildirimler
- bildirim tercihlerini değiştir
- ağ durumu ve bildirim
- yerel bildirimler
- Yazılım bildirimini özelleştirin
- sistem bildirimleri
- arama motorunu yönet
- ekle, varsayılan ayarla. Önerileri göster
- bildirimleri yönet
- yeni özellikler, ağ durumu
- Yazılımı Özelleştirin. Arama motoru
- desteklenen arama motorları
- Varsayılan arama motorunu seçin
- Yazılımı Özelleştirin. Arama motoru
- Web Aramalarının nasıl göründüğünü değiştirin
- default
- Genesis
- DuckDuckGo
- Google
- Bing
- Wikipedia
- taranan web bağlantılarını göster
- arama sırasında önerileri göster
- arama çubuğuna yazdığınızda göz atılan web bağlantılarından öneriler görüntülenir
- arama çubuğuna yazdığınızda odaklanmış öneriler görünür
- ulaşılabilirlik
- metin boyutu, yakınlaştırma, ses kullanarak giriş
- özelleştir | ulaşılabilirlik
- özel verileri temizle
- sekmeler, göz atılan web bağlantıları, yer imi, tanımlama bilgileri, önbellek
- Sistem Ayarını Değiştirin. Sistem Verilerini Temizle
- net veriler
- tüm sekmeleri sil
- taranan web bağlantılarını sil
- yer imlerini sil
- önbelleği sil
- önerileri sil
- verileri sil
- oturumu sil
- çerezleri sil
- sil özelleştir
- yazı tipi ölçekleme
- web içeriğini sistem yazı tipi boyutuna göre ölçeklendirin
- yakınlaştırmayı aç
- tüm web sayfaları için aç ve yakınlaştırmaya zorla
- ses kullanarak giriş
- url çubuğunda ses dikte etmeye izin ver
- özel yazı tipi ölçeklemeyi seçin
- bunu rahatça okuyana kadar kaydırıcıyı sürükleyin. metin bir paragrafa iki kez dokunduktan sonra en az bu kadar büyük görünmelidir
- 200%
- etkileşimler
- web sitesi içeriğiyle etkileşim şeklini değiştirmek
- Kullanıcı Açık
- kullanıcı gözetimi, girişler, veri seçenekleri
- Kullanıcı Gözetim Koruması
- adblock, izleyiciler, parmak izi
- Sistem ayarı . gizlilik
- Sistem ayarı . kullanıcı sürekliliği koruması
- çevrimiçi kimliğinizi koruyun
- kimliğinizi gizli tutun. Sizi çevrimiçi olarak takip eden birkaç izleyiciden koruyabiliriz. bu Sistem Ayarı, reklamı engellemek için de kullanılabilir
- kendinizi kullanıcı Survelance Protection\'dan kurtarın
- Genesis sitelere beni izlememelerini söyleyecek
- web sitesine beni takip etmemesini söyle
- Kullanıcı Gözetim Koruması
- Genesis tarafından sağlanan kullanıcı Survelance Protection\'ı etkinleştirin
- web sitesi çerezleri
- güvenlik ihtiyaçlarınıza göre web sitesi çerez tercihlerini seçin
- çıkışta özel verileri temizle
- yazılım kapatıldığında verileri otomatik olarak temizleyin
- özel Tarama
- kimliğinizi güvende tutun ve aşağıdaki seçenekleri kullanın
- etkinleştirildi
- etkinleştirildi, web sitesi izleme çerezleri hariç
- etkinleştirildi, 3. taraf hariç
- engelli
-
- korumayı devre dışı bırak
- kimlik Gözetleme Korumasına izin verin. bu çevrimiçi kimliğinizin çalınmasına neden olabilir
- varsayılan (önerilir)
- çevrimiçi reklamı ve sosyal web kullanıcısı Survelance\'ı engelleyin. sayfalar varsayılan olarak yüklenecek
- sıkı politika
- bilinen tüm izleyicileri durdurun, sayfalar daha hızlı yüklenecek ancak bazı işlevler çalışmayabilir
-
- javascript
- çeşitli komut dosyası saldırıları için java komut dosyasını devre dışı bırakın
- Sistem ayarı . karmaşık Sistem Ayarı
- sekmeleri geri yükle
- tarayıcıdan çıktıktan sonra geri yükleme
- araç çubuğu teması
- web sitesinde tanımlandığı gibi araç çubuğu temasını ayarla
- Resimleri göster
- her zaman web sitesi resimlerini yükle
- web yazı tiplerini göster
- bir sayfayı yüklerken uzak yazı tiplerini indirin
- otomatik oynatmaya izin ver
- medyanın otomatik olarak başlamasına izin ver
- veri koruyucu
- sekme
- yazılımı yeniden başlattıktan sonra sekmenin nasıl davranacağını değiştirin
- medya
- varsayılan veri koruyucuyu değiştir özelleştir
- varsayılan medyayı değiştir özelleştir
- her zaman resimleri göster
- resimleri yalnızca kablosuz bağlantı kullanırken göster
- tüm resimleri engelle
- Gelişmiş Sistem Ayarı
- sekmeleri geri yükle, veri tasarrufu, geliştirici araçları
- onion vekalet koşulu
- onion ağ durumunu kontrol et
- web sitesini bildir
- kötüye kullanılan web sitesini bildir
- bu uygulamayı oyla
- Play Store\'da oy verin ve yorum yapın
- bu uygulamayı paylaş
- bu yazılımı arkadaşlarınızla paylaşın
- Sistem ayarı . genel özelleştirme
- Varsayılan Sistem Ayarı
- ana sayfa, dil
- tam ekran tarama
- bir sayfayı aşağı kaydırırken tarayıcı araç çubuğunu gizle
- dil
- tarayıcınızın dilini değiştirin
- yazılım teması
- parlak ve koyu tema seçin
- tema parlak
- tema Koyu
- tam ekran taramayı ve dili değiştir
- sistem varsayılanı
- anasayfa
- about:blank
- yeni sekme
- ana sayfayı yeni sekmede aç
- tüm sekmeleri kaldır
- taranan web bağlantılarını kaldır
- yer imlerini kaldır
- göz atma önbelleğini kaldır
- önerileri kaldır
- site verilerini kaldır
- oturum verilerini kaldır
- web tarama çerezlerini kaldır
- tarayıcı özelleştirmesini kaldır
-
-
-
- yer imi web sitesi
- taranan web bağlantılarını ve Verileri sil
- yer imini ve Verileri temizle
- verileri temizlemek, göz atılan web bağlantılarını, çerezleri ve diğer tarama verilerini kaldırır
- verilerin silinmesi, yer imi eklenmiş web sitelerinin silinmesine neden olur
- iptal etmek
- https://
- bildiri
- web sitesini bildir
- Bu URL\'nin yasa dışı veya rahatsız edici olduğunu düşünüyorsanız, bize bildirin, böylece yasal işlem yapabiliriz
- başarıyla rapor edildi
- url başarıyla rapor edildi. bir şey bulunursa yasal işlem yapılacaktır
- dil desteklenmiyor
- sistem dili bu yazılım tarafından desteklenmemektedir. yakında dahil etmek için çalışıyoruz
- Orbot başlatılıyor
- eylem desteklenmiyor
- aşağıdaki komutu işleyecek herhangi bir yazılım bulunamadı
- hoşgeldiniz | gizli web Gateway
- bu yazılım size gizli web adreslerini aramak ve açmak için bir platform sağlar. işte birkaç öneri \n
- gizli web çevrimiçi pazarı
- sızdırılmış belgeler ve kitaplar
- karanlık web haberleri ve makaleler
- gizli yazılımlar ve bilgisayar korsanlığı araçları
- bir daha gösterme
- finans ve para
- sosyal toplumlar
- Manuel
- oyun mağazası
- dosya bildirimi
- indirme bildirimi
- indirme bildirimi
- web bağlantısı bildirimi
-
- e-postayı işleyecek yazılım bulunamadı
- dosya indirme |
- veriler temizlendi | yeniden başlatma gerekiyor
-
-
-
-
-
-
- Orbot günlükler
- yeni sekmeler
- sekmeyi kapat
- son sekmeleri aç
- dil
- İndirilenler
- taranan web bağlantıları
- Sistem ayarı
- masaüstü sitesi
- bu sayfayı kaydet
- yer imleri
- web sitesini bildir
- bu uygulamayı oyla
- sayfada bul
- çıkış
- Paylaş
-
-
- yeni sekmeler
- tüm sekmeleri kapat
- Sistem ayarı
- sekmeleri seç
-
-
- açık sekmeler
- kopya
- Paylaş
- seçimi temizle
- mevcut sekmede aç
- yeni sekmede aç
- sil
-
-
- taranan web bağlantıları
- Bunu kaldır
- arama ...
-
-
- yer imi
- Bunu kaldır
- arama ...
-
-
- yeniden dene
- opps! ağ bağlantısı hatası. ağ bağlı değil
- yardım ve Destek
-
-
- dil
- Dili değiştir
- sadece aşağıdaki dillerde çalışıyoruz. yakında daha fazlasını ekleyeceğiz
- ingilizce (amerika birleşik devletleri)
- alman (almanya)
- italyanca (italya)
- Portekiz Brezilyası)
- rusça (rusya)
- ukraynaca (ukrayna)
- basitleştirilmiş çince (anakara çin)
-
-
- ⚠️ uyarı
- Bridges\'ü özelleştir
- Bridges\'ü etkinleştir
- VPN serisini etkinleştir
- Bridge Gateway\'ü etkinleştir
- Gateway\'ü etkinleştir
-
-
- vekaletname durumu
- orbot vekilinin mevcut durumu
- Orbot vekalet koşulu
- onion
- VPN bağlantı durumu
- Bridge vekalet koşulu
- bilgi | Sistem Ayarını değiştir
- yazılımı yeniden başlatıp proxy yöneticisine giderek proxy\'yi değiştirebilirsiniz. alttaki dişli çark simgesine tıklayarak açılabilir
-
-
-
-
- default.jpg
- bunu aç
-
-
- 1
- connect
- Genesis is paused at the moment
- açık sekmeler burada gösterilecek
-
-
- bu siteye ulaşılamıyor
- web sitesine bağlanırken bir hata oluştu
- görüntülemeye çalıştığınız sayfa, alınan verilerin gerçekliği doğrulanamadığı için gösterilemiyor
- sayfa şu anda bir nedenden dolayı çalışmıyor
- Bu sorunu bildirmek için lütfen web sitesi sahipleriyle iletişime geçin.
- Tekrar yükle
-
- pref_language
- Geçersiz paket imzası
- oturum açmak için tıklayın.
- verileri manuel olarak seçmek için tıklayın.
- Web alanı güvenlik istisnası.
- DAL doğrulama hatası.
-
- Son sekmeler
- Yeni kimlik
- Gizlilik Politikası
- Genesis Browser gizlilik ilkesi
- Web sitesini bildir
- Yasadışı web sitesini bildirin
- web sitenizi yayınlayın
- Web sitenizi arama motorumuza ekleyin
-
-
-
-
-
- - Yüzde 55
- - Yüzde 70
- - Yüzde 85
- - Yüzde 100
- - Yüzde 115
- - Yüzde 130
- - Yüzde 145
-
-
-
- - Etkin
- - Devre dışı
-
-
-
- - Hepsini etkinleştir
- - Hepsini etkisiz hale getir
- - Bant Genişliği Yok
-
-
-
- - Hepsine izin ver
- - Güvenilir\'e İzin Ver
- - Hiçbirine İzin Verme
- - Ziyaret Edilmesine İzin Ver
- - İzleyici Olmayanlara İzin Ver
-
-
-
-
+
+
+
+ Genesis
+ bir şey arayın veya bir web bağlantısı yazın
+ sayfada bul
+ arama motoru
+ https://genesis.onion
+ opps! bir şeyler ters gitti
+ herşey
+ Genesis search engine
+ dijital özgürlük
+ Tekrar yükle
+ aşağıdaki problemlerden biriyle karşı karşıyasınız. web sayfası veya web sitesi çalışmıyor olabilir. İnternet bağlantınız zayıf olabilir. bir proxy kullanıyor olabilirsiniz. web sitesi güvenlik duvarı tarafından engelleniyor olabilir
+ com.hiddenservices.genesissearchengine.production.provider
+ BBC | İsrail Yeniden Grevde
+
+
+ Tarayıcı önbelleğini sil
+ Taranan web sitesini sil
+ Verilerinizi silin ve tarayıcıyı açın
+ Tarayıcı önbelleğini sil
+ Genesis tarayıcısını yeniden başlatın
+ Tarayıcınızı Yeniden Başlatın
+
+
+ Yer İşaretini Düzenle
+ Yer İşareti Adı
+ İşaretli URL\'nin adı burada gösterilecek
+ Yer imi adını girin…
+
+
+ Reddet
+
+
+ "Bazen Tor ağına ulaşmak için bir Köprü gerekir"
+ "BANA DAHA FAZLA ANLAT"
+ "Merhaba"
+ "Mobilde Genesis\'e hoş geldiniz."
+ "İnternette güvenli ve güvenli bir şekilde gezinin."
+ "İzleme yok. Sansür yok."
+
+
+ Bağlantı güvenli
+ Bilgileriniz (örneğin, şifre veya kredi kartı numaraları) bu siteye gönderildiğinde güvendedir
+ Güvenlik Ayarı
+ Javascript
+ Kimliğinizi güvende tutun ve aşağıdaki seçenekleri kullanın
+ Takip Etme
+ Sitelere sizi izlememelerini söyleyeceğiz
+ İzleme Koruması
+ Tarafımızdan sağlanan izleme korumasını etkinleştirin
+ Sertifika
+
+
+ Sertifika Bilgisi
+
+
+ proxy günlükleri
+ Sistem Günlüğü bilgisi
+ Genesis\'e başlarken bağlantı sorunu yaşıyorsanız, lütfen aşağıdaki kodu kopyalayın ve çevrimiçi sorunu bulun veya bize gönderin, böylece size yardımcı olmaya çalışabiliriz
+ ~ Genesis on standby at the moment
+
+
+ proxy özelleştirmek
+ Sizi dünya çapında binlerce gönüllünün yönettiği Tor ağına bağlıyoruz! Bu seçenekler size yardımcı olabilir mi
+ İnternet burada sansürlenir (güvenlik duvarını atlayın)
+ güvenlik duvarını atla
+ Bridges internetin çok yavaş çalışmasına neden olur. bunları yalnızca ülkenizde internet sansürlenmişse veya Tor ağı engellenmişse kullanın
+ güvenlik özelleştir
+
+
+ Güvenlik Ayarları
+ "BRIDGE" Ayarlarını Değiştir
+ Otomatik Olarak Oluştur
+ "KÖPRÜ" ayarlarını otomatik olarak yapılandır
+ Bildiğim bir "BRIDGE" sağlayın
+ Özel "BRIDGE" yapıştır
+ Proxy Settings | Bridge
+ "BRIDGE", Tor ağına yapılan bağlantıları engellemeyi zorlaştıran, listelenmemiş Tor röleleridir. Bazı ülkelerin Tor\'u engellemeye çalışması nedeniyle, bazı "BRIDGE" bazı ülkelerde çalışır, ancak bazılarında çalışmaz
+ Varsayılan "BRIDGE"yü Seç
+ Talep
+ obfs4 (Önerilen)
+ Meek-masmavi (Çin)
+
+
+ bildiğiniz bir Bridge sağlayın
+ güvenilir bir kaynaktan bridge bilgi girin
+ istek
+
+
+ Sistem Günlüğünün görünme şeklini değiştirin
+ modern liste görünümünü kullanarak Günlüğü göster
+ klasik ve modern liste görünümü arasında geçiş yap
+
+
+ Yer işareti kaldırıldı
+ Yer imi güncellendi
+ Veriler başarıyla temizlendi
+ URL Panoya kopyalandı
+ Uygulama bulunamadı
+ Değişikliklerden sonra yeniden başlatma gerekli
+ Yeniden Başlat
+ Sekme Kapalı
+ Yeni sekme açıldı
+ Genesis proxy bağlanıyor...
+ Bellek dolu ➔ Sekme temizleniyor
+ Pop-up engellendi
+ Hata Günlüklerini Aç
+ Anahtar
+ Geri al
+ Yeni kimlik oluşturuldu
+ ayarları aç
+
+
+ BUNU DUYDUĞUM İÇİN ÜZGÜNÜM
+ Bu uygulamayı kullanırken zorluk yaşıyorsanız, lütfen bize e-posta yoluyla ulaşın. Sorununuzu en kısa sürede çözmeye çalışacağız
+
+
+ SORUN GİDERME
+ Çalışmıyorsa, uygulamayı sıfırlayın. Yeniden çalışabilmesi için yeniden yapılandırmayı deneyeceğiz.
+ Sıfırla
+ Kapat
+
+
+ İndirmek için bekleniyor...
+ İndir
+
+
+ ABD\'yi Değerlendir
+ Başkalarına bu uygulama hakkında ne düşündüğünüzü söyleyin
+ Puan
+
+
+ Bitti
+ Bridge dize (obfs4 212.21.66.66:20621 ...)
+ Bridge tipi (obfs4, meek, ...)
+
+
+ Yer İşareti Web Sitesi
+ Bu sayfayı yer imlerinize ekleyin
+ yer imi adı...
+ Bitti
+
+
+ URL Bildirimi
+ Yeni Sekmede Aç
+ Geçerli Sekmede Aç
+ Panoya Kopyala
+ Dosyayı İndir
+
+
+ URL\'yi yeni sekmede aç
+ URL\'yi geçerli sekmede aç
+ URL\'yi panoya kopyala
+ Resmi yeni sekmede aç
+ Görüntü geçerli sekmesini aç
+ Resmi panoya kopyala
+ Resim dosyasını indirin
+
+
+ Yeni Bridge Talebi
+ REQUEST Bridge
+ Bridge adresi istemek için aşağıdaki E-posta\'yı seçin. Bir adresiniz olduğunda, kopyalayıp yukarıdaki kutuya yapıştırın ve uygulamayı başlatın.
+ Posta
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ru
+ Sistem ayarı
+ Genesis\'i varsayılan tarayıcınız yapın
+ Sistem ayarı
+ arama motoru
+ javascript
+ taranan web bağlantılarını kaldır
+ yazı tipi özelleştirmek
+ Sistem Yazı Tipi Konstomizasyonu
+ yazı tipini otomatik olarak değiştir
+ Çerez Ayarı
+ kurabiye
+ Sistem ayarı . Bildirim
+ bildirimler
+ bildirim tercihlerini değiştir
+ ağ durumu ve bildirim
+ yerel bildirimler
+ Yazılım bildirimini özelleştirin
+ sistem bildirimleri
+ arama motorunu yönet
+ ekle, varsayılan ayarla. Önerileri göster
+ bildirimleri yönet
+ yeni özellikler, ağ durumu
+ Yazılımı Özelleştirin. Arama motoru
+ desteklenen arama motorları
+ Varsayılan arama motorunu seçin
+ Yazılımı Özelleştirin. Arama motoru
+ Web Aramalarının nasıl göründüğünü değiştirin
+ default
+ Genesis
+ DuckDuckGo
+ Google
+ Bing
+ Wikipedia
+ taranan web bağlantılarını göster
+ arama sırasında önerileri göster
+ arama çubuğuna yazdığınızda göz atılan web bağlantılarından öneriler görüntülenir
+ arama çubuğuna yazdığınızda odaklanmış öneriler görünür
+ ulaşılabilirlik
+ metin boyutu, yakınlaştırma, ses kullanarak giriş
+ özelleştir | ulaşılabilirlik
+ özel verileri temizle
+ sekmeler, göz atılan web bağlantıları, yer imi, tanımlama bilgileri, önbellek
+ Sistem Ayarını Değiştirin. Sistem Verilerini Temizle
+ net veriler
+ tüm sekmeleri sil
+ taranan web bağlantılarını sil
+ yer imlerini sil
+ önbelleği sil
+ önerileri sil
+ verileri sil
+ oturumu sil
+ çerezleri sil
+ sil özelleştir
+ yazı tipi ölçekleme
+ web içeriğini sistem yazı tipi boyutuna göre ölçeklendirin
+ yakınlaştırmayı aç
+ tüm web sayfaları için aç ve yakınlaştırmaya zorla
+ ses kullanarak giriş
+ url çubuğunda ses dikte etmeye izin ver
+ özel yazı tipi ölçeklemeyi seçin
+ bunu rahatça okuyana kadar kaydırıcıyı sürükleyin. metin bir paragrafa iki kez dokunduktan sonra en az bu kadar büyük görünmelidir
+ 200%
+ etkileşimler
+ web sitesi içeriğiyle etkileşim şeklini değiştirmek
+ Kullanıcı Açık
+ kullanıcı gözetimi, girişler, veri seçenekleri
+ Kullanıcı Gözetim Koruması
+ adblock, izleyiciler, parmak izi
+ Sistem ayarı . gizlilik
+ Sistem ayarı . kullanıcı sürekliliği koruması
+ çevrimiçi kimliğinizi koruyun
+ kimliğinizi gizli tutun. Sizi çevrimiçi olarak takip eden birkaç izleyiciden koruyabiliriz. bu Sistem Ayarı, reklamı engellemek için de kullanılabilir
+ kendinizi kullanıcı Survelance Protection\'dan kurtarın
+ Genesis sitelere beni izlememelerini söyleyecek
+ web sitesine beni takip etmemesini söyle
+ Kullanıcı Gözetim Koruması
+ Genesis tarafından sağlanan kullanıcı Survelance Protection\'ı etkinleştirin
+ web sitesi çerezleri
+ güvenlik ihtiyaçlarınıza göre web sitesi çerez tercihlerini seçin
+ çıkışta özel verileri temizle
+ yazılım kapatıldığında verileri otomatik olarak temizleyin
+ özel Tarama
+ kimliğinizi güvende tutun ve aşağıdaki seçenekleri kullanın
+ etkinleştirildi
+ etkinleştirildi, web sitesi izleme çerezleri hariç
+ etkinleştirildi, 3. taraf hariç
+ engelli
+
+ korumayı devre dışı bırak
+ kimlik Gözetleme Korumasına izin verin. bu çevrimiçi kimliğinizin çalınmasına neden olabilir
+ varsayılan (önerilir)
+ çevrimiçi reklamı ve sosyal web kullanıcısı Survelance\'ı engelleyin. sayfalar varsayılan olarak yüklenecek
+ sıkı politika
+ bilinen tüm izleyicileri durdurun, sayfalar daha hızlı yüklenecek ancak bazı işlevler çalışmayabilir
+
+ javascript
+ çeşitli komut dosyası saldırıları için java komut dosyasını devre dışı bırakın
+ Sistem ayarı . karmaşık Sistem Ayarı
+ sekmeleri geri yükle
+ tarayıcıdan çıktıktan sonra geri yükleme
+ araç çubuğu teması
+ web sitesinde tanımlandığı gibi araç çubuğu temasını ayarla
+ Resimleri göster
+ her zaman web sitesi resimlerini yükle
+ web yazı tiplerini göster
+ bir sayfayı yüklerken uzak yazı tiplerini indirin
+ otomatik oynatmaya izin ver
+ medyanın otomatik olarak başlamasına izin ver
+ veri koruyucu
+ sekme
+ yazılımı yeniden başlattıktan sonra sekmenin nasıl davranacağını değiştirin
+ medya
+ varsayılan veri koruyucuyu değiştir özelleştir
+ varsayılan medyayı değiştir özelleştir
+ her zaman resimleri göster
+ resimleri yalnızca kablosuz bağlantı kullanırken göster
+ tüm resimleri engelle
+ Gelişmiş Sistem Ayarı
+ sekmeleri geri yükle, veri tasarrufu, geliştirici araçları
+ onion vekalet koşulu
+ onion ağ durumunu kontrol et
+ web sitesini bildir
+ kötüye kullanılan web sitesini bildir
+ bu uygulamayı oyla
+ Play Store\'da oy verin ve yorum yapın
+ bu uygulamayı paylaş
+ bu yazılımı arkadaşlarınızla paylaşın
+ Sistem ayarı . genel özelleştirme
+ Varsayılan Sistem Ayarı
+ ana sayfa, dil
+ tam ekran tarama
+ bir sayfayı aşağı kaydırırken tarayıcı araç çubuğunu gizle
+ dil
+ tarayıcınızın dilini değiştirin
+ yazılım teması
+ parlak ve koyu tema seçin
+ tema parlak
+ tema Koyu
+ tam ekran taramayı ve dili değiştir
+ sistem varsayılanı
+ anasayfa
+ about:blank
+ yeni sekme
+ ana sayfayı yeni sekmede aç
+ tüm sekmeleri kaldır
+ taranan web bağlantılarını kaldır
+ yer imlerini kaldır
+ göz atma önbelleğini kaldır
+ önerileri kaldır
+ site verilerini kaldır
+ oturum verilerini kaldır
+ web tarama çerezlerini kaldır
+ tarayıcı özelleştirmesini kaldır
+
+
+
+ yer imi web sitesi
+ taranan web bağlantılarını ve Verileri sil
+ yer imini ve Verileri temizle
+ verileri temizlemek, göz atılan web bağlantılarını, çerezleri ve diğer tarama verilerini kaldırır
+ verilerin silinmesi, yer imi eklenmiş web sitelerinin silinmesine neden olur
+ iptal etmek
+ https://
+ bildiri
+ web sitesini bildir
+ Bu URL\'nin yasa dışı veya rahatsız edici olduğunu düşünüyorsanız, bize bildirin, böylece yasal işlem yapabiliriz
+ başarıyla rapor edildi
+ url başarıyla rapor edildi. bir şey bulunursa yasal işlem yapılacaktır
+ dil desteklenmiyor
+ sistem dili bu yazılım tarafından desteklenmemektedir. yakında dahil etmek için çalışıyoruz
+ Orbot başlatılıyor
+ eylem desteklenmiyor
+ aşağıdaki komutu işleyecek herhangi bir yazılım bulunamadı
+ hoşgeldiniz | gizli web Gateway
+ bu yazılım size gizli web adreslerini aramak ve açmak için bir platform sağlar. işte birkaç öneri \n
+ gizli web çevrimiçi pazarı
+ sızdırılmış belgeler ve kitaplar
+ karanlık web haberleri ve makaleler
+ gizli yazılımlar ve bilgisayar korsanlığı araçları
+ bir daha gösterme
+ finans ve para
+ sosyal toplumlar
+ Manuel
+ oyun mağazası
+ dosya bildirimi
+ indirme bildirimi
+ indirme bildirimi
+ web bağlantısı bildirimi
+
+ e-postayı işleyecek yazılım bulunamadı
+ dosya indirme |
+ veriler temizlendi | yeniden başlatma gerekiyor
+
+
+
+
+
+
+ Orbot günlükler
+ yeni sekmeler
+ sekmeyi kapat
+ son sekmeleri aç
+ dil
+ İndirilenler
+ taranan web bağlantıları
+ Sistem ayarı
+ masaüstü sitesi
+ bu sayfayı kaydet
+ yer imleri
+ web sitesini bildir
+ bu uygulamayı oyla
+ sayfada bul
+ çıkış
+ Paylaş
+
+
+ yeni sekmeler
+ tüm sekmeleri kapat
+ Sistem ayarı
+ sekmeleri seç
+
+
+ açık sekmeler
+ kopya
+ Paylaş
+ seçimi temizle
+ mevcut sekmede aç
+ yeni sekmede aç
+ sil
+
+
+ taranan web bağlantıları
+ Bunu kaldır
+ arama ...
+
+
+ yer imi
+ Bunu kaldır
+ arama ...
+
+
+ yeniden dene
+ opps! ağ bağlantısı hatası. ağ bağlı değil
+ yardım ve Destek
+
+
+ dil
+ Dili değiştir
+ sadece aşağıdaki dillerde çalışıyoruz. yakında daha fazlasını ekleyeceğiz
+ ingilizce (amerika birleşik devletleri)
+ alman (almanya)
+ italyanca (italya)
+ Portekiz Brezilyası)
+ rusça (rusya)
+ ukraynaca (ukrayna)
+ basitleştirilmiş çince (anakara çin)
+
+
+ ⚠️ uyarı
+ Bridges\'ü özelleştir
+ Bridges\'ü etkinleştir
+ VPN serisini etkinleştir
+ Bridge Gateway\'ü etkinleştir
+ Gateway\'ü etkinleştir
+
+
+ vekaletname durumu
+ orbot vekilinin mevcut durumu
+ Orbot vekalet koşulu
+ onion
+ VPN bağlantı durumu
+ Bridge vekalet koşulu
+ bilgi | Sistem Ayarını değiştir
+ yazılımı yeniden başlatıp proxy yöneticisine giderek proxy\'yi değiştirebilirsiniz. alttaki dişli çark simgesine tıklayarak açılabilir
+
+
+
+
+ default.jpg
+ bunu aç
+
+
+ 1
+ connect
+ Genesis is paused at the moment
+ açık sekmeler burada gösterilecek
+
+
+ bu siteye ulaşılamıyor
+ web sitesine bağlanırken bir hata oluştu
+ görüntülemeye çalıştığınız sayfa, alınan verilerin gerçekliği doğrulanamadığı için gösterilemiyor
+ sayfa şu anda bir nedenden dolayı çalışmıyor
+ Bu sorunu bildirmek için lütfen web sitesi sahipleriyle iletişime geçin.
+ Tekrar yükle
+
+ pref_language
+ Geçersiz paket imzası
+ oturum açmak için tıklayın.
+ verileri manuel olarak seçmek için tıklayın.
+ Web alanı güvenlik istisnası.
+ DAL doğrulama hatası.
+
+ Son sekmeler
+ Yeni kimlik
+ Gizlilik Politikası
+ Genesis Browser gizlilik ilkesi
+ Web sitesini bildir
+ Yasadışı web sitesini bildirin
+ web sitenizi yayınlayın
+ Web sitenizi arama motorumuza ekleyin
+
+
+
+
+
+ - Yüzde 55
+ - Yüzde 70
+ - Yüzde 85
+ - Yüzde 100
+ - Yüzde 115
+ - Yüzde 130
+ - Yüzde 145
+
+
+
+ - Etkin
+ - Devre dışı
+
+
+
+ - Hepsini etkinleştir
+ - Hepsini etkisiz hale getir
+ - Bant Genişliği Yok
+
+
+
+ - Hepsine izin ver
+ - Güvenilir\'e İzin Ver
+ - Hiçbirine İzin Verme
+ - Ziyaret Edilmesine İzin Ver
+ - İzleyici Olmayanlara İzin Ver
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-ur/strings.xml b/app/src/main/res/values-ur/strings.xml
index 14ec5543..e9e0a145 100644
--- a/app/src/main/res/values-ur/strings.xml
+++ b/app/src/main/res/values-ur/strings.xml
@@ -12,7 +12,7 @@
ڈیجیٹل آزادی
دوبارہ لوڈ کریں
آپ کو مندرجہ ذیل میں سے ایک مسئلہ درپیش ہے۔ ہوسکتا ہے کہ ویب صفحہ یا ویب سائٹ کام نہیں کررہی ہے۔ ہوسکتا ہے کہ آپ کا انٹرنیٹ کنیکشن خراب ہو۔ آپ شاید ایک پراکسی استعمال کر رہے ہوں گے۔ ہوسکتا ہے کہ ویب سائٹ فائر وال کے ذریعے مسدود کردی جائے
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
بی بی سی | اسرائیل نے ایک بار پھر حملہ کیا
diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml
index 43fee984..c5eedcad 100644
--- a/app/src/main/res/values-vi/strings.xml
+++ b/app/src/main/res/values-vi/strings.xml
@@ -1,532 +1,532 @@
-
-
-
- Genesis
- tìm kiếm thứ gì đó hoặc nhập một liên kết web
- Tìm ở trang
- máy tìm kiếm
- https://genesis.onion
- opps! có gì đó không ổn
- mọi điều
- Genesis search engine
- tự do kỹ thuật số
- tải lại
- bạn đang phải đối mặt với một trong những vấn đề sau. trang web hoặc trang web có thể không hoạt động. kết nối internet của bạn có thể kém. bạn có thể đang sử dụng proxy. trang web có thể bị tường lửa chặn
- com.darkweb.genesissearchengine.production.provider
- BBC | Israel lại tấn công
-
-
- Xóa bộ nhớ cache của trình duyệt
- Xóa trang web đã duyệt
- Xóa dữ liệu của bạn và mở trình duyệt
- Xóa bộ nhớ cache của trình duyệt
- Khởi động lại trình duyệt genesis
- Khởi động Lại Trình Duyệt Của Bạn
-
-
- Chỉnh Sửa Dấu Trang
- Tên Dấu Trang
- Tên của url được đánh dấu sẽ được hiển thị ở đây
- Nhập tên dấu trang…
-
-
- bỏ qua
-
-
- "Đôi khi bạn cần một Cầu nối để truy cập Mạng Tor"
- "NÓI CHO TÔI THÊM"
- "Xin chào"
- "Chào mừng bạn đến với Genesis trên điện thoại di động."
- "Duyệt Internet một cách an toàn và bảo mật."
- "Không theo dõi. Không kiểm duyệt."
-
-
- Kết nối an toàn
- Thông tin của bạn (ví dụ: mật khẩu hoặc số thẻ tín dụng) được bảo mật khi nó được gửi đến trang web này
- Cài đặt Bảo Mật
- Javascript
- Giữ an toàn cho danh tính của bạn và sử dụng các tùy chọn bên dưới
- Không Theo Dõi
- Chúng tôi sẽ thông báo cho các trang web không theo dõi bạn
- Bảo Vệ Theo Dõi
- Bật tính năng bảo vệ theo dõi do chúng tôi cung cấp
- Giấy chứng nhận
-
-
- Thông Tin Chứng Chỉ
-
-
- nhật ký proxy
- Thông tin nhật ký hệ thống
- nếu bạn gặp sự cố kết nối khi khởi động Genesis, vui lòng sao chép mã sau và tìm sự cố trực tuyến hoặc gửi cho chúng tôi, để chúng tôi có thể cố gắng giúp bạn
- ~ Genesis on standby at the moment
-
-
- tùy chỉnh proxy
- chúng tôi kết nối bạn với mạng Tor do hàng nghìn tình nguyện viên trên khắp thế giới điều hành! Những tùy chọn này có thể giúp bạn không
- Internet được kiểm duyệt ở đây (vượt tường lửa)
- vượt tường lửa
- Bridges khiến Internet chạy rất chậm. chỉ sử dụng chúng nếu internet bị kiểm duyệt ở quốc gia của bạn hoặc mạng Tor bị chặn
- tùy chỉnh bảo mật
-
-
- Cài đặt Bảo Mật
- Thay đổi Cài đặt "BRIDGE"
- Tạo Tự động
- Tự động định cấu hình cài đặt "BRIDGE"
- Cung cấp một "BRIDGE" mà tôi biết
- Dán tùy chỉnh "BRIDGE"
- Proxy Settings | Bridge
- "BRIDGE" là các rơ le Tor không được liệt kê khiến việc chặn các kết nối vào mạng Tor trở nên khó khăn hơn. Vì cách một số quốc gia cố gắng chặn Tor, "BRIDGE" nhất định hoạt động ở một số quốc gia nhưng không hoạt động ở một số quốc gia khác
- Chọn Mặc định "BRIDGE"
- Yêu cầu
- obfs4 (Khuyến nghị)
- Meek-azure (Trung Quốc)
-
-
- thay đổi cách hiển thị Nhật ký hệ thống
- hiển thị Nhật ký bằng chế độ xem danh sách hiện đại
- toogle giữa chế độ xem danh sách cổ điển và hiện đại
-
-
- Đã xóa dấu trang
- Đã cập nhật dấu trang
- Đã xóa dữ liệu thành công
- URL được sao chép vào khay nhớ tạm
- Không tìm thấy ứng dụng nào
- Yêu cầu khởi động lại sau khi thay đổi
- Khởi động lại
- Tab Bị đóng
- Tab mới đã mở
- Genesis proxy kết nối ...
- Bộ nhớ đầy ➔ Xóa tab
- Cửa sổ bật lên bị chặn
- Mở Nhật Ký Lỗi
- Chuyển đổi
- Hoàn tác
- Danh tính mới được tạo
- mở cài đặt
-
-
- Yêu Cầu Mới Bridge
- REQUEST Bridge
- Chọn E-mail bên dưới để yêu cầu địa chỉ Bridge. Sau khi bạn có địa chỉ, hãy sao chép và dán nó vào ô trên và khởi động ứng dụng.
- Thư tín
-
-
- XIN LỖI KHI NGHE RỒI
- Nếu bạn gặp khó khăn khi sử dụng ứng dụng này, vui lòng liên hệ với chúng tôi qua email. Chúng tôi sẽ cố gắng giải quyết vấn đề của bạn càng sớm càng tốt
-
-
- KHẮC PHỤC SỰ CỐ
- Đặt lại ứng dụng trong trường hợp nó không hoạt động. Chúng tôi sẽ cố gắng cấu hình lại nó để nó có thể hoạt động trở lại.
- Đặt lại
- Loại bỏ
-
-
- Đang chờ tải xuống ...
- Tải xuống
-
-
- Đánh Giá US
- Cho người khác biết suy nghĩ của bạn về ứng dụng này
- Đánh giá
-
-
- Đã xong
- Bridge string (obfs4 212.21.66.66:20621 ...)
- Bridge kiểu (obfs4, meek, ...)
-
-
- Đánh Dấu Trang Web
- Thêm trang này vào dấu trang của bạn
- bookmark tên ...
- Đã xong
-
-
- Thông Báo URL
- Mở Trong Tab Mới
- Mở Trong Tab Hiện Tại
- Sao chép vào Clipboard
- Tải Xuống Tệp
-
-
- Mở url trong tab mới
- Mở url trong tab hiện tại
- Sao chép url vào khay nhớ tạm
- Mở hình ảnh trong tab mới
- Mở tab hình ảnh hiện tại
- Sao chép hình ảnh vào khay nhớ tạm
- Tải xuống tệp hình ảnh
-
-
- cung cấp một Bridge bạn biết
- nhập thông tin bridge từ một nguồn đáng tin cậy
- yêu cầu
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ru
- Thiết lập hệ thống
- đặt Genesis làm trình duyệt mặc định của bạn
- Thiết lập hệ thống
- máy tìm kiếm
- javascript
- xóa các liên kết web đã duyệt
- tùy chỉnh phông chữ
- Chòm sao Phông chữ Hệ thống
- thay đổi phông chữ tự động
- Cài đặt cookie
- bánh quy
- Thiết lập hệ thống . Thông báo
- thông báo
- thay đổi tùy chọn thông báo
- tình trạng của mạng và thông báo
- thông báo địa phương
- tùy chỉnh thông báo phần mềm
- thông báo hệ thống
- Quản lý công cụ tìm kiếm
- thêm, đặt mặc định. hiển thị đề xuất
- quản lý thông báo
- các tính năng mới, tình trạng của mạng
- Tùy chỉnh phần mềm. Máy tìm kiếm
- công cụ tìm kiếm được hỗ trợ
- chọn Công cụ tìm kiếm mặc định
- Tùy chỉnh phần mềm. Máy tìm kiếm
- thay đổi cách các Tìm kiếm trên Web xuất hiện
- default
- Genesis
- DuckDuckGo
- Google
- Bing
- Wikipedia
- hiển thị các liên kết web đã duyệt
- hiển thị các đề xuất trong quá trình tìm kiếm
- đề xuất từ các liên kết web đã duyệt xuất hiện khi bạn nhập vào thanh tìm kiếm
- đề xuất tập trung xuất hiện khi bạn nhập vào thanh tìm kiếm
- khả năng tiếp cận
- kích thước văn bản, thu phóng, nhập liệu bằng giọng nói
- tùy chỉnh | khả năng tiếp cận
- xóa dữ liệu cá nhân
- tab, liên kết web đã duyệt, dấu trang, cookie, bộ nhớ cache
- Thay đổi cài đặt hệ thống. Xóa dữ liệu hệ thống
- xóa dữ liệu
- xóa tất cả các tab
- xóa các liên kết web đã duyệt
- xóa dấu trang
- xóa bộ nhớ cache
- xóa đề xuất
- xóa dữ liệu
- xóa phiên
- xóa cookie
- xóa tùy chỉnh
- chia tỷ lệ phông chữ
- chia tỷ lệ nội dung web theo kích thước phông chữ hệ thống
- bật thu phóng
- bật và buộc thu phóng cho tất cả các trang web
- đầu vào bằng giọng nói
- cho phép đọc chính tả bằng giọng nói trong thanh url
- chọn tỷ lệ phông chữ tùy chỉnh
- kéo thanh trượt cho đến khi bạn có thể đọc thoải mái. văn bản ít nhất phải lớn như thế này sau khi nhấn đúp vào một đoạn văn
- 200%
- tương tác
- thay đổi cách tương tác với nội dung trang web
- Người dùng đang bật
- mức độ người dùng, thông tin đăng nhập, lựa chọn dữ liệu
- Bảo vệ giám sát người dùng
- adblock, trình theo dõi, lấy dấu vân tay
- Thiết lập hệ thống . riêng tư
- Thiết lập hệ thống . bảo vệ người dùng tuyệt vời
- bảo vệ danh tính trực tuyến của bạn
- giữ bí mật danh tính của bạn. chúng tôi có thể bảo vệ bạn khỏi một số trình theo dõi theo dõi bạn trực tuyến. Cài đặt Hệ thống này cũng có thể được sử dụng để chặn quảng cáo
- cứu bản thân khỏi tính năng Bảo vệ sự ngạc nhiên của người dùng
- Genesis sẽ yêu cầu các trang web không theo dõi tôi
- yêu cầu trang web không theo dõi tôi
- Bảo vệ giám sát người dùng
- kích hoạt tính năng Bảo vệ Survelance của người dùng do Genesis cung cấp
- cookie trang web
- chọn tùy chọn cookie trang web theo nhu cầu bảo mật của bạn
- xóa dữ liệu cá nhân khi thoát
- xóa dữ liệu tự động sau khi phần mềm được đóng
- duyệt web riêng tư
- giữ an toàn cho danh tính của bạn và sử dụng các tùy chọn bên dưới
- được kích hoạt
- được bật, không bao gồm cookie theo dõi trang web
- được bật, không bao gồm bên thứ 3
- tàn tật
-
- vô hiệu hóa bảo vệ
- cho phép Bảo vệ Survelance nhận dạng. điều này có thể khiến danh tính trực tuyến của bạn bị đánh cắp
- mặc định (khuyến nghị)
- chặn quảng cáo trực tuyến và người dùng web xã hội Survelance. các trang sẽ tải như mặc định
- chính sách nghiêm ngặt
- dừng tất cả các trình theo dõi đã biết, các trang sẽ tải nhanh hơn nhưng một số chức năng có thể không hoạt động
-
- javascript
- vô hiệu hóa tập lệnh java cho các cuộc tấn công tập lệnh khác nhau
- Thiết lập hệ thống . Thiết lập hệ thống phức tạp
- khôi phục các tab
- không khôi phục sau khi thoát khỏi trình duyệt
- chủ đề thanh công cụ
- đặt chủ đề thanh công cụ như được xác định trong trang web
- hiển thị hình ảnh
- luôn tải hình ảnh trang web
- hiển thị phông chữ web
- tải xuống phông chữ từ xa khi tải trang
- cho phép tự động phát
- cho phép phương tiện tự động khởi động
- trình tiết kiệm dữ liệu
- chuyển hướng
- thay đổi cách hoạt động của tab sau khi khởi động lại phần mềm
- phương tiện truyền thông
- thay đổi tùy chỉnh trình tiết kiệm dữ liệu mặc định
- thay đổi tùy chỉnh phương tiện mặc định
- luôn hiển thị hình ảnh
- chỉ hiển thị hình ảnh khi sử dụng wifi
- chặn tất cả hình ảnh
- Cài đặt hệ thống nâng cao
- khôi phục các tab, trình tiết kiệm dữ liệu, công cụ dành cho nhà phát triển
- onion điều kiện của proxy
- kiểm tra điều kiện mạng onion
- báo cáo trang web
- báo cáo trang web lạm dụng
- đánh giá ứng dụng này
- đánh giá và bình luận trên playstore
- chia sẻ ứng dụng này
- chia sẻ phần mềm này với bạn bè của bạn
- Thiết lập hệ thống . tùy chỉnh chung
- Cài đặt hệ thống mặc định
- trang chủ, ngôn ngữ
- duyệt toàn màn hình
- ẩn thanh công cụ của trình duyệt khi cuộn xuống một trang
- ngôn ngữ
- thay đổi ngôn ngữ của trình duyệt của bạn
- chủ đề phần mềm
- chọn chủ đề sáng và tối
- chủ đề tươi sáng
- chủ đề Tối
- thay đổi ngôn ngữ và duyệt toàn màn hình
- mặc định hệ thống
- trang chủ
- about:blank
- tab mới
- mở trang chủ trong tab mới
- xóa tất cả các tab
- xóa các liên kết web đã duyệt
- xóa dấu trang
- xóa bộ nhớ cache duyệt web
- loại bỏ các đề xuất
- xóa dữ liệu trang web
- xóa dữ liệu phiên
- xóa cookie duyệt web
- loại bỏ tùy chỉnh trình duyệt
-
-
- bookmark website
- xóa các liên kết web đã duyệt và Dữ liệu
- xóa dấu trang và dữ liệu
- xóa dữ liệu sẽ xóa các liên kết web đã duyệt, cookie và dữ liệu duyệt web khác
- xóa dữ liệu sẽ xóa các trang web được đánh dấu
- hủy bỏ
- https://
- báo cáo
- báo cáo trang web
- nếu bạn cho rằng URL này bất hợp pháp hoặc đáng lo ngại, hãy báo cáo cho chúng tôi để chúng tôi có thể thực hiện hành động pháp lý
- đã được báo cáo thành công
- url đã được báo cáo thành công. nếu một cái gì đó được tìm thấy, hành động pháp lý sẽ được thực hiện
- ngôn ngữ không được hỗ trợ
- ngôn ngữ hệ thống không được phần mềm này hỗ trợ. chúng tôi đang làm việc để sớm đưa nó vào
- khởi tạo Orbot
- hành động không được hỗ trợ
- không tìm thấy phần mềm nào để xử lý lệnh sau
- chào mừng | web ẩn Gateway
- phần mềm này cung cấp cho bạn một nền tảng để tìm kiếm và mở các url web ẩn. đây là một vài gợi ý \n
- thị trường trực tuyến web ẩn
- tài liệu và sách bị rò rỉ
- tin tức và bài báo trên dark web
- phần mềm bí mật và công cụ hack
- không hiển thị lại
- tài chính và tiền bạc
- xã hội xã hội
- sổ tay
- Cửa hang tro chơi
- thông báo tệp
- thông báo tải xuống
- thông báo tải xuống
- thông báo liên kết web
-
- không tìm thấy phần mềm để xử lý email
- tải tập tin |
- dữ liệu bị xóa | yêu cầu khởi động lại
-
-
-
-
-
-
- Orbot nhật ký
- tab mới
- đóng tab
- mở các tab gần đây
- ngôn ngữ
- tải xuống
- liên kết web đã duyệt
- Thiết lập hệ thống
- trang máy tính để bàn
- lưu trang này
- dấu trang
- báo cáo trang web
- đánh giá ứng dụng này
- Tìm ở trang
- lối ra
- chia sẻ
-
-
- tab mới
- đóng tất cả cửa sổ
- Thiết lập hệ thống
- chọn tab
-
-
- mở tab
- sao chép
- chia sẻ
- lựa chọn rõ ràng
- mở trong tab hiện tại
- mở trang mới
- xóa bỏ
-
-
- liên kết web đã duyệt
- tháo cái này
- Tìm kiếm ...
-
-
- dấu trang
- tháo cái này
- Tìm kiếm ...
-
-
- thử lại
- opps! lỗi kết nối mạng. mạng không kết nối
- giúp đỡ và hỗ trợ
-
-
- ngôn ngữ
- thay đổi ngôn ngữ
- chúng tôi chỉ chạy trên các ngôn ngữ sau. chúng tôi sẽ sớm bổ sung thêm
- tiếng anh (các bang thống nhất)
- đức (đức)
- tiếng Ý (italy)
- người Bồ Đào Nha (Brazil)
- nga (nga)
- ukrainian (ukraine)
- tiếng Trung giản thể (Trung Quốc đại lục)
-
-
- ⚠️ cảnh báo
- tùy chỉnh Bridges
- kích hoạt Bridges
- kích hoạt VPN serivces
- kích hoạt Bridge Gateway
- kích hoạt Gateway
-
-
- điều kiện của proxy
- tình trạng hiện tại của orbot proxy
- Orbot điều kiện của proxy
- onion
- VPN điều kiện kết nối
- Bridge điều kiện của proxy
- thông tin | thay đổi cài đặt hệ thống
- bạn có thể thay đổi proxy bằng cách khởi động lại phần mềm và chuyển đến trình quản lý proxy. nó có thể được mở bằng cách nhấp vào biểu tượng bánh răng ở dưới cùng
-
-
-
-
- default.jpg
- mở thứ này
-
-
- 1
- connect
- Genesis is paused at the moment
- các tab đang mở sẽ hiển thị ở đây
-
-
- trang web này không thể truy cập được
- đã xảy ra lỗi khi kết nối với trang web
- không thể hiển thị trang bạn đang cố xem vì không thể xác minh tính xác thực của dữ liệu đã nhận
- trang này hiện không hoạt động do một số lý do
- vui lòng liên hệ với chủ sở hữu trang web để thông báo cho họ về vấn đề này.
- tải lại
-
-
- pref_language
- Chữ ký gói không hợp lệ
- bấm để đăng nhập.
- bấm để chọn dữ liệu theo cách thủ công.
- Ngoại lệ bảo mật tên miền web.
- Không xác minh được DAL.
-
- Các tab gần đây
- Nhận dạng mới
- Chính sách bảo mật
- Genesis Browser chính sách về quyền riêng tư
- Báo cáo trang web
- Báo cáo trang web bất hợp pháp
- xuất bản trang web của bạn
- Thêm trang web của bạn vào công cụ tìm kiếm của chúng tôi
-
-
-
-
-
- - 55 Phần trăm
- - 70 Phần trăm
- - 85 Phần trăm
- - 100 phần trăm
- - 115 Phần trăm
- - 130 Phần trăm
- - 145 Phần trăm
-
-
-
- - Đã bật
- - Tàn tật
-
-
-
- - Cho phép tất cả
- - Vô hiệu hóa tất cả
- - Không có băng thông
-
-
-
- - Chấp nhận tất cả
- - Cho phép Tin cậy
- - Cho phép Không
- - Cho phép truy cập
- - Cho phép không theo dõi
-
-
-
-
+
+
+
+ Genesis
+ tìm kiếm thứ gì đó hoặc nhập một liên kết web
+ Tìm ở trang
+ máy tìm kiếm
+ https://genesis.onion
+ opps! có gì đó không ổn
+ mọi điều
+ Genesis search engine
+ tự do kỹ thuật số
+ tải lại
+ bạn đang phải đối mặt với một trong những vấn đề sau. trang web hoặc trang web có thể không hoạt động. kết nối internet của bạn có thể kém. bạn có thể đang sử dụng proxy. trang web có thể bị tường lửa chặn
+ com.hiddenservices.genesissearchengine.production.provider
+ BBC | Israel lại tấn công
+
+
+ Xóa bộ nhớ cache của trình duyệt
+ Xóa trang web đã duyệt
+ Xóa dữ liệu của bạn và mở trình duyệt
+ Xóa bộ nhớ cache của trình duyệt
+ Khởi động lại trình duyệt genesis
+ Khởi động Lại Trình Duyệt Của Bạn
+
+
+ Chỉnh Sửa Dấu Trang
+ Tên Dấu Trang
+ Tên của url được đánh dấu sẽ được hiển thị ở đây
+ Nhập tên dấu trang…
+
+
+ bỏ qua
+
+
+ "Đôi khi bạn cần một Cầu nối để truy cập Mạng Tor"
+ "NÓI CHO TÔI THÊM"
+ "Xin chào"
+ "Chào mừng bạn đến với Genesis trên điện thoại di động."
+ "Duyệt Internet một cách an toàn và bảo mật."
+ "Không theo dõi. Không kiểm duyệt."
+
+
+ Kết nối an toàn
+ Thông tin của bạn (ví dụ: mật khẩu hoặc số thẻ tín dụng) được bảo mật khi nó được gửi đến trang web này
+ Cài đặt Bảo Mật
+ Javascript
+ Giữ an toàn cho danh tính của bạn và sử dụng các tùy chọn bên dưới
+ Không Theo Dõi
+ Chúng tôi sẽ thông báo cho các trang web không theo dõi bạn
+ Bảo Vệ Theo Dõi
+ Bật tính năng bảo vệ theo dõi do chúng tôi cung cấp
+ Giấy chứng nhận
+
+
+ Thông Tin Chứng Chỉ
+
+
+ nhật ký proxy
+ Thông tin nhật ký hệ thống
+ nếu bạn gặp sự cố kết nối khi khởi động Genesis, vui lòng sao chép mã sau và tìm sự cố trực tuyến hoặc gửi cho chúng tôi, để chúng tôi có thể cố gắng giúp bạn
+ ~ Genesis on standby at the moment
+
+
+ tùy chỉnh proxy
+ chúng tôi kết nối bạn với mạng Tor do hàng nghìn tình nguyện viên trên khắp thế giới điều hành! Những tùy chọn này có thể giúp bạn không
+ Internet được kiểm duyệt ở đây (vượt tường lửa)
+ vượt tường lửa
+ Bridges khiến Internet chạy rất chậm. chỉ sử dụng chúng nếu internet bị kiểm duyệt ở quốc gia của bạn hoặc mạng Tor bị chặn
+ tùy chỉnh bảo mật
+
+
+ Cài đặt Bảo Mật
+ Thay đổi Cài đặt "BRIDGE"
+ Tạo Tự động
+ Tự động định cấu hình cài đặt "BRIDGE"
+ Cung cấp một "BRIDGE" mà tôi biết
+ Dán tùy chỉnh "BRIDGE"
+ Proxy Settings | Bridge
+ "BRIDGE" là các rơ le Tor không được liệt kê khiến việc chặn các kết nối vào mạng Tor trở nên khó khăn hơn. Vì cách một số quốc gia cố gắng chặn Tor, "BRIDGE" nhất định hoạt động ở một số quốc gia nhưng không hoạt động ở một số quốc gia khác
+ Chọn Mặc định "BRIDGE"
+ Yêu cầu
+ obfs4 (Khuyến nghị)
+ Meek-azure (Trung Quốc)
+
+
+ thay đổi cách hiển thị Nhật ký hệ thống
+ hiển thị Nhật ký bằng chế độ xem danh sách hiện đại
+ toogle giữa chế độ xem danh sách cổ điển và hiện đại
+
+
+ Đã xóa dấu trang
+ Đã cập nhật dấu trang
+ Đã xóa dữ liệu thành công
+ URL được sao chép vào khay nhớ tạm
+ Không tìm thấy ứng dụng nào
+ Yêu cầu khởi động lại sau khi thay đổi
+ Khởi động lại
+ Tab Bị đóng
+ Tab mới đã mở
+ Genesis proxy kết nối ...
+ Bộ nhớ đầy ➔ Xóa tab
+ Cửa sổ bật lên bị chặn
+ Mở Nhật Ký Lỗi
+ Chuyển đổi
+ Hoàn tác
+ Danh tính mới được tạo
+ mở cài đặt
+
+
+ Yêu Cầu Mới Bridge
+ REQUEST Bridge
+ Chọn E-mail bên dưới để yêu cầu địa chỉ Bridge. Sau khi bạn có địa chỉ, hãy sao chép và dán nó vào ô trên và khởi động ứng dụng.
+ Thư tín
+
+
+ XIN LỖI KHI NGHE RỒI
+ Nếu bạn gặp khó khăn khi sử dụng ứng dụng này, vui lòng liên hệ với chúng tôi qua email. Chúng tôi sẽ cố gắng giải quyết vấn đề của bạn càng sớm càng tốt
+
+
+ KHẮC PHỤC SỰ CỐ
+ Đặt lại ứng dụng trong trường hợp nó không hoạt động. Chúng tôi sẽ cố gắng cấu hình lại nó để nó có thể hoạt động trở lại.
+ Đặt lại
+ Loại bỏ
+
+
+ Đang chờ tải xuống ...
+ Tải xuống
+
+
+ Đánh Giá US
+ Cho người khác biết suy nghĩ của bạn về ứng dụng này
+ Đánh giá
+
+
+ Đã xong
+ Bridge string (obfs4 212.21.66.66:20621 ...)
+ Bridge kiểu (obfs4, meek, ...)
+
+
+ Đánh Dấu Trang Web
+ Thêm trang này vào dấu trang của bạn
+ bookmark tên ...
+ Đã xong
+
+
+ Thông Báo URL
+ Mở Trong Tab Mới
+ Mở Trong Tab Hiện Tại
+ Sao chép vào Clipboard
+ Tải Xuống Tệp
+
+
+ Mở url trong tab mới
+ Mở url trong tab hiện tại
+ Sao chép url vào khay nhớ tạm
+ Mở hình ảnh trong tab mới
+ Mở tab hình ảnh hiện tại
+ Sao chép hình ảnh vào khay nhớ tạm
+ Tải xuống tệp hình ảnh
+
+
+ cung cấp một Bridge bạn biết
+ nhập thông tin bridge từ một nguồn đáng tin cậy
+ yêu cầu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ru
+ Thiết lập hệ thống
+ đặt Genesis làm trình duyệt mặc định của bạn
+ Thiết lập hệ thống
+ máy tìm kiếm
+ javascript
+ xóa các liên kết web đã duyệt
+ tùy chỉnh phông chữ
+ Chòm sao Phông chữ Hệ thống
+ thay đổi phông chữ tự động
+ Cài đặt cookie
+ bánh quy
+ Thiết lập hệ thống . Thông báo
+ thông báo
+ thay đổi tùy chọn thông báo
+ tình trạng của mạng và thông báo
+ thông báo địa phương
+ tùy chỉnh thông báo phần mềm
+ thông báo hệ thống
+ Quản lý công cụ tìm kiếm
+ thêm, đặt mặc định. hiển thị đề xuất
+ quản lý thông báo
+ các tính năng mới, tình trạng của mạng
+ Tùy chỉnh phần mềm. Máy tìm kiếm
+ công cụ tìm kiếm được hỗ trợ
+ chọn Công cụ tìm kiếm mặc định
+ Tùy chỉnh phần mềm. Máy tìm kiếm
+ thay đổi cách các Tìm kiếm trên Web xuất hiện
+ default
+ Genesis
+ DuckDuckGo
+ Google
+ Bing
+ Wikipedia
+ hiển thị các liên kết web đã duyệt
+ hiển thị các đề xuất trong quá trình tìm kiếm
+ đề xuất từ các liên kết web đã duyệt xuất hiện khi bạn nhập vào thanh tìm kiếm
+ đề xuất tập trung xuất hiện khi bạn nhập vào thanh tìm kiếm
+ khả năng tiếp cận
+ kích thước văn bản, thu phóng, nhập liệu bằng giọng nói
+ tùy chỉnh | khả năng tiếp cận
+ xóa dữ liệu cá nhân
+ tab, liên kết web đã duyệt, dấu trang, cookie, bộ nhớ cache
+ Thay đổi cài đặt hệ thống. Xóa dữ liệu hệ thống
+ xóa dữ liệu
+ xóa tất cả các tab
+ xóa các liên kết web đã duyệt
+ xóa dấu trang
+ xóa bộ nhớ cache
+ xóa đề xuất
+ xóa dữ liệu
+ xóa phiên
+ xóa cookie
+ xóa tùy chỉnh
+ chia tỷ lệ phông chữ
+ chia tỷ lệ nội dung web theo kích thước phông chữ hệ thống
+ bật thu phóng
+ bật và buộc thu phóng cho tất cả các trang web
+ đầu vào bằng giọng nói
+ cho phép đọc chính tả bằng giọng nói trong thanh url
+ chọn tỷ lệ phông chữ tùy chỉnh
+ kéo thanh trượt cho đến khi bạn có thể đọc thoải mái. văn bản ít nhất phải lớn như thế này sau khi nhấn đúp vào một đoạn văn
+ 200%
+ tương tác
+ thay đổi cách tương tác với nội dung trang web
+ Người dùng đang bật
+ mức độ người dùng, thông tin đăng nhập, lựa chọn dữ liệu
+ Bảo vệ giám sát người dùng
+ adblock, trình theo dõi, lấy dấu vân tay
+ Thiết lập hệ thống . riêng tư
+ Thiết lập hệ thống . bảo vệ người dùng tuyệt vời
+ bảo vệ danh tính trực tuyến của bạn
+ giữ bí mật danh tính của bạn. chúng tôi có thể bảo vệ bạn khỏi một số trình theo dõi theo dõi bạn trực tuyến. Cài đặt Hệ thống này cũng có thể được sử dụng để chặn quảng cáo
+ cứu bản thân khỏi tính năng Bảo vệ sự ngạc nhiên của người dùng
+ Genesis sẽ yêu cầu các trang web không theo dõi tôi
+ yêu cầu trang web không theo dõi tôi
+ Bảo vệ giám sát người dùng
+ kích hoạt tính năng Bảo vệ Survelance của người dùng do Genesis cung cấp
+ cookie trang web
+ chọn tùy chọn cookie trang web theo nhu cầu bảo mật của bạn
+ xóa dữ liệu cá nhân khi thoát
+ xóa dữ liệu tự động sau khi phần mềm được đóng
+ duyệt web riêng tư
+ giữ an toàn cho danh tính của bạn và sử dụng các tùy chọn bên dưới
+ được kích hoạt
+ được bật, không bao gồm cookie theo dõi trang web
+ được bật, không bao gồm bên thứ 3
+ tàn tật
+
+ vô hiệu hóa bảo vệ
+ cho phép Bảo vệ Survelance nhận dạng. điều này có thể khiến danh tính trực tuyến của bạn bị đánh cắp
+ mặc định (khuyến nghị)
+ chặn quảng cáo trực tuyến và người dùng web xã hội Survelance. các trang sẽ tải như mặc định
+ chính sách nghiêm ngặt
+ dừng tất cả các trình theo dõi đã biết, các trang sẽ tải nhanh hơn nhưng một số chức năng có thể không hoạt động
+
+ javascript
+ vô hiệu hóa tập lệnh java cho các cuộc tấn công tập lệnh khác nhau
+ Thiết lập hệ thống . Thiết lập hệ thống phức tạp
+ khôi phục các tab
+ không khôi phục sau khi thoát khỏi trình duyệt
+ chủ đề thanh công cụ
+ đặt chủ đề thanh công cụ như được xác định trong trang web
+ hiển thị hình ảnh
+ luôn tải hình ảnh trang web
+ hiển thị phông chữ web
+ tải xuống phông chữ từ xa khi tải trang
+ cho phép tự động phát
+ cho phép phương tiện tự động khởi động
+ trình tiết kiệm dữ liệu
+ chuyển hướng
+ thay đổi cách hoạt động của tab sau khi khởi động lại phần mềm
+ phương tiện truyền thông
+ thay đổi tùy chỉnh trình tiết kiệm dữ liệu mặc định
+ thay đổi tùy chỉnh phương tiện mặc định
+ luôn hiển thị hình ảnh
+ chỉ hiển thị hình ảnh khi sử dụng wifi
+ chặn tất cả hình ảnh
+ Cài đặt hệ thống nâng cao
+ khôi phục các tab, trình tiết kiệm dữ liệu, công cụ dành cho nhà phát triển
+ onion điều kiện của proxy
+ kiểm tra điều kiện mạng onion
+ báo cáo trang web
+ báo cáo trang web lạm dụng
+ đánh giá ứng dụng này
+ đánh giá và bình luận trên playstore
+ chia sẻ ứng dụng này
+ chia sẻ phần mềm này với bạn bè của bạn
+ Thiết lập hệ thống . tùy chỉnh chung
+ Cài đặt hệ thống mặc định
+ trang chủ, ngôn ngữ
+ duyệt toàn màn hình
+ ẩn thanh công cụ của trình duyệt khi cuộn xuống một trang
+ ngôn ngữ
+ thay đổi ngôn ngữ của trình duyệt của bạn
+ chủ đề phần mềm
+ chọn chủ đề sáng và tối
+ chủ đề tươi sáng
+ chủ đề Tối
+ thay đổi ngôn ngữ và duyệt toàn màn hình
+ mặc định hệ thống
+ trang chủ
+ about:blank
+ tab mới
+ mở trang chủ trong tab mới
+ xóa tất cả các tab
+ xóa các liên kết web đã duyệt
+ xóa dấu trang
+ xóa bộ nhớ cache duyệt web
+ loại bỏ các đề xuất
+ xóa dữ liệu trang web
+ xóa dữ liệu phiên
+ xóa cookie duyệt web
+ loại bỏ tùy chỉnh trình duyệt
+
+
+ bookmark website
+ xóa các liên kết web đã duyệt và Dữ liệu
+ xóa dấu trang và dữ liệu
+ xóa dữ liệu sẽ xóa các liên kết web đã duyệt, cookie và dữ liệu duyệt web khác
+ xóa dữ liệu sẽ xóa các trang web được đánh dấu
+ hủy bỏ
+ https://
+ báo cáo
+ báo cáo trang web
+ nếu bạn cho rằng URL này bất hợp pháp hoặc đáng lo ngại, hãy báo cáo cho chúng tôi để chúng tôi có thể thực hiện hành động pháp lý
+ đã được báo cáo thành công
+ url đã được báo cáo thành công. nếu một cái gì đó được tìm thấy, hành động pháp lý sẽ được thực hiện
+ ngôn ngữ không được hỗ trợ
+ ngôn ngữ hệ thống không được phần mềm này hỗ trợ. chúng tôi đang làm việc để sớm đưa nó vào
+ khởi tạo Orbot
+ hành động không được hỗ trợ
+ không tìm thấy phần mềm nào để xử lý lệnh sau
+ chào mừng | web ẩn Gateway
+ phần mềm này cung cấp cho bạn một nền tảng để tìm kiếm và mở các url web ẩn. đây là một vài gợi ý \n
+ thị trường trực tuyến web ẩn
+ tài liệu và sách bị rò rỉ
+ tin tức và bài báo trên dark web
+ phần mềm bí mật và công cụ hack
+ không hiển thị lại
+ tài chính và tiền bạc
+ xã hội xã hội
+ sổ tay
+ Cửa hang tro chơi
+ thông báo tệp
+ thông báo tải xuống
+ thông báo tải xuống
+ thông báo liên kết web
+
+ không tìm thấy phần mềm để xử lý email
+ tải tập tin |
+ dữ liệu bị xóa | yêu cầu khởi động lại
+
+
+
+
+
+
+ Orbot nhật ký
+ tab mới
+ đóng tab
+ mở các tab gần đây
+ ngôn ngữ
+ tải xuống
+ liên kết web đã duyệt
+ Thiết lập hệ thống
+ trang máy tính để bàn
+ lưu trang này
+ dấu trang
+ báo cáo trang web
+ đánh giá ứng dụng này
+ Tìm ở trang
+ lối ra
+ chia sẻ
+
+
+ tab mới
+ đóng tất cả cửa sổ
+ Thiết lập hệ thống
+ chọn tab
+
+
+ mở tab
+ sao chép
+ chia sẻ
+ lựa chọn rõ ràng
+ mở trong tab hiện tại
+ mở trang mới
+ xóa bỏ
+
+
+ liên kết web đã duyệt
+ tháo cái này
+ Tìm kiếm ...
+
+
+ dấu trang
+ tháo cái này
+ Tìm kiếm ...
+
+
+ thử lại
+ opps! lỗi kết nối mạng. mạng không kết nối
+ giúp đỡ và hỗ trợ
+
+
+ ngôn ngữ
+ thay đổi ngôn ngữ
+ chúng tôi chỉ chạy trên các ngôn ngữ sau. chúng tôi sẽ sớm bổ sung thêm
+ tiếng anh (các bang thống nhất)
+ đức (đức)
+ tiếng Ý (italy)
+ người Bồ Đào Nha (Brazil)
+ nga (nga)
+ ukrainian (ukraine)
+ tiếng Trung giản thể (Trung Quốc đại lục)
+
+
+ ⚠️ cảnh báo
+ tùy chỉnh Bridges
+ kích hoạt Bridges
+ kích hoạt VPN serivces
+ kích hoạt Bridge Gateway
+ kích hoạt Gateway
+
+
+ điều kiện của proxy
+ tình trạng hiện tại của orbot proxy
+ Orbot điều kiện của proxy
+ onion
+ VPN điều kiện kết nối
+ Bridge điều kiện của proxy
+ thông tin | thay đổi cài đặt hệ thống
+ bạn có thể thay đổi proxy bằng cách khởi động lại phần mềm và chuyển đến trình quản lý proxy. nó có thể được mở bằng cách nhấp vào biểu tượng bánh răng ở dưới cùng
+
+
+
+
+ default.jpg
+ mở thứ này
+
+
+ 1
+ connect
+ Genesis is paused at the moment
+ các tab đang mở sẽ hiển thị ở đây
+
+
+ trang web này không thể truy cập được
+ đã xảy ra lỗi khi kết nối với trang web
+ không thể hiển thị trang bạn đang cố xem vì không thể xác minh tính xác thực của dữ liệu đã nhận
+ trang này hiện không hoạt động do một số lý do
+ vui lòng liên hệ với chủ sở hữu trang web để thông báo cho họ về vấn đề này.
+ tải lại
+
+
+ pref_language
+ Chữ ký gói không hợp lệ
+ bấm để đăng nhập.
+ bấm để chọn dữ liệu theo cách thủ công.
+ Ngoại lệ bảo mật tên miền web.
+ Không xác minh được DAL.
+
+ Các tab gần đây
+ Nhận dạng mới
+ Chính sách bảo mật
+ Genesis Browser chính sách về quyền riêng tư
+ Báo cáo trang web
+ Báo cáo trang web bất hợp pháp
+ xuất bản trang web của bạn
+ Thêm trang web của bạn vào công cụ tìm kiếm của chúng tôi
+
+
+
+
+
+ - 55 Phần trăm
+ - 70 Phần trăm
+ - 85 Phần trăm
+ - 100 phần trăm
+ - 115 Phần trăm
+ - 130 Phần trăm
+ - 145 Phần trăm
+
+
+
+ - Đã bật
+ - Tàn tật
+
+
+
+ - Cho phép tất cả
+ - Vô hiệu hóa tất cả
+ - Không có băng thông
+
+
+
+ - Chấp nhận tất cả
+ - Cho phép Tin cậy
+ - Cho phép Không
+ - Cho phép truy cập
+ - Cho phép không theo dõi
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index 7c0a98b8..2d14f4b7 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -12,7 +12,7 @@
数字自由
重装
您正面临以下问题之一。网页或网站可能无法正常工作。您的互联网连接可能不佳。您可能正在使用代理。网站可能被防火墙阻止
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
英国广播公司|以色列再次罢工
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 00887c54..07f39ec7 100755
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -137,6 +137,7 @@
#ffffff
#7591bd
#e6e6e6
+ #f0f0f0
/* Shared Colors */
#0066FF
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 60b9e145..49d45dde 100755
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -14,7 +14,7 @@
Online Freedom
Reload
These might be the problems you are facing \n\n• Webpage or Website might be down \n• Your Internet connection might be poor \n• You might be using a proxy \n• Website might be blocked by firewall
- com.darkweb.genesissearchengine.production.provider
+ com.hiddenservices.genesissearchengine.production.provider
BBC | Israel Strikes Again
Search the web ...
diff --git a/app/variables.gradle b/app/variables.gradle
index 0d29f137..a15ec6b8 100755
--- a/app/variables.gradle
+++ b/app/variables.gradle
@@ -33,7 +33,7 @@ project.ext.min_sdk_version = 21
project.ext.target_sdk_version = 30
project.ext.build_tool_version = '30.0.3'
project.ext.ndk_version = '21.4.7075529'
-project.ext.application_id = "com.darkweb.genesissearchengine.production"
+project.ext.application_id = "com.hiddenservices.genesissearchengine.production"
project.ext.debugSymbolLevel = 'FULL'
/* Splits */
diff --git a/orbotmanager/build.gradle b/orbotmanager/build.gradle
index a96ef159..b8a230f2 100644
--- a/orbotmanager/build.gradle
+++ b/orbotmanager/build.gradle
@@ -1,67 +1,67 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion 31
- buildToolsVersion '30.0.3'
- ndkVersion '21.3.6528147'
-
- sourceSets {
- main {
- jniLibs.srcDirs = ['./src/main/libs']
- }
- }
-
- defaultConfig {
- minSdkVersion 16
- targetSdkVersion 31
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-
- aaptOptions {
- cruncherEnabled = false
- }
-
- lintOptions {
- checkReleaseBuilds false
- abortOnError true
-
- htmlReport true
- xmlReport false
- textReport false
-
- lintConfig file("../lint.xml")
- }
-
- packagingOptions {
- exclude 'META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version'
- }
-}
-
-dependencies {
- implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
- implementation 'com.gitlab.guardianproject:jsocksandroid:1.0.4'
-
- implementation 'com.jaredrummler:android-shell:1.0.0'
-
- implementation 'androidx.core:core:1.6.0'
- implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
- testImplementation 'junit:junit:4.13.2'
-
- implementation 'com.offbynull.portmapper:portmapper:2.0.5'
-
- implementation 'info.guardianproject:geoip:20191217'
-
- api 'info.guardianproject:jtorctl:0.4.5.7'
- implementation 'info.guardianproject:tor-android:0.4.5.9'
-
- implementation 'com.github.tladesignz:IPtProxy:1.0.0'
-}
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 31
+ buildToolsVersion '30.0.3'
+ ndkVersion '21.3.6528147'
+
+ sourceSets {
+ main {
+ jniLibs.srcDirs = ['./src/main/libs']
+ }
+ }
+
+ defaultConfig {
+ minSdkVersion 16
+ targetSdkVersion 31
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+
+ aaptOptions {
+ cruncherEnabled = false
+ }
+
+ lintOptions {
+ checkReleaseBuilds false
+ abortOnError true
+
+ htmlReport true
+ xmlReport false
+ textReport false
+
+ lintConfig file("../lint.xml")
+ }
+
+ packagingOptions {
+ exclude 'META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version'
+ }
+}
+
+dependencies {
+ implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
+ implementation 'com.gitlab.guardianproject:jsocksandroid:1.0.4'
+
+ implementation 'com.jaredrummler:android-shell:1.0.0'
+
+ implementation 'androidx.core:core:1.7.0'
+ implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
+ testImplementation 'junit:junit:4.13.2'
+
+ implementation 'com.offbynull.portmapper:portmapper:2.0.5'
+
+ implementation 'info.guardianproject:geoip:20191217'
+
+ api 'info.guardianproject:jtorctl:0.4.5.7'
+ implementation 'info.guardianproject:tor-android:0.4.5.9'
+
+ implementation 'com.github.tladesignz:IPtProxy:1.0.0'
+}
diff --git a/orbotmanager/src/main/AndroidManifest.xml b/orbotmanager/src/main/AndroidManifest.xml
index 589ee334..aecfe6ad 100644
--- a/orbotmanager/src/main/AndroidManifest.xml
+++ b/orbotmanager/src/main/AndroidManifest.xml
@@ -1,5 +1,5 @@
+ package="org.orbotproject.android.service">
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/OrbotConstants.java b/orbotmanager/src/main/java/org/orbotproject/android/service/OrbotConstants.java
similarity index 93%
rename from orbotmanager/src/main/java/org/torproject/android/service/OrbotConstants.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/OrbotConstants.java
index 3960fb6c..596f30f8 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/OrbotConstants.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/OrbotConstants.java
@@ -1,38 +1,38 @@
-/* Copyright (c) 2009, Nathan Freitas, Orbot/The Guardian Project - http://openideals.com/guardian */
-/* See LICENSE for licensing information */
-
-package org.torproject.android.service;
-
-public interface OrbotConstants {
-
- String TAG = "Orbot";
-
- String PREF_OR = "pref_or";
- String PREF_OR_PORT = "pref_or_port";
- String PREF_OR_NICKNAME = "pref_or_nickname";
- String PREF_REACHABLE_ADDRESSES = "pref_reachable_addresses";
- String PREF_REACHABLE_ADDRESSES_PORTS = "pref_reachable_addresses_ports";
-
- String PREF_DISABLE_NETWORK = "pref_disable_network";
-
- String PREF_TOR_SHARED_PREFS = "org.torproject.android_preferences";
-
- String PREF_SOCKS = "pref_socks";
-
- String PREF_HTTP = "pref_http";
-
- String PREF_ISOLATE_DEST = "pref_isolate_dest";
-
- String PREF_CONNECTION_PADDING = "pref_connection_padding";
- String PREF_REDUCED_CONNECTION_PADDING = "pref_reduced_connection_padding";
- String PREF_CIRCUIT_PADDING = "pref_circuit_padding";
- String PREF_REDUCED_CIRCUIT_PADDING = "pref_reduced_circuit_padding";
-
- String PREF_PREFER_IPV6 = "pref_prefer_ipv6";
- String PREF_DISABLE_IPV4 = "pref_disable_ipv4";
-
-
- String APP_TOR_KEY = "_app_tor";
- String APP_DATA_KEY = "_app_data";
- String APP_WIFI_KEY = "_app_wifi";
-}
+/* Copyright (c) 2009, Nathan Freitas, Orbot/The Guardian Project - http://openideals.com/guardian */
+/* See LICENSE for licensing information */
+
+package org.orbotproject.android.service;
+
+public interface OrbotConstants {
+
+ String TAG = "Orbot";
+
+ String PREF_OR = "pref_or";
+ String PREF_OR_PORT = "pref_or_port";
+ String PREF_OR_NICKNAME = "pref_or_nickname";
+ String PREF_REACHABLE_ADDRESSES = "pref_reachable_addresses";
+ String PREF_REACHABLE_ADDRESSES_PORTS = "pref_reachable_addresses_ports";
+
+ String PREF_DISABLE_NETWORK = "pref_disable_network";
+
+ String PREF_TOR_SHARED_PREFS = "org.torproject.android_preferences";
+
+ String PREF_SOCKS = "pref_socks";
+
+ String PREF_HTTP = "pref_http";
+
+ String PREF_ISOLATE_DEST = "pref_isolate_dest";
+
+ String PREF_CONNECTION_PADDING = "pref_connection_padding";
+ String PREF_REDUCED_CONNECTION_PADDING = "pref_reduced_connection_padding";
+ String PREF_CIRCUIT_PADDING = "pref_circuit_padding";
+ String PREF_REDUCED_CIRCUIT_PADDING = "pref_reduced_circuit_padding";
+
+ String PREF_PREFER_IPV6 = "pref_prefer_ipv6";
+ String PREF_DISABLE_IPV4 = "pref_disable_ipv4";
+
+
+ String APP_TOR_KEY = "_app_tor";
+ String APP_DATA_KEY = "_app_data";
+ String APP_WIFI_KEY = "_app_wifi";
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/OrbotService.java b/orbotmanager/src/main/java/org/orbotproject/android/service/OrbotService.java
similarity index 93%
rename from orbotmanager/src/main/java/org/torproject/android/service/OrbotService.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/OrbotService.java
index 681070f7..3aa81627 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/OrbotService.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/OrbotService.java
@@ -1,1975 +1,1974 @@
-package org.torproject.android.service;
-
-import android.annotation.SuppressLint;
-import android.app.Application;
-import android.app.Notification;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.app.Service;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.ContentResolver;
-import android.content.ContentValues;
-import android.content.Context;
-import android.content.ContextWrapper;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.ServiceConnection;
-import android.content.SharedPreferences;
-import android.content.pm.PackageManager;
-import android.database.Cursor;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.net.Uri;
-import android.net.VpnService;
-import android.os.BatteryManager;
-import android.os.Build;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.IBinder;
-import android.os.Looper;
-import android.provider.BaseColumns;
-import android.text.TextUtils;
-import android.util.Log;
-
-import net.freehaven.tor.control.TorControlCommands;
-import net.freehaven.tor.control.TorControlConnection;
-
-import org.torproject.android.service.util.CustomTorResourceInstaller;
-import org.torproject.android.service.util.DummyActivity;
-import org.torproject.android.service.util.Prefs;
-import org.torproject.android.service.util.TorServiceUtils;
-import org.torproject.android.service.util.Utils;
-import org.torproject.android.service.vpn.OrbotVpnManager;
-import org.torproject.android.service.vpn.VpnPrefs;
-import org.torproject.android.service.wrapper.localHelperMethod;
-import org.torproject.android.service.wrapper.logRowModel;
-import org.torproject.android.service.wrapper.orbotLocalConstants;
-import org.torproject.jni.TorService;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.StringReader;
-import java.text.NumberFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Objects;
-import java.util.Random;
-import java.util.StringTokenizer;
-import java.util.UUID;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeoutException;
-
-import IPtProxy.IPtProxy;
-import androidx.annotation.RequiresApi;
-import androidx.core.app.NotificationCompat;
-import androidx.localbroadcastmanager.content.LocalBroadcastManager;
-
-import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
-import static org.torproject.android.service.wrapper.orbotLocalConstants.mBridgesDefault;
-
-public class OrbotService extends VpnService implements TorServiceConstants, OrbotConstants {
-
- public final static String BINARY_TOR_VERSION = TorService.VERSION_NAME;
-
- static final int NOTIFY_ID = 1;
- private static final int ERROR_NOTIFY_ID = 3;
- private static final int HS_NOTIFY_ID = 4;
- private static final Uri V2_HS_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.hiddenservices.providers.genesis/hs");
- private static final Uri V3_ONION_SERVICES_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.v3onionservice.genesis/v3");
- private static final Uri COOKIE_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.hiddenservices.providers.genesis.cookie/cookie");
- private static final Uri V3_CLIENT_AUTH_URI = Uri.parse("content://org.torproject.android.ui.v3onionservice.genesis.clientauth/v3auth");
- private final static String NOTIFICATION_CHANNEL_ID = "orbot_channel_1";
- private static final String[] LEGACY_V2_ONION_SERVICE_PROJECTION = new String[]{
- OnionService._ID,
- OnionService.NAME,
- OnionService.DOMAIN,
- OnionService.PORT,
- OnionService.AUTH_COOKIE,
- OnionService.AUTH_COOKIE_VALUE,
- OnionService.ONION_PORT,
- OnionService.ENABLED,
- OnionService.PATH};
- private static final String[] V3_ONION_SERVICE_PROJECTION = new String[]{
- OnionService._ID,
- OnionService.NAME,
- OnionService.DOMAIN,
- OnionService.PORT,
- OnionService.ONION_PORT,
- OnionService.ENABLED,
- OnionService.PATH
- };
- private static final String[] LEGACY_COOKIE_PROJECTION = new String[]{
- ClientCookie._ID,
- ClientCookie.DOMAIN,
- ClientCookie.AUTH_COOKIE_VALUE,
- ClientCookie.ENABLED};
- private static final String[] V3_CLIENT_AUTH_PROJECTION = new String[]{
- V3ClientAuth._ID,
- V3ClientAuth.DOMAIN,
- V3ClientAuth.HASH,
- V3ClientAuth.ENABLED
- };
-
- public boolean isAppClosed = false;
- public static int mPortSOCKS = -1;
- public static int mPortHTTP = -1;
- public static int mPortDns = TOR_DNS_PORT_DEFAULT;
- public static int mPortTrans = TOR_TRANSPROXY_PORT_DEFAULT;
- public static File appBinHome;
- public static File appCacheHome;
- private final ExecutorService mExecutor = Executors.newCachedThreadPool();
- boolean mIsLollipop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
- TorEventHandler mEventHandler;
- OrbotVpnManager mVpnManager;
- Handler mHandler;
- //we should randomly sort alBridges so we don't have the same bridge order each time
- Random bridgeSelectRandom = new Random(System.nanoTime());
- ActionBroadcastReceiver mActionBroadcastReceiver;
- private String mCurrentStatus = STATUS_OFF;
- private TorControlConnection conn = null;
- private ServiceConnection torServiceConnection;
- private TorService torService;
- private boolean shouldUnbindTorService;
- private NotificationManager mNotificationManager = null;
- private NotificationCompat.Builder mNotifyBuilder;
- private boolean mNotificationShowing = false;
- private File mHSBasePath, mV3OnionBasePath, mV3AuthBasePath;
- private ArrayList alBridges = null;
-
- /**
- * @param bridgeList bridges that were manually entered into Orbot settings
- * @return Array with each bridge as an element, no whitespace entries see issue #289...
- */
- private static String[] parseBridgesFromSettings(String bridgeList) {
- // this regex replaces lines that only contain whitespace with an empty String
- bridgeList = bridgeList.trim().replaceAll("(?m)^[ \t]*\r?\n", "");
- return bridgeList.split("\\n");
- }
-
- public void debug(String msg) {
- Log.d(OrbotConstants.TAG, msg);
-
- if (Prefs.useDebugLogging()) {
- sendCallbackLogMessage(msg);
- }
- }
-
- public void logException(String msg, Exception e) {
- if (Prefs.useDebugLogging()) {
- Log.e(OrbotConstants.TAG, msg, e);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- e.printStackTrace(new PrintStream(baos));
-
- sendCallbackLogMessage(msg + '\n' + new String(baos.toByteArray()));
-
- } else
- sendCallbackLogMessage(msg);
-
- }
-
- private void showConnectedToTorNetworkNotification() {
- showToolbarNotification(getString(R.string.status_activated), NOTIFY_ID, R.mipmap.ic_stat_tor_logo);
- }
-
- @Override
- public void onLowMemory() {
- super.onLowMemory();
- logNotice("Low Memory Warning!");
- }
-
- private void clearNotifications() {
- if (mNotificationManager != null)
- mNotificationManager.cancelAll();
-
- if (mEventHandler != null)
- mEventHandler.getNodes().clear();
-
- mNotificationShowing = false;
- }
-
- @RequiresApi(api = Build.VERSION_CODES.O)
- private void createNotificationChannel() {
- NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
-
- CharSequence name = getString(R.string.app_name); // The user-visible name of the channel.
- String description = getString(R.string.app_description); // The user-visible description of the channel.
- NotificationChannel mChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, name, NotificationManager.IMPORTANCE_LOW);
- // Configure the notification channel.
- mChannel.setDescription(description);
- mChannel.enableLights(false);
- mChannel.enableVibration(false);
- mChannel.setShowBadge(false);
- mChannel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
- mNotificationManager.createNotificationChannel(mChannel);
- }
-
- boolean mToolbarUpdating = false;
- @SuppressLint({"NewApi", "RestrictedApi"})
- public void showToolbarNotification(String notifyMsg, int notifyType, int icon) {
- if(!mToolbarUpdating){
- mToolbarUpdating = true;
- }else {
- return;
- }
-
- try{
- if(isAppClosed){
- Log.i("superman", "superman");
- return;
- }
- PackageManager pm = getPackageManager();
- Intent intent = pm.getLaunchIntentForPackage(getPackageName());
- PendingIntent pendIntent = PendingIntent.getActivity(OrbotService.this, 0, intent, 0);
-
- if (mNotifyBuilder == null) {
- mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- mNotifyBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
- .setContentTitle(getString(R.string.app_name))
- .setSmallIcon(R.mipmap.ic_stat_tor_logo)
- .setContentIntent(pendIntent)
- .setCategory(Notification.CATEGORY_SERVICE)
- .setOngoing(Prefs.persistNotifications());
- }
-
- mNotifyBuilder.mActions.clear();
- if (conn != null && orbotLocalConstants.mIsTorInitialized) {
- Intent intentRefresh = new Intent(CMD_NEWNYM);
- PendingIntent pendingIntentNewNym = PendingIntent.getBroadcast(this, 0, intentRefresh, PendingIntent.FLAG_UPDATE_CURRENT);
- mNotifyBuilder.addAction(R.mipmap.ic_stat_tor_logo, getString(R.string.menu_new_identity), pendingIntentNewNym);
-
- Intent intentSetting = new Intent(CMD_SETTING);
- PendingIntent pendingIntentSetting = PendingIntent.getBroadcast(this, 0, intentSetting, PendingIntent.FLAG_UPDATE_CURRENT);
- mNotifyBuilder.addAction(0, "Notification Settings", pendingIntentSetting);
- }
-
- mNotifyBuilder.setContentText(notifyMsg)
- .setSmallIcon(icon)
- .setTicker(notifyType != NOTIFY_ID ? notifyMsg : null);
-
- if (!Prefs.persistNotifications())
- mNotifyBuilder.setPriority(Notification.PRIORITY_LOW);
-
- Notification notification = mNotifyBuilder.build();
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- startForeground(11337, notification);
- } else if (Prefs.persistNotifications() && (!mNotificationShowing)) {
- startForeground(11337, notification);
- logNotice("Set background service to FOREGROUND");
- } else {
- mNotificationManager.notify(NOTIFY_ID, notification);
- }
- }catch (Exception ex){
- Log.i("sad","asd");
- }
-
- mNotificationShowing = true;
- mToolbarUpdating = false;
- }
-
- public int onStartCommand(Intent intent, int flags, int startId) {
- showToolbarNotification("", NOTIFY_ID, R.mipmap.ic_stat_tor_logo);
-
- self = this;
- if (intent != null)
- mExecutor.execute(new IncomingIntentRouter(intent));
- else
- Log.d(OrbotConstants.TAG, "Got null onStartCommand() intent");
-
- return Service.START_STICKY;
- }
-
- @Override
- public void onTaskRemoved(Intent rootIntent) {
- try{
- Intent intent = new Intent(this, DummyActivity.class);
- intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- }catch (Exception ignored){
- Log.i("sda","ASd");
-
- }
- }
-
- @Override
- public void onDestroy() {
-
- try {
- disableNotification();
- clearNotifications();
- unregisterReceiver(mNetworkStateReceiver);
- unregisterReceiver(mActionBroadcastReceiver);
- }catch (Exception ex){
- Log.i("sad","asd");
- ex.printStackTrace();
- }
-
- isAppClosed = true;
-
- try {
- stopTor();
- stopTorAsync();
- clearNotifications();
- killAllDaemons();
- } catch (Exception exception) {
- exception.printStackTrace();
- }
-
- super.onDestroy();
- }
-
- private void killAllDaemons() throws Exception {
-
- if (conn != null) {
- logNotice("Using control port to shutdown Tor");
-
- try {
- logNotice("sending HALT signal to Tor process");
- conn.shutdownTor("SHUTDOWN");
-
- } catch (IOException e) {
- Log.d(OrbotConstants.TAG, "error shutting down Tor via connection", e);
- }
-
- conn = null;
- }
- }
-
- private void stopTorAsync() {
-
- debug("stopTor");
-
- try {
- sendCallbackStatus(STATUS_STOPPING);
- sendCallbackLogMessage(getString(R.string.status_shutting_down));
-
- if (Prefs.bridgesEnabled()) {
- if (useIPtObfsMeekProxy())
- IPtProxy.stopObfs4Proxy();
- else if (useIPtSnowflakeProxy())
- IPtProxy.stopSnowflake();
- }
- else if (Prefs.beSnowflakeProxy())
- disableSnowflakeProxy();
-
- stopTor();
-
- //stop the foreground priority and make sure to remove the persistant notification
- stopForeground(true);
-
- sendCallbackLogMessage(getString(R.string.status_disabled));
- } catch (Exception e) {
- logNotice("An error occured stopping Tor: " + e.getMessage());
- sendCallbackLogMessage(getString(R.string.something_bad_happened));
- }
- clearNotifications();
- sendCallbackStatus(STATUS_OFF);
- }
-
- private void disableSnowflakeProxy () {
- IPtProxy.stopSnowflakeProxy();
- logNotice("Snowflake Proxy mode DISABLED");
- }
-
- private void stopTorOnError(String message) {
- stopTorAsync();
- showToolbarNotification(
- getString(R.string.unable_to_start_tor) + ": " + message,
- ERROR_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
- }
-
- private static boolean useIPtObfsMeekProxy() {
- String bridgeList = Prefs.getBridgesList();
- return bridgeList.contains("obfs") || bridgeList.contains("meek");
- }
-
- private static boolean useIPtSnowflakeProxy() {
- String bridgeList = Prefs.getBridgesList();
- return bridgeList.contains("snowflake");
- }
-
- private static HashMap mFronts;
-
- public static void loadCdnFronts (Context context) {
- if (mFronts == null) {
- mFronts = new HashMap<>();
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(context.getAssets().open("fronts")));
- String line;
- while ((line = reader.readLine())!=null) {
- String[] front = line.split(" ");
- mFronts.put(front[0],front[1]);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
- public static String getCdnFront(String service) {
- return mFronts.get(service);
- }
-
- private void startSnowflakeClient() {
- String target = getCdnFront("snowflake-target");
- String front = getCdnFront("snowflake-front");
- String stunServer = getCdnFront("snowflake-stun");
- IPtProxy.startSnowflake(stunServer, target, front,null, true, false, true, 3);
- }
-
- /*
- This is to host a snowflake entrance node / bridge
- */
- private void runSnowflakeProxy () {
- int capacity = 3;
- 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);
- }
-
- private void stopSnowflakeProxy () {
- IPtProxy.stopSnowflakeProxy();
- }
- /**
- * if someone stops during startup, we may have to wait for the conn port to be setup, so we can properly shutdown tor
- */
- private synchronized void stopTor() throws Exception {
-
- if (conn != null) {
- logNotice("Using control port to shutdown Tor");
-
- try {
- logNotice("sending HALT signal to Tor process");
- conn.shutdownTor(TorControlCommands.SIGNAL_SHUTDOWN);
-
- } catch (IOException e) {
- Log.d(OrbotConstants.TAG, "error shutting down Tor via connection", e);
- }
-
- if (shouldUnbindTorService) {
- unbindService(torServiceConnection);
- shouldUnbindTorService = false;
- }
-
- conn = null;
- }
- }
-
- private void requestTorRereadConfig() {
- try {
- if (conn != null) {
- conn.signal(TorControlCommands.SIGNAL_RELOAD);
- }
- } catch (IOException e) {
- Log.i("sad","asd");
- e.printStackTrace();
- }
- }
-
- protected void logNotice(String msg) {
- if (msg != null && msg.trim().length() > 0) {
- if (Prefs.useDebugLogging())
- Log.d(OrbotConstants.TAG, msg);
-
- sendCallbackLogMessage(msg);
- }
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- try {
- if (Build.VERSION.SDK_INT <= 25) {
- Intent notificationIntent = new Intent(this, OrbotService.class);
-
- PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
- notificationIntent, 0);
-
- Notification notification = new NotificationCompat.Builder(this)
- .setSmallIcon(R.drawable.ic_stat_starting_tor_logo)
- .setContentTitle("Starting Genesis")
- .setContentIntent(pendingIntent).build();
-
- startForeground(11337, notification);
- }else {
- String id = "_channel_01";
- int importance = NotificationManager.IMPORTANCE_LOW;
- NotificationChannel mChannel = new NotificationChannel(id, "notification", importance);
- mChannel.enableLights(true);
-
- Notification notification = new Notification.Builder(getApplicationContext(), id)
- .setSmallIcon(R.drawable.ic_stat_starting_tor_logo)
- .setContentTitle("Starting Genesis")
- .build();
-
- NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- if (mNotificationManager != null) {
- mNotificationManager.createNotificationChannel(mChannel);
- mNotificationManager.notify(11337, notification);
- }
-
- startForeground(11337, notification);
- }
-
-
- mHandler = new Handler();
-
- appBinHome = getFilesDir();
- if (!appBinHome.exists())
- appBinHome.mkdirs();
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- appCacheHome = new File(getDataDir(), DIRECTORY_TOR_DATA);
- } else {
- appCacheHome = getDir(DIRECTORY_TOR_DATA, Application.MODE_PRIVATE);
- }
-
- if (!appCacheHome.exists())
- appCacheHome.mkdirs();
-
- mHSBasePath = new File(getFilesDir().getAbsolutePath(), TorServiceConstants.HIDDEN_SERVICES_DIR);
- if (!mHSBasePath.isDirectory())
- mHSBasePath.mkdirs();
-
- mV3OnionBasePath = new File(getFilesDir().getAbsolutePath(), TorServiceConstants.ONION_SERVICES_DIR);
- if (!mV3OnionBasePath.isDirectory())
- mV3OnionBasePath.mkdirs();
-
- mV3AuthBasePath = new File(getFilesDir().getAbsolutePath(), TorServiceConstants.V3_CLIENT_AUTH_DIR);
- if (!mV3AuthBasePath.isDirectory())
- mV3AuthBasePath.mkdirs();
-
- if (mNotificationManager == null) {
- mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- }
-
- IntentFilter mNetworkStateFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
- registerReceiver(mNetworkStateReceiver , mNetworkStateFilter);
-
- IntentFilter filter = new IntentFilter();
- filter.addAction(CMD_NEWNYM);
- filter.addAction(CMD_SETTING);
- filter.addAction(CMD_ACTIVE);
- mActionBroadcastReceiver = new ActionBroadcastReceiver();
- registerReceiver(mActionBroadcastReceiver, filter);
-
- if (Build.VERSION.SDK_INT >= 26)
- createNotificationChannel();
-
- CustomTorResourceInstaller installer = new CustomTorResourceInstaller(this, appBinHome);
- installer.installGeoIP();
-
- pluggableTransportInstall();
-
- mVpnManager = new OrbotVpnManager(this);
-
- loadCdnFronts(this);
-
- } catch (Exception e) {
- //what error here
- Log.e(OrbotConstants.TAG, "Error installing Orbot binaries", e);
- logNotice("There was an error installing Orbot binaries");
- }
-
- Log.i("OrbotService", "onCreate end");
- }
-
- protected String getCurrentStatus() {
- return mCurrentStatus;
- }
-
- private boolean pluggableTransportInstall() {
-
- File fileCacheDir = new File(getCacheDir(), "pt");
- if (!fileCacheDir.exists())
- //noinspection ResultOfMethodCallIgnored
- fileCacheDir.mkdir();
- IPtProxy.setStateLocation(fileCacheDir.getAbsolutePath());
- String fileTestState = IPtProxy.getStateLocation();
- debug("IPtProxy state: " + fileTestState);
-
- return false;
- }
-
- private File updateTorrcCustomFile() throws IOException, TimeoutException {
- SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
-
- StringBuffer extraLines = new StringBuffer();
-
- extraLines.append("\n");
-
- extraLines.append("RunAsDaemon 0").append('\n');
- extraLines.append("AvoidDiskWrites 0").append('\n');
-
- String socksPortPref = prefs.getString(OrbotConstants.PREF_SOCKS, (TorServiceConstants.SOCKS_PROXY_PORT_DEFAULT));
-
- if (socksPortPref.indexOf(':') != -1)
- socksPortPref = socksPortPref.split(":")[1];
-
-
- String httpPortPref = prefs.getString(OrbotConstants.PREF_HTTP, (TorServiceConstants.HTTP_PROXY_PORT_DEFAULT));
-
- if (httpPortPref.indexOf(':') != -1)
- httpPortPref = httpPortPref.split(":")[1];
-
-
- try{
- orbotLocalConstants.mSOCKSPort = Integer.parseInt(socksPortPref);
- orbotLocalConstants.mHTTPPort = Integer.parseInt(httpPortPref);
-
- }catch (Exception ex){
- orbotLocalConstants.mSOCKSPort = 9050;
- orbotLocalConstants.mHTTPPort = 8118;
- }
-
- String isolate = "";
- if (prefs.getBoolean(OrbotConstants.PREF_ISOLATE_DEST, false)) {
- isolate += " IsolateDestAddr ";
- }
-
- String ipv6Pref = "";
-
- if (prefs.getBoolean(OrbotConstants.PREF_PREFER_IPV6, true)) {
- ipv6Pref += " IPv6Traffic PreferIPv6 ";
- }
-
- if (prefs.getBoolean(OrbotConstants.PREF_DISABLE_IPV4, false)) {
- ipv6Pref += " IPv6Traffic NoIPv4Traffic ";
- }
-
- extraLines.append("SOCKSPort ").append(socksPortPref).append(isolate).append(ipv6Pref).append('\n');
- extraLines.append("SafeSocks 0").append('\n');
- extraLines.append("TestSocks 0").append('\n');
-
- if (Prefs.openProxyOnAllInterfaces())
- extraLines.append("SocksListenAddress 0.0.0.0").append('\n');
-
-
- extraLines.append("HTTPTunnelPort ").append(httpPortPref).append('\n');
-
- if (prefs.getBoolean(OrbotConstants.PREF_CONNECTION_PADDING, false)) {
- extraLines.append("ConnectionPadding 1").append('\n');
- }
-
- if (prefs.getBoolean(OrbotConstants.PREF_REDUCED_CONNECTION_PADDING, true)) {
- extraLines.append("ReducedConnectionPadding 1").append('\n');
- }
-
- if (prefs.getBoolean(OrbotConstants.PREF_CIRCUIT_PADDING, true)) {
- extraLines.append("CircuitPadding 1").append('\n');
- } else {
- extraLines.append("CircuitPadding 0").append('\n');
- }
-
- if (prefs.getBoolean(OrbotConstants.PREF_REDUCED_CIRCUIT_PADDING, true)) {
- extraLines.append("ReducedCircuitPadding 1").append('\n');
- }
-
- String transPort = prefs.getString("pref_transport", TorServiceConstants.TOR_TRANSPROXY_PORT_DEFAULT + "");
- String dnsPort = prefs.getString("pref_dnsport", TorServiceConstants.TOR_DNS_PORT_DEFAULT + "");
-
- extraLines.append("TransPort ").append(checkPortOrAuto(transPort)).append('\n');
- extraLines.append("DNSPort ").append(checkPortOrAuto(dnsPort)).append('\n');
-
- extraLines.append("VirtualAddrNetwork 10.192.0.0/10").append('\n');
- extraLines.append("AutomapHostsOnResolve 1").append('\n');
-
- extraLines.append("DormantClientTimeout 10 minutes").append('\n');
- // extraLines.append("DormantOnFirstStartup 0").append('\n');
- extraLines.append("DormantCanceledByStartup 1").append('\n');
-
- extraLines.append("DisableNetwork 0").append('\n');
-
- if (Prefs.useDebugLogging()) {
- extraLines.append("Log debug syslog").append('\n');
- extraLines.append("SafeLogging 0").append('\n');
- }
-
- extraLines = processSettingsImpl(extraLines);
-
- if (extraLines == null)
- return null;
-
- extraLines.append('\n');
- extraLines.append(prefs.getString("pref_custom_torrc", "")).append('\n');
-
- logNotice("updating torrc custom configuration...");
-
- debug("torrc.custom=" + extraLines.toString());
-
- File fileTorRcCustom = TorService.getTorrc(this);
- updateTorConfigCustom(fileTorRcCustom, extraLines.toString());
- return fileTorRcCustom;
- }
-
- public int getPortHTTP(){
- return orbotLocalConstants.mHTTPPort;
- }
-
- public int getPortSOCKS(){
- return orbotLocalConstants.mSOCKSPort;
- }
-
- private String checkPortOrAuto(String portString) {
- if (!portString.equalsIgnoreCase("auto")) {
- boolean isPortUsed = true;
- int port = Integer.parseInt(portString);
-
- while (isPortUsed) {
- isPortUsed = TorServiceUtils.isPortOpen("127.0.0.1", port, 500);
-
- if (isPortUsed) //the specified port is not available, so let Tor find one instead
- port++;
- }
- return port + "";
- }
-
- return portString;
- }
-
- public boolean updateTorConfigCustom(File fileTorRcCustom, String extraLines) throws IOException, TimeoutException {
- FileWriter fos = new FileWriter(fileTorRcCustom, false);
- PrintWriter ps = new PrintWriter(fos);
- ps.print(extraLines);
- ps.flush();
- ps.close();
- return true;
- }
-
- /**
- * Send Orbot's status in reply to an
- * {@link TorServiceConstants#ACTION_START} {@link Intent}, targeted only to
- * the app that sent the initial request. If the user has disabled auto-
- * starts, the reply {@code ACTION_START Intent} will include the extra
- * {@link TorServiceConstants#STATUS_STARTS_DISABLED}
- */
- private void replyWithStatus(Intent startRequest) {
- String packageName = startRequest.getStringExtra(EXTRA_PACKAGE_NAME);
-
- Intent reply = new Intent(ACTION_STATUS);
- reply.putExtra(EXTRA_STATUS, mCurrentStatus);
- reply.putExtra(EXTRA_SOCKS_PROXY, "socks://127.0.0.1:" + mPortSOCKS);
- reply.putExtra(EXTRA_SOCKS_PROXY_HOST, "127.0.0.1");
- reply.putExtra(EXTRA_SOCKS_PROXY_PORT, mPortSOCKS);
- reply.putExtra(EXTRA_HTTP_PROXY, "http://127.0.0.1:" + mPortHTTP);
- reply.putExtra(EXTRA_HTTP_PROXY_HOST, "127.0.0.1");
- reply.putExtra(EXTRA_HTTP_PROXY_PORT, mPortHTTP);
-
- if (packageName != null) {
- reply.setPackage(packageName);
- sendBroadcast(reply);
- }
-
- LocalBroadcastManager.getInstance(this).sendBroadcast(reply);
-
- if (mPortSOCKS != -1 && mPortHTTP != -1)
- sendCallbackPorts(mPortSOCKS, mPortHTTP, mPortDns, mPortTrans);
-
- }
-
- /**
- * The entire process for starting tor and related services is run from this method.
- */
- public void onRestart() {
- try {
- startTorService();
- } catch (Exception exception) {
- exception.printStackTrace();
- }
- }
-
- private void startTor() {
- try {
-
- // STATUS_STARTING is set in onCreate()
- if (mCurrentStatus.equals(STATUS_STOPPING)) {
- // these states should probably be handled better
- sendCallbackLogMessage("Ignoring start request, currently " + mCurrentStatus);
- return;
- } else if (mCurrentStatus.equals(STATUS_ON)) {
- showConnectedToTorNetworkNotification();
- sendCallbackLogMessage("Ignoring start request, already started.");
- return;
- }
-
- sendCallbackStatus(STATUS_STARTING);
-
- // make sure there are no stray daemons running
- stopTor();
-
- showToolbarNotification(getString(R.string.status_starting_up), NOTIFY_ID, R.drawable.ic_stat_starting_tor_logo);
- //sendCallbackLogMessage(getString(R.string.status_starting_up));
- //logNotice(getString(R.string.status_starting_up));
-
- ArrayList customEnv = new ArrayList<>();
-
- if (Prefs.bridgesEnabled())
- if (Prefs.useVpn() && !mIsLollipop) {
- customEnv.add("TOR_PT_PROXY=socks5://" + OrbotVpnManager.sSocksProxyLocalhost + ":" + OrbotVpnManager.sSocksProxyServerPort);
- }
-
- startTorService();
-
- if (Prefs.hostOnionServicesEnabled()) {
- try {
- updateLegacyV2OnionNames();
- } catch (SecurityException se) {
- logNotice("unable to upload legacy v2 onion names");
- }
- try {
- updateV3OnionNames();
- } catch (SecurityException se) {
- logNotice("unable to upload v3 onion names");
- }
- }
- } catch (Exception e) {
- Log.i("sad","asd");
- logException("Unable to start Tor: " + e.toString(), e);
- stopTorOnError(e.getLocalizedMessage());
- }
- }
-
-
- private void updateV3OnionNames() throws SecurityException {
- ContentResolver contentResolver = getApplicationContext().getContentResolver();
- Cursor onionServices = contentResolver.query(V3_ONION_SERVICES_CONTENT_URI, null, null, null, null);
- if (onionServices != null) {
- try {
- while (onionServices.moveToNext()) {
- String domain = onionServices.getString(onionServices.getColumnIndex(OnionService.DOMAIN));
- if (domain == null || TextUtils.isEmpty(domain)) {
- String path = onionServices.getString(onionServices.getColumnIndex(OnionService.PATH));
- String v3OnionDirPath = new File(mV3OnionBasePath.getAbsolutePath(), path).getCanonicalPath();
- File hostname = new File(v3OnionDirPath, "hostname");
- if (hostname.exists()) {
- int id = onionServices.getInt(onionServices.getColumnIndex(OnionService._ID));
- domain = Utils.readString(new FileInputStream(hostname)).trim();
- ContentValues fields = new ContentValues();
- fields.put(OnionService.DOMAIN, domain);
- contentResolver.update(V3_ONION_SERVICES_CONTENT_URI, fields, OnionService._ID + "=" + id, null);
- }
- }
-
- }
- } catch (Exception e) {
- Log.i("sad","asd");
- e.printStackTrace();
- }
- onionServices.close();
- }
- }
-
- private void updateLegacyV2OnionNames() throws SecurityException {
- // Tor is running, update new .onion names at db
- ContentResolver mCR = getApplicationContext().getContentResolver();
- Cursor hidden_services = mCR.query(V2_HS_CONTENT_URI, LEGACY_V2_ONION_SERVICE_PROJECTION, null, null, null);
- if (hidden_services != null) {
- try {
- while (hidden_services.moveToNext()) {
- String HSDomain = hidden_services.getString(hidden_services.getColumnIndex(OnionService.DOMAIN));
- int HSAuthCookie = hidden_services.getInt(hidden_services.getColumnIndex(OnionService.AUTH_COOKIE));
- String HSAuthCookieValue = hidden_services.getString(hidden_services.getColumnIndex(OnionService.AUTH_COOKIE_VALUE));
- // Update only new domains or restored from backup with auth cookie
- if ((HSDomain == null || HSDomain.length() < 1) || (HSAuthCookie == 1 && (HSAuthCookieValue == null || HSAuthCookieValue.length() < 1))) {
- String hsDirPath = new File(mHSBasePath.getAbsolutePath(), hidden_services.getString(hidden_services.getColumnIndex(OnionService.PATH))).getCanonicalPath();
- File file = new File(hsDirPath, "hostname");
-
- if (file.exists()) {
- ContentValues fields = new ContentValues();
-
- try {
- int id = hidden_services.getInt(hidden_services.getColumnIndex(OnionService._ID));
- String onionHostname = Utils.readString(new FileInputStream(file)).trim();
- if (HSAuthCookie == 1) {
- String[] aux = onionHostname.split(" ");
- onionHostname = aux[0];
- fields.put(OnionService.AUTH_COOKIE_VALUE, aux[1]);
- }
- fields.put(OnionService.DOMAIN, onionHostname);
- mCR.update(V2_HS_CONTENT_URI, fields, OnionService._ID + "=" + id, null);
- } catch (FileNotFoundException e) {
- logException("unable to read onion hostname file", e);
- showToolbarNotification(getString(R.string.unable_to_read_hidden_service_name), HS_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
- }
- } else {
- showToolbarNotification(getString(R.string.unable_to_read_hidden_service_name), HS_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
- }
- }
- }
-
- } catch (NumberFormatException e) {
- Log.e(OrbotConstants.TAG, "error parsing hsport", e);
- } catch (Exception e) {
- Log.e(OrbotConstants.TAG, "error starting share server", e);
- }
-
- hidden_services.close();
- }
- }
-
- private synchronized void startTorService() throws Exception {
- updateTorConfigCustom(TorService.getDefaultsTorrc(this),
- "DNSPort 0\n" +
- "TransPort 0\n" +
- "DisableNetwork 1\n");
-
- File fileTorrcCustom = updateTorrcCustomFile();
- if ((!fileTorrcCustom.exists()) || (!fileTorrcCustom.canRead()))
- return;
-
- sendCallbackLogMessage(getString(R.string.status_starting_up));
-
- torServiceConnection = new ServiceConnection() {
- @Override
- public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
- new Thread(){
- public void run(){
- torService = ((TorService.LocalBinder) iBinder).getService();
- try {
- conn = torService.getTorControlConnection();
- while (conn == null) {
- Log.v(TAG, "Waiting for Tor Control Connection...");
- Thread.sleep(500);
- conn = torService.getTorControlConnection();
- }
- sleep(2000);
- mEventHandler = new TorEventHandler(OrbotService.this);
- logNotice("adding control port event handler");
- conn.setEventHandler(mEventHandler);
- ArrayList events = new ArrayList<>(Arrays.asList(
- TorControlCommands.EVENT_OR_CONN_STATUS,
- TorControlCommands.EVENT_CIRCUIT_STATUS,
- TorControlCommands.EVENT_NOTICE_MSG,
- TorControlCommands.EVENT_WARN_MSG,
- TorControlCommands.EVENT_ERR_MSG,
- TorControlCommands.EVENT_BANDWIDTH_USED,
- TorControlCommands.EVENT_NEW_DESC,
- TorControlCommands.EVENT_ADDRMAP));
- if (Prefs.useDebugLogging()) {
- events.add(TorControlCommands.EVENT_DEBUG_MSG);
- events.add(TorControlCommands.EVENT_INFO_MSG);
- }
-
- conn.setEvents(events);
- initControlConnection();
- logNotice("SUCCESS added control port event handler");
- } catch (InterruptedException | IOException e) {
- e.printStackTrace();
- stopTorOnError(e.getLocalizedMessage());
- conn = null;
- }
- }
- }.start();
- }
-
- @Override
- public void onServiceDisconnected(ComponentName componentName) {
- conn = null;
- torService = null;
- mEventHandler = null;
- }
-
- @Override
- public void onNullBinding(ComponentName componentName) {
- stopTorOnError("Tor was unable to start: " + "onNullBinding");
- conn = null;
- torService = null;
- mEventHandler = null;
- }
-
- @Override
- public void onBindingDied(ComponentName componentName) {
- stopTorOnError("Tor was unable to start: " + "onBindingDied");
- conn = null;
- torService = null;
- mEventHandler = null;
- }
- };
-
- BroadcastReceiver receiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- if (TorService.ACTION_STATUS.equals(intent.getAction())
- && TorService.STATUS_ON.equals(intent.getStringExtra(TorService.EXTRA_STATUS))) {
- initControlConnection();
- unregisterReceiver(this);
- }
- }
- };
- // run the BroadcastReceiver in its own thread
- HandlerThread handlerThread = new HandlerThread(receiver.getClass().getSimpleName());
- handlerThread.start();
- Looper looper = handlerThread.getLooper();
- Handler handler = new Handler(looper);
- registerReceiver(receiver, new IntentFilter(TorService.ACTION_STATUS), null, handler);
-
- Intent serviceIntent = new Intent(this, TorService.class);
- if (Build.VERSION.SDK_INT < 29) {
- shouldUnbindTorService = bindService(serviceIntent, torServiceConnection, BIND_AUTO_CREATE);
- } else {
- shouldUnbindTorService = bindService(serviceIntent, BIND_AUTO_CREATE, mExecutor, torServiceConnection);
- }
- }
-
- protected void exec(Runnable runn) {
- mExecutor.execute(runn);
- }
-
- public int getNotifyId() {
- return NOTIFY_ID;
- }
-
- public String getProxyStatus() {
- return mCurrentStatus;
- }
-
- private static OrbotService self = null;
-
- public static OrbotService getServiceObject(){
- return self;
- }
-
- private boolean mConnectivity = true;
- private int mNetworkType = -1;
- private final BroadcastReceiver mNetworkStateReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
-
- SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
-
- if(prefs==null){
- }
-
- boolean doNetworKSleep = prefs.getBoolean(OrbotConstants.PREF_DISABLE_NETWORK, true);
-
- final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
- final NetworkInfo netInfo = cm.getActiveNetworkInfo();
-
- boolean newConnectivityState;
- int newNetType = -1;
-
- if (netInfo!=null)
- newNetType = netInfo.getType();
-
- if(netInfo != null && netInfo.isConnected()) {
- // WE ARE CONNECTED: DO SOMETHING
- newConnectivityState = true;
- }
- else {
- // WE ARE NOT: DO SOMETHING ELSE
- newConnectivityState = false;
- }
-
- mNetworkType = newNetType;
-
- if (newConnectivityState != mConnectivity) {
- mConnectivity = newConnectivityState;
- orbotLocalConstants.mNetworkState = mConnectivity;
-
- if (mConnectivity){
- newIdentity();
- }
- }
-
- if (doNetworKSleep)
- {
- //setTorNetworkEnabled (mConnectivity);
- if (!mConnectivity)
- {
- //sendCallbackStatus(STATUS_OFF);
- orbotLocalConstants.mTorLogsStatus = "No internet connection";
- if(orbotLocalConstants.mNotificationStatus!=0){
- showToolbarNotification(getString(R.string.newnym), getNotifyId(), R.drawable.ic_stat_tor_off);
- showToolbarNotification("Genesis is sleeping | Internet connectivity issue",NOTIFY_ID,R.drawable.ic_stat_tor_off);
- }
- }
- else
- {
- //sendCallbackStatus(STATUS_STARTING);
- if(orbotLocalConstants.mNotificationStatus!=0){
- showToolbarNotification(getString(R.string.status_starting_up),NOTIFY_ID,R.drawable.ic_stat_starting_tor_logo);
- }
- }
-
- }
- orbotLocalConstants.mNetworkState = mConnectivity;
- }
- };
-
- private void initControlConnection() {
- if (conn != null) {
- logNotice("SUCCESS connected to Tor control port.");
- try {
- String confSocks = conn.getInfo("net/listeners/socks");
- StringTokenizer st = new StringTokenizer(confSocks, " ");
-
- confSocks = st.nextToken().split(":")[1];
- confSocks = confSocks.substring(0, confSocks.length() - 1);
- mPortSOCKS = Integer.parseInt(confSocks);
-
- String confHttp = conn.getInfo("net/listeners/httptunnel");
- st = new StringTokenizer(confHttp, " ");
-
- confHttp = st.nextToken().split(":")[1];
- confHttp = confHttp.substring(0, confHttp.length() - 1);
- mPortHTTP = Integer.parseInt(confHttp);
-
- String confDns = conn.getInfo("net/listeners/dns");
- st = new StringTokenizer(confDns, " ");
- if (st.hasMoreTokens()) {
- confDns = st.nextToken().split(":")[1];
- confDns = confDns.substring(0, confDns.length() - 1);
- mPortDns = Integer.parseInt(confDns);
- Prefs.getSharedPrefs(getApplicationContext()).edit().putInt(VpnPrefs.PREFS_DNS_PORT, mPortDns).apply();
- }
-
- String confTrans = conn.getInfo("net/listeners/trans");
- st = new StringTokenizer(confTrans, " ");
- if (st.hasMoreTokens()) {
- confTrans = st.nextToken().split(":")[1];
- confTrans = confTrans.substring(0, confTrans.length() - 1);
- mPortTrans = Integer.parseInt(confTrans);
- }
-
- sendCallbackPorts(mPortSOCKS, mPortHTTP, mPortDns, mPortTrans);
- orbotLocalConstants.mIsTorInitialized = true;
-
- } catch (IOException e) {
- Log.i("sad","asd");
- e.printStackTrace();
- stopTorOnError(e.getLocalizedMessage());
- conn = null;
- }
- }
- }
-
- public void sendSignalActive() {
- if (conn != null && mCurrentStatus == STATUS_ON) {
- try {
- conn.signal("ACTIVE");
- } catch (IOException e) {
- debug("error send active: " + e.getLocalizedMessage());
- }
- }
- }
-
- public void newIdentity() {
- //it is possible to not have a connection yet, and someone might try to newnym
- if (conn != null) {
- new Thread() {
- public void run() {
- try {
- int iconId = R.mipmap.ic_stat_tor_logo;
-
- if (conn != null && mCurrentStatus == STATUS_ON && Prefs.expandedNotifications() && mConnectivity)
- showToolbarNotification(getString(R.string.newnym), NOTIFY_ID, R.drawable.ic_stat_starting_tor_logo);
-
- conn.signal(TorControlCommands.SIGNAL_NEWNYM);
-
- sleep(1000);
- if(mConnectivity)
- enableNotification();
-
- } catch (Exception ioe) {
- debug("error requesting newnym: " + ioe.getLocalizedMessage());
- }
- }
- }.start();
- }
- }
-
- protected void sendCallbackBandwidth(long lastWritten, long lastRead, long totalWritten, long totalRead) {
- Intent intent = new Intent(LOCAL_ACTION_BANDWIDTH);
-
- intent.putExtra("totalWritten", totalWritten);
- intent.putExtra("totalRead", totalRead);
- intent.putExtra("lastWritten", lastWritten);
- intent.putExtra("lastRead", lastRead);
- intent.putExtra(EXTRA_STATUS, mCurrentStatus);
-
- LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
- }
-
- int e=0;
- String mPrevLogs = "";
- private void sendCallbackLogMessage(String logMessage)
- {
- if(mPrevLogs.equals(logMessage)){
- return;
- }else {
- mPrevLogs = logMessage;
- }
- if(logMessage.contains("Bootstrapped 100%")){
- orbotLocalConstants.mIsTorInitialized = true;
- }
- mHandler.post(() -> {
- Intent intent = new Intent(LOCAL_ACTION_LOG);
- intent.putExtra(LOCAL_EXTRA_LOG, logMessage);
- intent.putExtra(EXTRA_STATUS, mCurrentStatus);
- orbotLocalConstants.mTorLogsHistory.add(new logRowModel(logMessage, localHelperMethod.getCurrentTime()));
-
- if(!mConnectivity){
- orbotLocalConstants.mTorLogsStatus = "No internet connection";
- }else {
- orbotLocalConstants.mTorLogsStatus = logMessage;
- }
- LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
- });
-
- }
-
- public boolean getConnectivity(){
- return mConnectivity;
- }
-
- private void sendCallbackPorts(int socksPort, int httpPort, int dnsPort, int transPort) {
-
- orbotLocalConstants.mSOCKSPort = socksPort;
- orbotLocalConstants.mHTTPPort = httpPort;
-
- Intent intent = new Intent(LOCAL_ACTION_PORTS); // You can also include some extra data.
- intent.putExtra(EXTRA_SOCKS_PROXY_PORT, socksPort);
- intent.putExtra(EXTRA_HTTP_PROXY_PORT, httpPort);
- intent.putExtra(EXTRA_DNS_PORT, dnsPort);
- intent.putExtra(EXTRA_TRANS_PORT, transPort);
-
- LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
-
- if (Prefs.useVpn())
- mVpnManager.handleIntent(new Builder(), intent);
-
- }
-
- protected void sendCallbackStatus(String currentStatus) {
- mCurrentStatus = currentStatus;
- Intent intent = getActionStatusIntent(currentStatus);
- sendBroadcastOnlyToOrbot(intent); // send for Orbot internals, using secure local broadcast
- sendBroadcast(intent); // send for any apps that are interested
- }
-
- /**
- * Send a secure broadcast only to Orbot itself
- *
- * @see {@link ContextWrapper#sendBroadcast(Intent)}
- * @see {@link LocalBroadcastManager}
- */
- private boolean sendBroadcastOnlyToOrbot(Intent intent) {
- return LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
- }
-
- private Intent getActionStatusIntent(String currentStatus) {
- Intent intent = new Intent(ACTION_STATUS);
- intent.putExtra(EXTRA_STATUS, currentStatus);
- return intent;
- }
-
- private StringBuffer processSettingsImpl(StringBuffer extraLines) throws IOException {
- logNotice(getString(R.string.updating_settings_in_tor_service));
- SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
-
- boolean useBridges = Prefs.bridgesEnabled();
- boolean becomeRelay = prefs.getBoolean(OrbotConstants.PREF_OR, false);
- boolean ReachableAddresses = prefs.getBoolean(OrbotConstants.PREF_REACHABLE_ADDRESSES, false);
- boolean enableStrictNodes = prefs.getBoolean("pref_strict_nodes", false);
- String entranceNodes = prefs.getString("pref_entrance_nodes", "");
- String exitNodes = prefs.getString("pref_exit_nodes", "");
- String excludeNodes = prefs.getString("pref_exclude_nodes", "");
-
- if (!useBridges) {
- extraLines.append("UseBridges 0").append('\n');
- if (Prefs.useVpn()) { //set the proxy here if we aren't using a bridge
- if (!mIsLollipop) {
- String proxyType = "socks5";
- extraLines.append(proxyType + "Proxy" + ' ' + OrbotVpnManager.sSocksProxyLocalhost + ':' + OrbotVpnManager.sSocksProxyServerPort).append('\n');
- }
-
- } else {
- String proxyType = prefs.getString("pref_proxy_type", null);
- if (proxyType != null && proxyType.length() > 0) {
- String proxyHost = prefs.getString("pref_proxy_host", null);
- String proxyPort = prefs.getString("pref_proxy_port", null);
- String proxyUser = prefs.getString("pref_proxy_username", null);
- String proxyPass = prefs.getString("pref_proxy_password", null);
-
- if ((proxyHost != null && proxyHost.length() > 0) && (proxyPort != null && proxyPort.length() > 0)) {
- extraLines.append(proxyType).append("Proxy").append(' ').append(proxyHost).append(':').append(proxyPort).append('\n');
-
- if (proxyUser != null && proxyPass != null) {
- if (proxyType.equalsIgnoreCase("socks5")) {
- extraLines.append("Socks5ProxyUsername").append(' ').append(proxyUser).append('\n');
- extraLines.append("Socks5ProxyPassword").append(' ').append(proxyPass).append('\n');
- } else
- extraLines.append(proxyType).append("ProxyAuthenticator").append(' ').append(proxyUser).append(':').append(proxyPort).append('\n');
-
- } else if (proxyPass != null)
- extraLines.append(proxyType).append("ProxyAuthenticator").append(' ').append(proxyUser).append(':').append(proxyPort).append('\n');
- }
- }
- }
- } else {
-
- loadBridgeDefaults();
- extraLines.append("UseBridges 1").append('\n');
- // extraLines.append("UpdateBridgesFromAuthority 1").append('\n');
-
- String bridgeList = Prefs.getBridgesList();
-
- String builtInBridgeType = null;
-
- //check if any PT bridges are needed
- if (bridgeList.contains("obfs")) {
-
- extraLines.append("ClientTransportPlugin obfs3 socks5 127.0.0.1:" + IPtProxy.obfs3Port()).append('\n');
- extraLines.append("ClientTransportPlugin obfs4 socks5 127.0.0.1:" + IPtProxy.obfs4Port()).append('\n');
-
- if (bridgeList.equals("obfs4"))
- builtInBridgeType = "obfs4";
- }
-
- if (bridgeList.equals("meek")) {
- extraLines.append("ClientTransportPlugin meek_lite socks5 127.0.0.1:" + IPtProxy.meekPort()).append('\n');
- builtInBridgeType = "meek_lite";
- }
-
- if (bridgeList.equals("snowflake")) {
- extraLines.append("ClientTransportPlugin snowflake socks5 127.0.0.1:" + IPtProxy.snowflakePort()).append('\n');
- builtInBridgeType = "snowflake";
- }
-
- if (!TextUtils.isEmpty(builtInBridgeType))
- getBridges(builtInBridgeType, extraLines);
- else {
- String[] bridgeListLines = parseBridgesFromSettings(bridgeList);
- int bridgeIdx = (int) Math.floor(Math.random() * ((double) bridgeListLines.length));
- String bridgeLine = bridgeListLines[bridgeIdx];
- extraLines.append("Bridge ");
- extraLines.append(bridgeLine);
- extraLines.append("\n");
- }
- }
-
- //only apply GeoIP if you need it
- File fileGeoIP = new File(appBinHome, GEOIP_ASSET_KEY);
- File fileGeoIP6 = new File(appBinHome, GEOIP6_ASSET_KEY);
-
- if (fileGeoIP.exists()) {
- extraLines.append("GeoIPFile" + ' ').append(fileGeoIP.getCanonicalPath()).append('\n');
- extraLines.append("GeoIPv6File" + ' ').append(fileGeoIP6.getCanonicalPath()).append('\n');
- }
-
- if (!TextUtils.isEmpty(entranceNodes))
- extraLines.append("EntryNodes" + ' ').append(entranceNodes).append('\n');
-
- if (!TextUtils.isEmpty(exitNodes))
- extraLines.append("ExitNodes" + ' ').append(exitNodes).append('\n');
-
- if (!TextUtils.isEmpty(excludeNodes))
- extraLines.append("ExcludeNodes" + ' ').append(excludeNodes).append('\n');
-
- extraLines.append("StrictNodes" + ' ').append(enableStrictNodes ? "1" : "0").append('\n');
-
- try {
- if (ReachableAddresses) {
- String ReachableAddressesPorts = prefs.getString(OrbotConstants.PREF_REACHABLE_ADDRESSES_PORTS, "*:80,*:443");
- extraLines.append("ReachableAddresses" + ' ').append(ReachableAddressesPorts).append('\n');
- }
-
- } catch (Exception e) {
- showToolbarNotification(getString(R.string.your_reachableaddresses_settings_caused_an_exception_), ERROR_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
- return null;
- }
-
- try {
- if (becomeRelay && (!useBridges) && (!ReachableAddresses)) {
- int ORPort = Integer.parseInt(Objects.requireNonNull(prefs.getString(OrbotConstants.PREF_OR_PORT, "9001")));
- String nickname = prefs.getString(OrbotConstants.PREF_OR_NICKNAME, "Orbot");
- String dnsFile = writeDNSFile();
-
- extraLines.append("ServerDNSResolvConfFile").append(' ').append(dnsFile).append('\n');
- extraLines.append("ORPort").append(' ').append(ORPort).append('\n');
- extraLines.append("Nickname").append(' ').append(nickname).append('\n');
- extraLines.append("ExitPolicy").append(' ').append("reject *:*").append('\n');
-
- }
- } catch (Exception e) {
- showToolbarNotification(getString(R.string.your_relay_settings_caused_an_exception_), ERROR_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
- return null;
- }
-
- if (false) {
- ContentResolver contentResolver = getApplicationContext().getContentResolver();
- addV3OnionServicesToTorrc(extraLines, contentResolver);
- addV3ClientAuthToTorrc(extraLines, contentResolver);
- addV2HiddenServicesToTorrc(extraLines, contentResolver);
- addV2ClientCookiesToTorrc(extraLines, contentResolver);
- }
-
- return extraLines;
- }
-
- public static String formatBandwidthCount(Context context, long bitsPerSecond) {
- NumberFormat nf = NumberFormat.getInstance(Locale.getDefault());
- if (bitsPerSecond < 1e6)
- return nf.format(Math.round(((float) ((int) (bitsPerSecond * 10 / 1024)) / 10)))
- + "kbps";
- else
- return nf.format(Math.round(((float) ((int) (bitsPerSecond * 100 / 1024 / 1024)) / 100)))
- + "mbps";
- }
-
- private void addV3OnionServicesToTorrc(StringBuffer torrc, ContentResolver contentResolver) {
- try {
- Cursor onionServices = contentResolver.query(V3_ONION_SERVICES_CONTENT_URI, V3_ONION_SERVICE_PROJECTION, OnionService.ENABLED + "=1", null, null);
- if (onionServices != null) {
- while (onionServices.moveToNext()) {
- int id = onionServices.getInt(onionServices.getColumnIndex(OnionService._ID));
- int localPort = onionServices.getInt(onionServices.getColumnIndex(OnionService.PORT));
- int onionPort = onionServices.getInt(onionServices.getColumnIndex(OnionService.ONION_PORT));
- String path = onionServices.getString(onionServices.getColumnIndex(OnionService.PATH));
- String domain = onionServices.getString(onionServices.getColumnIndex(OnionService.DOMAIN));
- if (path == null) {
- path = "v3";
- if (domain == null)
- path += UUID.randomUUID().toString();
- else
- path += localPort;
- ContentValues cv = new ContentValues();
- cv.put(OnionService.PATH, path);
- contentResolver.update(V3_ONION_SERVICES_CONTENT_URI, cv, OnionService._ID + "=" + id, null);
- }
- String v3DirPath = new File(mV3OnionBasePath.getAbsolutePath(), path).getCanonicalPath();
- torrc.append("HiddenServiceDir ").append(v3DirPath).append("\n");
- torrc.append("HiddenServiceVersion 3").append("\n");
- torrc.append("HiddenServicePort ").append(onionPort).append(" 127.0.0.1:").append(localPort).append("\n");
- }
- onionServices.close();
- }
- } catch (Exception e) {
- Log.i("sad","asd");
- Log.e(TAG, e.getLocalizedMessage());
- }
- }
-
- private void addV2HiddenServicesToTorrc(StringBuffer torrc, ContentResolver contentResolver) {
- try {
- Cursor hidden_services = contentResolver.query(V2_HS_CONTENT_URI, LEGACY_V2_ONION_SERVICE_PROJECTION, OnionService.ENABLED + "=1", null, null);
- if (hidden_services != null) {
- try {
- while (hidden_services.moveToNext()) {
- int id = hidden_services.getInt(hidden_services.getColumnIndex(OnionService._ID));
- String HSname = hidden_services.getString(hidden_services.getColumnIndex(OnionService.NAME));
- String domain = hidden_services.getString(hidden_services.getColumnIndex(OnionService.DOMAIN));
- int HSLocalPort = hidden_services.getInt(hidden_services.getColumnIndex(OnionService.PORT));
- int HSOnionPort = hidden_services.getInt(hidden_services.getColumnIndex(OnionService.ONION_PORT));
- int HSAuthCookie = hidden_services.getInt(hidden_services.getColumnIndex(OnionService.AUTH_COOKIE));
- String path = hidden_services.getString(hidden_services.getColumnIndex(OnionService.PATH));
-
- // logic to fix bug where you can't have 2+ hidden services on same local port without breaking services that were configured before the bug fix
- if (path == null) {
- String newPath = "hs";
- if (domain == null)
- newPath +=UUID.randomUUID().toString();
- else
- newPath += HSLocalPort;
-
- ContentValues cv = new ContentValues();
- cv.put(OnionService.PATH, newPath);
- contentResolver.update(V2_HS_CONTENT_URI, cv, OnionService._ID + "=" + id, null);
- path = newPath;
- }
-
- String hsDirPath = new File(mHSBasePath.getAbsolutePath(), path).getCanonicalPath();
-
-
- debug("Adding hidden service on port: " + HSLocalPort);
-
- torrc.append("HiddenServiceDir" + ' ' + hsDirPath).append('\n');
- torrc.append("HiddenServiceVersion 2").append('\n');
- torrc.append("HiddenServicePort" + ' ' + HSOnionPort + " 127.0.0.1:" + HSLocalPort).append('\n');
-
- if (HSAuthCookie == 1)
- torrc.append("HiddenServiceAuthorizeClient stealth " + HSname).append('\n');
- }
- } catch (NumberFormatException e) {
- Log.e(OrbotConstants.TAG, "error parsing hsport", e);
- } catch (Exception e) {
- Log.e(OrbotConstants.TAG, "error starting share server", e);
- }
-
- hidden_services.close();
- }
- } catch (SecurityException se) {
- Log.i("sad","asd");
- }
- }
-
- public static String buildV3ClientAuthFile(String domain, String keyHash) {
- return domain + ":descriptor:x25519:" + keyHash;
- }
-
- private void addV3ClientAuthToTorrc(StringBuffer torrc, ContentResolver contentResolver) {
- Cursor v3auths = contentResolver.query(V3_CLIENT_AUTH_URI, V3_CLIENT_AUTH_PROJECTION, V3ClientAuth.ENABLED + "=1", null, null);
- if (v3auths != null) {
- for (File file : mV3AuthBasePath.listFiles()) {
- if (!file.isDirectory())
- file.delete(); // todo the adapter should maybe just write these files and not do this in service...
- }
- torrc.append("ClientOnionAuthDir " + mV3AuthBasePath.getAbsolutePath()).append('\n');
- try {
- int i = 0;
- while (v3auths.moveToNext()) {
- String domain = v3auths.getString(v3auths.getColumnIndex(V3ClientAuth.DOMAIN));
- String hash = v3auths.getString(v3auths.getColumnIndex(V3ClientAuth.HASH));
- File authFile = new File(mV3AuthBasePath, (i++) + ".auth_private");
- authFile.createNewFile();
- FileOutputStream fos = new FileOutputStream(authFile);
- fos.write(buildV3ClientAuthFile(domain, hash).getBytes());
- fos.close();
- }
- } catch (Exception e) {
- Log.e(TAG, "error adding v3 client auth...");
- }
- }
- }
-
- private void addV2ClientCookiesToTorrc(StringBuffer torrc, ContentResolver contentResolver) {
- try {
- Cursor client_cookies = contentResolver.query(COOKIE_CONTENT_URI, LEGACY_COOKIE_PROJECTION, ClientCookie.ENABLED + "=1", null, null);
- if (client_cookies != null) {
- try {
- while (client_cookies.moveToNext()) {
- String domain = client_cookies.getString(client_cookies.getColumnIndex(ClientCookie.DOMAIN));
- String cookie = client_cookies.getString(client_cookies.getColumnIndex(ClientCookie.AUTH_COOKIE_VALUE));
- torrc.append("HidServAuth" + ' ' + domain + ' ' + cookie).append('\n');
- }
- } catch (Exception e) {
- Log.e(OrbotConstants.TAG, "error starting share server", e);
- }
- client_cookies.close();
- }
- } catch (SecurityException se) {
- Log.i("sad","asd");
- }
- }
-
- //using Google DNS for now as the public DNS server
- private String writeDNSFile() throws IOException {
- File file = new File(appBinHome, "resolv.conf");
-
- PrintWriter bw = new PrintWriter(new FileWriter(file));
- bw.println("nameserver 8.8.8.8");
- bw.println("nameserver 8.8.4.4");
- bw.close();
-
- return file.getCanonicalPath();
- }
-
- @SuppressLint("NewApi")
- @Override
- public void onTrimMemory(int level) {
- super.onTrimMemory(level);
-
- switch (level) {
- case TRIM_MEMORY_BACKGROUND:
- debug("trim memory requested: app in the background");
- break;
-
- case TRIM_MEMORY_COMPLETE:
- debug("trim memory requested: cleanup all memory");
- break;
-
- case TRIM_MEMORY_MODERATE:
- debug("trim memory requested: clean up some memory");
- break;
-
- case TRIM_MEMORY_RUNNING_CRITICAL:
- debug("trim memory requested: memory on device is very low and critical");
- break;
-
- case TRIM_MEMORY_RUNNING_LOW:
- debug("trim memory requested: memory on device is running low");
- break;
-
- case TRIM_MEMORY_RUNNING_MODERATE:
- debug("trim memory requested: memory on device is moderate");
- break;
-
- case TRIM_MEMORY_UI_HIDDEN:
- debug("trim memory requested: app is not showing UI anymore");
- break;
- }
- }
-
- @Override
- public IBinder onBind(Intent intent) {
- Log.e(TAG, "onBind");
- return super.onBind(intent); // invoking super class will call onRevoke() when appropriate
- }
-
- // system calls this method when VPN disconnects (either by the user or another VPN app)
- @Override
- public void onRevoke() {
- Prefs.putUseVpn(false);
- mVpnManager.handleIntent(new Builder(), new Intent(ACTION_STOP_VPN));
- // tell UI, if it's open, to update immediately (don't wait for onResume() in Activity...)
- LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(ACTION_STOP_VPN));
- }
-
- private void setExitNode(String newExits) {
- SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
-
- if (TextUtils.isEmpty(newExits)) {
- prefs.edit().remove("pref_exit_nodes").apply();
-
- if (conn != null) {
- try {
- ArrayList resetBuffer = new ArrayList<>();
- resetBuffer.add("ExitNodes");
- resetBuffer.add("StrictNodes");
- conn.resetConf(resetBuffer);
- conn.setConf("DisableNetwork", "1");
- conn.setConf("DisableNetwork", "0");
-
- } catch (Exception ioe) {
- Log.e(OrbotConstants.TAG, "Connection exception occured resetting exits", ioe);
- }
- }
- } else {
- prefs.edit().putString("pref_exit_nodes", newExits).apply();
-
- if (conn != null) {
- try {
- File fileGeoIP = new File(appBinHome, GEOIP_ASSET_KEY);
- File fileGeoIP6 = new File(appBinHome, GEOIP6_ASSET_KEY);
-
- conn.setConf("GeoIPFile", fileGeoIP.getCanonicalPath());
- conn.setConf("GeoIPv6File", fileGeoIP6.getCanonicalPath());
-
- conn.setConf("ExitNodes", newExits);
- conn.setConf("StrictNodes", "1");
-
- conn.setConf("DisableNetwork", "1");
- conn.setConf("DisableNetwork", "0");
-
- } catch (Exception ioe) {
- Log.e(OrbotConstants.TAG, "Connection exception occured resetting exits", ioe);
- }
- }
- }
-
- }
-
- private void loadBridgeDefaults() {
- if (alBridges == null) {
- alBridges = new ArrayList<>();
-
- try {
-
- BufferedReader in = new BufferedReader(new InputStreamReader(getResources().openRawResource(R.raw.bridges), "UTF-8"));
-
- if(mBridgesDefault.length()>1){
- Reader inputString = new StringReader(mBridgesDefault);
- in = new BufferedReader(inputString);
- }
- String str;
-
- while ((str = in.readLine()) != null) {
-
- StringTokenizer st = new StringTokenizer(str, " ");
- Bridge b = new Bridge();
- b.type = st.nextToken();
-
- StringBuffer sbConfig = new StringBuffer();
-
- while (st.hasMoreTokens())
- sbConfig.append(st.nextToken()).append(' ');
-
- b.config = sbConfig.toString().trim();
-
- alBridges.add(b);
-
- }
-
- in.close();
- } catch (Exception e) {
- Log.i("sad","asd");
- e.printStackTrace();
- }
- }
-
- }
-
- private void getBridges(String type, StringBuffer extraLines) {
-
- Collections.shuffle(alBridges, bridgeSelectRandom);
-
- int maxBridges = 12;
- int bridgeCount = 0;
-
-
- if(orbotLocalConstants.mIsManualBridge){
- List mList = Arrays.asList(orbotLocalConstants.mBridges.split("\n"));
- alBridges.clear();
-
- for(int e=0;e maxBridges)
- break;
- }
- }
- }
-
-
- public static final class OnionService implements BaseColumns {
- public static final String NAME = "name";
- public static final String PORT = "port";
- public static final String ONION_PORT = "onion_port";
- public static final String DOMAIN = "domain";
- public static final String AUTH_COOKIE = "auth_cookie";
- public static final String AUTH_COOKIE_VALUE = "auth_cookie_value";
- public static final String ENABLED = "enabled";
- public static final String PATH = "filepath";
- }
-
- public static final class V3ClientAuth implements BaseColumns {
- public static final String DOMAIN = "domain";
- public static final String HASH = "hash";
- public static final String ENABLED = "enabled";
- }
-
- public static final class ClientCookie implements BaseColumns {
- public static final String DOMAIN = "domain";
- public static final String AUTH_COOKIE_VALUE = "auth_cookie_value";
- public static final String ENABLED = "enabled";
- }
-
- // for bridge loading from the assets default bridges.txt file
- static class Bridge {
- String type;
- String config;
-
- public Bridge(String pConfig,String pType){
- config = pConfig;
- type = pType;
- }
-
- public Bridge(){
- }
- }
-
- private class IncomingIntentRouter implements Runnable {
- Intent mIntent;
-
- public IncomingIntentRouter(Intent intent) {
- mIntent = intent;
- }
-
- public void run() {
- String action = mIntent.getAction();
-
- if (!TextUtils.isEmpty(action)) {
- if (action.equals(ACTION_START) || action.equals(ACTION_START_ON_BOOT)) {
-
- if (Prefs.bridgesEnabled()) {
- if (useIPtObfsMeekProxy())
- IPtProxy.startObfs4Proxy("DEBUG", false, false);
- else if (useIPtSnowflakeProxy())
- startSnowflakeClient();
- } else if (Prefs.beSnowflakeProxy()) {
-
- if (Prefs.limitSnowflakeProxying())
- {
- if (isChargingAndWifi(OrbotService.this))
- {
- enableSnowflakeProxy();
- }
-
- }
- else
- enableSnowflakeProxy();
- }
-
- startTor();
- replyWithStatus(mIntent);
-
- if (Prefs.useVpn()) {
- if (mVpnManager != null
- && (!mVpnManager.isStarted())) {
- //start VPN here
- Intent vpnIntent = VpnService.prepare(OrbotService.this);
- if (vpnIntent == null) //then we can run the VPN
- {
- mVpnManager.handleIntent(new Builder(), mIntent);
-
- }
- }
-
- if (mPortSOCKS != -1 && mPortHTTP != -1)
- sendCallbackPorts(mPortSOCKS, mPortHTTP, mPortDns, mPortTrans);
- }
- } else if (action.equals(ACTION_STOP)) {
- stopTorAsync();
- } else if (action.equals(ACTION_START_VPN)) {
- if (mVpnManager != null && (!mVpnManager.isStarted())) {
- //start VPN here
- Intent vpnIntent = VpnService.prepare(OrbotService.this);
- if (vpnIntent == null) { //then we can run the VPN
- mVpnManager.handleIntent(new Builder(), mIntent);
- }
- }
-
- if (mPortSOCKS != -1 && mPortHTTP != -1)
- sendCallbackPorts(mPortSOCKS, mPortHTTP, mPortDns, mPortTrans);
-
-
- } else if (action.equals(ACTION_STOP_VPN)) {
- if (mVpnManager != null)
- mVpnManager.handleIntent(new Builder(), mIntent);
- } else if (action.equals(ACTION_STATUS)) {
- replyWithStatus(mIntent);
- } else if (action.equals(TorControlCommands.SIGNAL_RELOAD)) {
- requestTorRereadConfig();
- } else if (action.equals(TorControlCommands.SIGNAL_NEWNYM)) {
- newIdentity();
- } else if (action.equals(CMD_ACTIVE)) {
- sendSignalActive();
- } else if (action.equals(CMD_SET_EXIT)) {
- setExitNode(mIntent.getStringExtra("exit"));
- } else {
- Log.w(OrbotConstants.TAG, "unhandled OrbotService Intent: " + action);
- }
- }
- }
- }
-
- 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(){
- if(mNotificationManager!=null){
- mNotificationManager.cancel(NOTIFY_ID);
- stopForeground(true);
- orbotLocalConstants.mNotificationStatus = 0;
- }
- }
-
- public void enableTorNotificationNoBandwidth(){
- orbotLocalConstants.mNotificationStatus = 1;
- showToolbarNotification("Connected to the Tor network", HS_NOTIFY_ID, R.mipmap.ic_stat_tor_logo);
- }
-
- public void enableNotification(){
- if(mConnectivity && orbotLocalConstants.mIsTorInitialized){
- orbotLocalConstants.mNotificationStatus = 1;
- showToolbarNotification(0+"kbps ⇣ / " +0+"kbps ⇡", HS_NOTIFY_ID, R.mipmap.ic_stat_tor_logo);
- }
- }
-
- public void onSettingRegister(){
- try {
- Intent intent = null;
- intent = new Intent(this, Class.forName("com.darkweb.genesissearchengine.appManager.settingManager.notificationManager.settingNotificationController"));
- intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
- getApplicationContext().startActivity(intent);
- } catch (ClassNotFoundException e) {
- Log.i("sad","asd");
- e.printStackTrace();
- }
- }
-
- 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 {
- public void onReceive(Context context, Intent intent) {
- switch (intent.getAction()) {
- case CMD_NEWNYM: {
- newIdentity();
- break;
- }
- case CMD_SETTING: {
- onSettingRegister();
- break;
- }
- case CMD_ACTIVE: {
- sendSignalActive();
- break;
- }
- }
- }
- }
-
-}
+package org.orbotproject.android.service;
+
+import android.annotation.SuppressLint;
+import android.app.Application;
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.app.Service;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.ContentResolver;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.ContextWrapper;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.ServiceConnection;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
+import android.database.Cursor;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.Uri;
+import android.net.VpnService;
+import android.os.BatteryManager;
+import android.os.Build;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.IBinder;
+import android.os.Looper;
+import android.provider.BaseColumns;
+import android.text.TextUtils;
+import android.util.Log;
+
+import net.freehaven.tor.control.TorControlCommands;
+import net.freehaven.tor.control.TorControlConnection;
+
+import org.orbotproject.android.service.util.CustomTorResourceInstaller;
+import org.orbotproject.android.service.util.DummyActivity;
+import org.orbotproject.android.service.util.Prefs;
+import org.orbotproject.android.service.util.TorServiceUtils;
+import org.orbotproject.android.service.util.Utils;
+import org.orbotproject.android.service.vpn.OrbotVpnManager;
+import org.orbotproject.android.service.vpn.VpnPrefs;
+import org.orbotproject.android.service.wrapper.localHelperMethod;
+import org.orbotproject.android.service.wrapper.logRowModel;
+import org.orbotproject.android.service.wrapper.orbotLocalConstants;
+import org.torproject.jni.TorService;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringReader;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Objects;
+import java.util.Random;
+import java.util.StringTokenizer;
+import java.util.UUID;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeoutException;
+
+import IPtProxy.IPtProxy;
+import androidx.annotation.RequiresApi;
+import androidx.core.app.NotificationCompat;
+import androidx.localbroadcastmanager.content.LocalBroadcastManager;
+
+import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
+
+public class OrbotService extends VpnService implements TorServiceConstants, OrbotConstants {
+
+ public final static String BINARY_TOR_VERSION = TorService.VERSION_NAME;
+
+ static final int NOTIFY_ID = 1;
+ private static final int ERROR_NOTIFY_ID = 3;
+ private static final int HS_NOTIFY_ID = 4;
+ private static final Uri V2_HS_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.hiddenservices.providers.genesishiddenservices/hs");
+ private static final Uri V3_ONION_SERVICES_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.v3onionservice.genesishiddenservices/v3");
+ private static final Uri COOKIE_CONTENT_URI = Uri.parse("content://org.torproject.android.ui.hiddenservices.providers.genesishiddenservices.cookie/cookie");
+ private static final Uri V3_CLIENT_AUTH_URI = Uri.parse("content://org.torproject.android.ui.v3onionservice.genesishiddenservices.clientauth/v3auth");
+ private final static String NOTIFICATION_CHANNEL_ID = "orbot_channel_1";
+ private static final String[] LEGACY_V2_ONION_SERVICE_PROJECTION = new String[]{
+ OnionService._ID,
+ OnionService.NAME,
+ OnionService.DOMAIN,
+ OnionService.PORT,
+ OnionService.AUTH_COOKIE,
+ OnionService.AUTH_COOKIE_VALUE,
+ OnionService.ONION_PORT,
+ OnionService.ENABLED,
+ OnionService.PATH};
+ private static final String[] V3_ONION_SERVICE_PROJECTION = new String[]{
+ OnionService._ID,
+ OnionService.NAME,
+ OnionService.DOMAIN,
+ OnionService.PORT,
+ OnionService.ONION_PORT,
+ OnionService.ENABLED,
+ OnionService.PATH
+ };
+ private static final String[] LEGACY_COOKIE_PROJECTION = new String[]{
+ ClientCookie._ID,
+ ClientCookie.DOMAIN,
+ ClientCookie.AUTH_COOKIE_VALUE,
+ ClientCookie.ENABLED};
+ private static final String[] V3_CLIENT_AUTH_PROJECTION = new String[]{
+ V3ClientAuth._ID,
+ V3ClientAuth.DOMAIN,
+ V3ClientAuth.HASH,
+ V3ClientAuth.ENABLED
+ };
+
+ public boolean isAppClosed = false;
+ public static int mPortSOCKS = -1;
+ public static int mPortHTTP = -1;
+ public static int mPortDns = TOR_DNS_PORT_DEFAULT;
+ public static int mPortTrans = TOR_TRANSPROXY_PORT_DEFAULT;
+ public static File appBinHome;
+ public static File appCacheHome;
+ private final ExecutorService mExecutor = Executors.newCachedThreadPool();
+ boolean mIsLollipop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
+ TorEventHandler mEventHandler;
+ OrbotVpnManager mVpnManager;
+ Handler mHandler;
+ //we should randomly sort alBridges so we don't have the same bridge order each time
+ Random bridgeSelectRandom = new Random(System.nanoTime());
+ ActionBroadcastReceiver mActionBroadcastReceiver;
+ private String mCurrentStatus = STATUS_OFF;
+ private TorControlConnection conn = null;
+ private ServiceConnection torServiceConnection;
+ private TorService torService;
+ private boolean shouldUnbindTorService;
+ private NotificationManager mNotificationManager = null;
+ private NotificationCompat.Builder mNotifyBuilder;
+ private boolean mNotificationShowing = false;
+ private File mHSBasePath, mV3OnionBasePath, mV3AuthBasePath;
+ private ArrayList alBridges = null;
+
+ /**
+ * @param bridgeList bridges that were manually entered into Orbot settings
+ * @return Array with each bridge as an element, no whitespace entries see issue #289...
+ */
+ private static String[] parseBridgesFromSettings(String bridgeList) {
+ // this regex replaces lines that only contain whitespace with an empty String
+ bridgeList = bridgeList.trim().replaceAll("(?m)^[ \t]*\r?\n", "");
+ return bridgeList.split("\\n");
+ }
+
+ public void debug(String msg) {
+ Log.d(TAG, msg);
+
+ if (Prefs.useDebugLogging()) {
+ sendCallbackLogMessage(msg);
+ }
+ }
+
+ public void logException(String msg, Exception e) {
+ if (Prefs.useDebugLogging()) {
+ Log.e(TAG, msg, e);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ e.printStackTrace(new PrintStream(baos));
+
+ sendCallbackLogMessage(msg + '\n' + new String(baos.toByteArray()));
+
+ } else
+ sendCallbackLogMessage(msg);
+
+ }
+
+ private void showConnectedToTorNetworkNotification() {
+ showToolbarNotification(getString(R.string.status_activated), NOTIFY_ID, R.mipmap.ic_stat_tor_logo);
+ }
+
+ @Override
+ public void onLowMemory() {
+ super.onLowMemory();
+ logNotice("Low Memory Warning!");
+ }
+
+ private void clearNotifications() {
+ if (mNotificationManager != null)
+ mNotificationManager.cancelAll();
+
+ if (mEventHandler != null)
+ mEventHandler.getNodes().clear();
+
+ mNotificationShowing = false;
+ }
+
+ @RequiresApi(api = Build.VERSION_CODES.O)
+ private void createNotificationChannel() {
+ NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+
+ CharSequence name = getString(R.string.app_name); // The user-visible name of the channel.
+ String description = getString(R.string.app_description); // The user-visible description of the channel.
+ NotificationChannel mChannel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, name, NotificationManager.IMPORTANCE_LOW);
+ // Configure the notification channel.
+ mChannel.setDescription(description);
+ mChannel.enableLights(false);
+ mChannel.enableVibration(false);
+ mChannel.setShowBadge(false);
+ mChannel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
+ mNotificationManager.createNotificationChannel(mChannel);
+ }
+
+ boolean mToolbarUpdating = false;
+ @SuppressLint({"NewApi", "RestrictedApi"})
+ public void showToolbarNotification(String notifyMsg, int notifyType, int icon) {
+ if(!mToolbarUpdating){
+ mToolbarUpdating = true;
+ }else {
+ return;
+ }
+
+ try{
+ if(isAppClosed){
+ Log.i("superman", "superman");
+ return;
+ }
+ PackageManager pm = getPackageManager();
+ Intent intent = pm.getLaunchIntentForPackage(getPackageName());
+ PendingIntent pendIntent = PendingIntent.getActivity(OrbotService.this, 0, intent, 0);
+
+ if (mNotifyBuilder == null) {
+ mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ mNotifyBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
+ .setContentTitle(getString(R.string.app_name))
+ .setSmallIcon(R.mipmap.ic_stat_tor_logo)
+ .setContentIntent(pendIntent)
+ .setCategory(Notification.CATEGORY_SERVICE)
+ .setOngoing(Prefs.persistNotifications());
+ }
+
+ mNotifyBuilder.mActions.clear();
+ if (conn != null && orbotLocalConstants.mIsTorInitialized) {
+ Intent intentRefresh = new Intent(CMD_NEWNYM);
+ PendingIntent pendingIntentNewNym = PendingIntent.getBroadcast(this, 0, intentRefresh, PendingIntent.FLAG_UPDATE_CURRENT);
+ mNotifyBuilder.addAction(R.mipmap.ic_stat_tor_logo, getString(R.string.menu_new_identity), pendingIntentNewNym);
+
+ Intent intentSetting = new Intent(CMD_SETTING);
+ PendingIntent pendingIntentSetting = PendingIntent.getBroadcast(this, 0, intentSetting, PendingIntent.FLAG_UPDATE_CURRENT);
+ mNotifyBuilder.addAction(0, "Notification Settings", pendingIntentSetting);
+ }
+
+ mNotifyBuilder.setContentText(notifyMsg)
+ .setSmallIcon(icon)
+ .setTicker(notifyType != NOTIFY_ID ? notifyMsg : null);
+
+ if (!Prefs.persistNotifications())
+ mNotifyBuilder.setPriority(Notification.PRIORITY_LOW);
+
+ Notification notification = mNotifyBuilder.build();
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ startForeground(11337, notification);
+ } else if (Prefs.persistNotifications() && (!mNotificationShowing)) {
+ startForeground(11337, notification);
+ logNotice("Set background service to FOREGROUND");
+ } else {
+ mNotificationManager.notify(NOTIFY_ID, notification);
+ }
+ }catch (Exception ex){
+ Log.i("sad","asd");
+ }
+
+ mNotificationShowing = true;
+ mToolbarUpdating = false;
+ }
+
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ showToolbarNotification("", NOTIFY_ID, R.mipmap.ic_stat_tor_logo);
+
+ self = this;
+ if (intent != null)
+ mExecutor.execute(new IncomingIntentRouter(intent));
+ else
+ Log.d(TAG, "Got null onStartCommand() intent");
+
+ return Service.START_STICKY;
+ }
+
+ @Override
+ public void onTaskRemoved(Intent rootIntent) {
+ try{
+ Intent intent = new Intent(this, DummyActivity.class);
+ intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
+ startActivity(intent);
+ }catch (Exception ignored){
+ Log.i("sda","ASd");
+
+ }
+ }
+
+ @Override
+ public void onDestroy() {
+
+ try {
+ disableNotification();
+ clearNotifications();
+ unregisterReceiver(mNetworkStateReceiver);
+ unregisterReceiver(mActionBroadcastReceiver);
+ }catch (Exception ex){
+ Log.i("sad","asd");
+ ex.printStackTrace();
+ }
+
+ isAppClosed = true;
+
+ try {
+ stopTor();
+ stopTorAsync();
+ clearNotifications();
+ killAllDaemons();
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+
+ super.onDestroy();
+ }
+
+ private void killAllDaemons() throws Exception {
+
+ if (conn != null) {
+ logNotice("Using control port to shutdown Tor");
+
+ try {
+ logNotice("sending HALT signal to Tor process");
+ conn.shutdownTor("SHUTDOWN");
+
+ } catch (IOException e) {
+ Log.d(TAG, "error shutting down Tor via connection", e);
+ }
+
+ conn = null;
+ }
+ }
+
+ private void stopTorAsync() {
+
+ debug("stopTor");
+
+ try {
+ sendCallbackStatus(STATUS_STOPPING);
+ sendCallbackLogMessage(getString(R.string.status_shutting_down));
+
+ if (Prefs.bridgesEnabled()) {
+ if (useIPtObfsMeekProxy())
+ IPtProxy.stopObfs4Proxy();
+ else if (useIPtSnowflakeProxy())
+ IPtProxy.stopSnowflake();
+ }
+ else if (Prefs.beSnowflakeProxy())
+ disableSnowflakeProxy();
+
+ stopTor();
+
+ //stop the foreground priority and make sure to remove the persistant notification
+ stopForeground(true);
+
+ sendCallbackLogMessage(getString(R.string.status_disabled));
+ } catch (Exception e) {
+ logNotice("An error occured stopping Tor: " + e.getMessage());
+ sendCallbackLogMessage(getString(R.string.something_bad_happened));
+ }
+ clearNotifications();
+ sendCallbackStatus(STATUS_OFF);
+ }
+
+ private void disableSnowflakeProxy () {
+ IPtProxy.stopSnowflakeProxy();
+ logNotice("Snowflake Proxy mode DISABLED");
+ }
+
+ private void stopTorOnError(String message) {
+ stopTorAsync();
+ showToolbarNotification(
+ getString(R.string.unable_to_start_tor) + ": " + message,
+ ERROR_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
+ }
+
+ private static boolean useIPtObfsMeekProxy() {
+ String bridgeList = Prefs.getBridgesList();
+ return bridgeList.contains("obfs") || bridgeList.contains("meek");
+ }
+
+ private static boolean useIPtSnowflakeProxy() {
+ String bridgeList = Prefs.getBridgesList();
+ return bridgeList.contains("snowflake");
+ }
+
+ private static HashMap mFronts;
+
+ public static void loadCdnFronts (Context context) {
+ if (mFronts == null) {
+ mFronts = new HashMap<>();
+ try {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(context.getAssets().open("fronts")));
+ String line;
+ while ((line = reader.readLine())!=null) {
+ String[] front = line.split(" ");
+ mFronts.put(front[0],front[1]);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static String getCdnFront(String service) {
+ return mFronts.get(service);
+ }
+
+ private void startSnowflakeClient() {
+ String target = getCdnFront("snowflake-target");
+ String front = getCdnFront("snowflake-front");
+ String stunServer = getCdnFront("snowflake-stun");
+ IPtProxy.startSnowflake(stunServer, target, front,null, true, false, true, 3);
+ }
+
+ /*
+ This is to host a snowflake entrance node / bridge
+ */
+ private void runSnowflakeProxy () {
+ int capacity = 3;
+ 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);
+ }
+
+ private void stopSnowflakeProxy () {
+ IPtProxy.stopSnowflakeProxy();
+ }
+ /**
+ * if someone stops during startup, we may have to wait for the conn port to be setup, so we can properly shutdown tor
+ */
+ private synchronized void stopTor() throws Exception {
+
+ if (conn != null) {
+ logNotice("Using control port to shutdown Tor");
+
+ try {
+ logNotice("sending HALT signal to Tor process");
+ conn.shutdownTor(TorControlCommands.SIGNAL_SHUTDOWN);
+
+ } catch (IOException e) {
+ Log.d(TAG, "error shutting down Tor via connection", e);
+ }
+
+ if (shouldUnbindTorService) {
+ unbindService(torServiceConnection);
+ shouldUnbindTorService = false;
+ }
+
+ conn = null;
+ }
+ }
+
+ private void requestTorRereadConfig() {
+ try {
+ if (conn != null) {
+ conn.signal(TorControlCommands.SIGNAL_RELOAD);
+ }
+ } catch (IOException e) {
+ Log.i("sad","asd");
+ e.printStackTrace();
+ }
+ }
+
+ protected void logNotice(String msg) {
+ if (msg != null && msg.trim().length() > 0) {
+ if (Prefs.useDebugLogging())
+ Log.d(TAG, msg);
+
+ sendCallbackLogMessage(msg);
+ }
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+ try {
+ if (Build.VERSION.SDK_INT <= 25) {
+ Intent notificationIntent = new Intent(this, OrbotService.class);
+
+ PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
+ notificationIntent, 0);
+
+ Notification notification = new NotificationCompat.Builder(this)
+ .setSmallIcon(R.drawable.ic_stat_starting_tor_logo)
+ .setContentTitle("Starting Genesis")
+ .setContentIntent(pendingIntent).build();
+
+ startForeground(11337, notification);
+ }else {
+ String id = "_channel_01";
+ int importance = NotificationManager.IMPORTANCE_LOW;
+ NotificationChannel mChannel = new NotificationChannel(id, "notification", importance);
+ mChannel.enableLights(true);
+
+ Notification notification = new Notification.Builder(getApplicationContext(), id)
+ .setSmallIcon(R.drawable.ic_stat_starting_tor_logo)
+ .setContentTitle("Starting Genesis")
+ .build();
+
+ NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ if (mNotificationManager != null) {
+ mNotificationManager.createNotificationChannel(mChannel);
+ mNotificationManager.notify(11337, notification);
+ }
+
+ startForeground(11337, notification);
+ }
+
+
+ mHandler = new Handler();
+
+ appBinHome = getFilesDir();
+ if (!appBinHome.exists())
+ appBinHome.mkdirs();
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ appCacheHome = new File(getDataDir(), DIRECTORY_TOR_DATA);
+ } else {
+ appCacheHome = getDir(DIRECTORY_TOR_DATA, Application.MODE_PRIVATE);
+ }
+
+ if (!appCacheHome.exists())
+ appCacheHome.mkdirs();
+
+ mHSBasePath = new File(getFilesDir().getAbsolutePath(), HIDDEN_SERVICES_DIR);
+ if (!mHSBasePath.isDirectory())
+ mHSBasePath.mkdirs();
+
+ mV3OnionBasePath = new File(getFilesDir().getAbsolutePath(), ONION_SERVICES_DIR);
+ if (!mV3OnionBasePath.isDirectory())
+ mV3OnionBasePath.mkdirs();
+
+ mV3AuthBasePath = new File(getFilesDir().getAbsolutePath(), V3_CLIENT_AUTH_DIR);
+ if (!mV3AuthBasePath.isDirectory())
+ mV3AuthBasePath.mkdirs();
+
+ if (mNotificationManager == null) {
+ mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ }
+
+ IntentFilter mNetworkStateFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
+ registerReceiver(mNetworkStateReceiver , mNetworkStateFilter);
+
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(CMD_NEWNYM);
+ filter.addAction(CMD_SETTING);
+ filter.addAction(CMD_ACTIVE);
+ mActionBroadcastReceiver = new ActionBroadcastReceiver();
+ registerReceiver(mActionBroadcastReceiver, filter);
+
+ if (Build.VERSION.SDK_INT >= 26)
+ createNotificationChannel();
+
+ CustomTorResourceInstaller installer = new CustomTorResourceInstaller(this, appBinHome);
+ installer.installGeoIP();
+
+ pluggableTransportInstall();
+
+ mVpnManager = new OrbotVpnManager(this);
+
+ loadCdnFronts(this);
+
+ } catch (Exception e) {
+ //what error here
+ Log.e(TAG, "Error installing Orbot binaries", e);
+ logNotice("There was an error installing Orbot binaries");
+ }
+
+ Log.i("OrbotService", "onCreate end");
+ }
+
+ protected String getCurrentStatus() {
+ return mCurrentStatus;
+ }
+
+ private boolean pluggableTransportInstall() {
+
+ File fileCacheDir = new File(getCacheDir(), "pt");
+ if (!fileCacheDir.exists())
+ //noinspection ResultOfMethodCallIgnored
+ fileCacheDir.mkdir();
+ IPtProxy.setStateLocation(fileCacheDir.getAbsolutePath());
+ String fileTestState = IPtProxy.getStateLocation();
+ debug("IPtProxy state: " + fileTestState);
+
+ return false;
+ }
+
+ private File updateTorrcCustomFile() throws IOException, TimeoutException {
+ SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
+
+ StringBuffer extraLines = new StringBuffer();
+
+ extraLines.append("\n");
+
+ extraLines.append("RunAsDaemon 0").append('\n');
+ extraLines.append("AvoidDiskWrites 0").append('\n');
+
+ String socksPortPref = prefs.getString(PREF_SOCKS, (SOCKS_PROXY_PORT_DEFAULT));
+
+ if (socksPortPref.indexOf(':') != -1)
+ socksPortPref = socksPortPref.split(":")[1];
+
+
+ String httpPortPref = prefs.getString(PREF_HTTP, (HTTP_PROXY_PORT_DEFAULT));
+
+ if (httpPortPref.indexOf(':') != -1)
+ httpPortPref = httpPortPref.split(":")[1];
+
+
+ try{
+ orbotLocalConstants.mSOCKSPort = Integer.parseInt(socksPortPref);
+ orbotLocalConstants.mHTTPPort = Integer.parseInt(httpPortPref);
+
+ }catch (Exception ex){
+ orbotLocalConstants.mSOCKSPort = 9050;
+ orbotLocalConstants.mHTTPPort = 8118;
+ }
+
+ String isolate = "";
+ if (prefs.getBoolean(PREF_ISOLATE_DEST, false)) {
+ isolate += " IsolateDestAddr ";
+ }
+
+ String ipv6Pref = "";
+
+ if (prefs.getBoolean(PREF_PREFER_IPV6, true)) {
+ ipv6Pref += " IPv6Traffic PreferIPv6 ";
+ }
+
+ if (prefs.getBoolean(PREF_DISABLE_IPV4, false)) {
+ ipv6Pref += " IPv6Traffic NoIPv4Traffic ";
+ }
+
+ extraLines.append("SOCKSPort ").append(socksPortPref).append(isolate).append(ipv6Pref).append('\n');
+ extraLines.append("SafeSocks 0").append('\n');
+ extraLines.append("TestSocks 0").append('\n');
+
+ if (Prefs.openProxyOnAllInterfaces())
+ extraLines.append("SocksListenAddress 0.0.0.0").append('\n');
+
+
+ extraLines.append("HTTPTunnelPort ").append(httpPortPref).append('\n');
+
+ if (prefs.getBoolean(PREF_CONNECTION_PADDING, false)) {
+ extraLines.append("ConnectionPadding 1").append('\n');
+ }
+
+ if (prefs.getBoolean(PREF_REDUCED_CONNECTION_PADDING, true)) {
+ extraLines.append("ReducedConnectionPadding 1").append('\n');
+ }
+
+ if (prefs.getBoolean(PREF_CIRCUIT_PADDING, true)) {
+ extraLines.append("CircuitPadding 1").append('\n');
+ } else {
+ extraLines.append("CircuitPadding 0").append('\n');
+ }
+
+ if (prefs.getBoolean(PREF_REDUCED_CIRCUIT_PADDING, true)) {
+ extraLines.append("ReducedCircuitPadding 1").append('\n');
+ }
+
+ String transPort = prefs.getString("pref_transport", TOR_TRANSPROXY_PORT_DEFAULT + "");
+ String dnsPort = prefs.getString("pref_dnsport", TOR_DNS_PORT_DEFAULT + "");
+
+ extraLines.append("TransPort ").append(checkPortOrAuto(transPort)).append('\n');
+ extraLines.append("DNSPort ").append(checkPortOrAuto(dnsPort)).append('\n');
+
+ extraLines.append("VirtualAddrNetwork 10.192.0.0/10").append('\n');
+ extraLines.append("AutomapHostsOnResolve 1").append('\n');
+
+ extraLines.append("DormantClientTimeout 10 minutes").append('\n');
+ // extraLines.append("DormantOnFirstStartup 0").append('\n');
+ extraLines.append("DormantCanceledByStartup 1").append('\n');
+
+ extraLines.append("DisableNetwork 0").append('\n');
+
+ if (Prefs.useDebugLogging()) {
+ extraLines.append("Log debug syslog").append('\n');
+ extraLines.append("SafeLogging 0").append('\n');
+ }
+
+ extraLines = processSettingsImpl(extraLines);
+
+ if (extraLines == null)
+ return null;
+
+ extraLines.append('\n');
+ extraLines.append(prefs.getString("pref_custom_torrc", "")).append('\n');
+
+ logNotice("updating torrc custom configuration...");
+
+ debug("torrc.custom=" + extraLines.toString());
+
+ File fileTorRcCustom = TorService.getTorrc(this);
+ updateTorConfigCustom(fileTorRcCustom, extraLines.toString());
+ return fileTorRcCustom;
+ }
+
+ public int getPortHTTP(){
+ return orbotLocalConstants.mHTTPPort;
+ }
+
+ public int getPortSOCKS(){
+ return orbotLocalConstants.mSOCKSPort;
+ }
+
+ private String checkPortOrAuto(String portString) {
+ if (!portString.equalsIgnoreCase("auto")) {
+ boolean isPortUsed = true;
+ int port = Integer.parseInt(portString);
+
+ while (isPortUsed) {
+ isPortUsed = TorServiceUtils.isPortOpen("127.0.0.1", port, 500);
+
+ if (isPortUsed) //the specified port is not available, so let Tor find one instead
+ port++;
+ }
+ return port + "";
+ }
+
+ return portString;
+ }
+
+ public boolean updateTorConfigCustom(File fileTorRcCustom, String extraLines) throws IOException, TimeoutException {
+ FileWriter fos = new FileWriter(fileTorRcCustom, false);
+ PrintWriter ps = new PrintWriter(fos);
+ ps.print(extraLines);
+ ps.flush();
+ ps.close();
+ return true;
+ }
+
+ /**
+ * Send Orbot's status in reply to an
+ * {@link TorServiceConstants#ACTION_START} {@link Intent}, targeted only to
+ * the app that sent the initial request. If the user has disabled auto-
+ * starts, the reply {@code ACTION_START Intent} will include the extra
+ * {@link TorServiceConstants#STATUS_STARTS_DISABLED}
+ */
+ private void replyWithStatus(Intent startRequest) {
+ String packageName = startRequest.getStringExtra(EXTRA_PACKAGE_NAME);
+
+ Intent reply = new Intent(ACTION_STATUS);
+ reply.putExtra(EXTRA_STATUS, mCurrentStatus);
+ reply.putExtra(EXTRA_SOCKS_PROXY, "socks://127.0.0.1:" + mPortSOCKS);
+ reply.putExtra(EXTRA_SOCKS_PROXY_HOST, "127.0.0.1");
+ reply.putExtra(EXTRA_SOCKS_PROXY_PORT, mPortSOCKS);
+ reply.putExtra(EXTRA_HTTP_PROXY, "http://127.0.0.1:" + mPortHTTP);
+ reply.putExtra(EXTRA_HTTP_PROXY_HOST, "127.0.0.1");
+ reply.putExtra(EXTRA_HTTP_PROXY_PORT, mPortHTTP);
+
+ if (packageName != null) {
+ reply.setPackage(packageName);
+ sendBroadcast(reply);
+ }
+
+ LocalBroadcastManager.getInstance(this).sendBroadcast(reply);
+
+ if (mPortSOCKS != -1 && mPortHTTP != -1)
+ sendCallbackPorts(mPortSOCKS, mPortHTTP, mPortDns, mPortTrans);
+
+ }
+
+ /**
+ * The entire process for starting tor and related services is run from this method.
+ */
+ public void onRestart() {
+ try {
+ startTorService();
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+ }
+
+ private void startTor() {
+ try {
+
+ // STATUS_STARTING is set in onCreate()
+ if (mCurrentStatus.equals(STATUS_STOPPING)) {
+ // these states should probably be handled better
+ sendCallbackLogMessage("Ignoring start request, currently " + mCurrentStatus);
+ return;
+ } else if (mCurrentStatus.equals(STATUS_ON)) {
+ showConnectedToTorNetworkNotification();
+ sendCallbackLogMessage("Ignoring start request, already started.");
+ return;
+ }
+
+ sendCallbackStatus(STATUS_STARTING);
+
+ // make sure there are no stray daemons running
+ stopTor();
+
+ showToolbarNotification(getString(R.string.status_starting_up), NOTIFY_ID, R.drawable.ic_stat_starting_tor_logo);
+ //sendCallbackLogMessage(getString(R.string.status_starting_up));
+ //logNotice(getString(R.string.status_starting_up));
+
+ ArrayList customEnv = new ArrayList<>();
+
+ if (Prefs.bridgesEnabled())
+ if (Prefs.useVpn() && !mIsLollipop) {
+ customEnv.add("TOR_PT_PROXY=socks5://" + OrbotVpnManager.sSocksProxyLocalhost + ":" + OrbotVpnManager.sSocksProxyServerPort);
+ }
+
+ startTorService();
+
+ if (Prefs.hostOnionServicesEnabled()) {
+ try {
+ updateLegacyV2OnionNames();
+ } catch (SecurityException se) {
+ logNotice("unable to upload legacy v2 onion names");
+ }
+ try {
+ updateV3OnionNames();
+ } catch (SecurityException se) {
+ logNotice("unable to upload v3 onion names");
+ }
+ }
+ } catch (Exception e) {
+ Log.i("sad","asd");
+ logException("Unable to start Tor: " + e.toString(), e);
+ stopTorOnError(e.getLocalizedMessage());
+ }
+ }
+
+
+ private void updateV3OnionNames() throws SecurityException {
+ ContentResolver contentResolver = getApplicationContext().getContentResolver();
+ Cursor onionServices = contentResolver.query(V3_ONION_SERVICES_CONTENT_URI, null, null, null, null);
+ if (onionServices != null) {
+ try {
+ while (onionServices.moveToNext()) {
+ String domain = onionServices.getString(onionServices.getColumnIndex(OnionService.DOMAIN));
+ if (domain == null || TextUtils.isEmpty(domain)) {
+ String path = onionServices.getString(onionServices.getColumnIndex(OnionService.PATH));
+ String v3OnionDirPath = new File(mV3OnionBasePath.getAbsolutePath(), path).getCanonicalPath();
+ File hostname = new File(v3OnionDirPath, "hostname");
+ if (hostname.exists()) {
+ int id = onionServices.getInt(onionServices.getColumnIndex(OnionService._ID));
+ domain = Utils.readString(new FileInputStream(hostname)).trim();
+ ContentValues fields = new ContentValues();
+ fields.put(OnionService.DOMAIN, domain);
+ contentResolver.update(V3_ONION_SERVICES_CONTENT_URI, fields, OnionService._ID + "=" + id, null);
+ }
+ }
+
+ }
+ } catch (Exception e) {
+ Log.i("sad","asd");
+ e.printStackTrace();
+ }
+ onionServices.close();
+ }
+ }
+
+ private void updateLegacyV2OnionNames() throws SecurityException {
+ // Tor is running, update new .onion names at db
+ ContentResolver mCR = getApplicationContext().getContentResolver();
+ Cursor hidden_services = mCR.query(V2_HS_CONTENT_URI, LEGACY_V2_ONION_SERVICE_PROJECTION, null, null, null);
+ if (hidden_services != null) {
+ try {
+ while (hidden_services.moveToNext()) {
+ String HSDomain = hidden_services.getString(hidden_services.getColumnIndex(OnionService.DOMAIN));
+ int HSAuthCookie = hidden_services.getInt(hidden_services.getColumnIndex(OnionService.AUTH_COOKIE));
+ String HSAuthCookieValue = hidden_services.getString(hidden_services.getColumnIndex(OnionService.AUTH_COOKIE_VALUE));
+ // Update only new domains or restored from backup with auth cookie
+ if ((HSDomain == null || HSDomain.length() < 1) || (HSAuthCookie == 1 && (HSAuthCookieValue == null || HSAuthCookieValue.length() < 1))) {
+ String hsDirPath = new File(mHSBasePath.getAbsolutePath(), hidden_services.getString(hidden_services.getColumnIndex(OnionService.PATH))).getCanonicalPath();
+ File file = new File(hsDirPath, "hostname");
+
+ if (file.exists()) {
+ ContentValues fields = new ContentValues();
+
+ try {
+ int id = hidden_services.getInt(hidden_services.getColumnIndex(OnionService._ID));
+ String onionHostname = Utils.readString(new FileInputStream(file)).trim();
+ if (HSAuthCookie == 1) {
+ String[] aux = onionHostname.split(" ");
+ onionHostname = aux[0];
+ fields.put(OnionService.AUTH_COOKIE_VALUE, aux[1]);
+ }
+ fields.put(OnionService.DOMAIN, onionHostname);
+ mCR.update(V2_HS_CONTENT_URI, fields, OnionService._ID + "=" + id, null);
+ } catch (FileNotFoundException e) {
+ logException("unable to read onion hostname file", e);
+ showToolbarNotification(getString(R.string.unable_to_read_hidden_service_name), HS_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
+ }
+ } else {
+ showToolbarNotification(getString(R.string.unable_to_read_hidden_service_name), HS_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
+ }
+ }
+ }
+
+ } catch (NumberFormatException e) {
+ Log.e(TAG, "error parsing hsport", e);
+ } catch (Exception e) {
+ Log.e(TAG, "error starting share server", e);
+ }
+
+ hidden_services.close();
+ }
+ }
+
+ private synchronized void startTorService() throws Exception {
+ updateTorConfigCustom(TorService.getDefaultsTorrc(this),
+ "DNSPort 0\n" +
+ "TransPort 0\n" +
+ "DisableNetwork 1\n");
+
+ File fileTorrcCustom = updateTorrcCustomFile();
+ if ((!fileTorrcCustom.exists()) || (!fileTorrcCustom.canRead()))
+ return;
+
+ sendCallbackLogMessage(getString(R.string.status_starting_up));
+
+ torServiceConnection = new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
+ new Thread(){
+ public void run(){
+ torService = ((TorService.LocalBinder) iBinder).getService();
+ try {
+ conn = torService.getTorControlConnection();
+ while (conn == null) {
+ Log.v(TAG, "Waiting for Tor Control Connection...");
+ Thread.sleep(500);
+ conn = torService.getTorControlConnection();
+ }
+ sleep(2000);
+ mEventHandler = new TorEventHandler(OrbotService.this);
+ logNotice("adding control port event handler");
+ conn.setEventHandler(mEventHandler);
+ ArrayList events = new ArrayList<>(Arrays.asList(
+ TorControlCommands.EVENT_OR_CONN_STATUS,
+ TorControlCommands.EVENT_CIRCUIT_STATUS,
+ TorControlCommands.EVENT_NOTICE_MSG,
+ TorControlCommands.EVENT_WARN_MSG,
+ TorControlCommands.EVENT_ERR_MSG,
+ TorControlCommands.EVENT_BANDWIDTH_USED,
+ TorControlCommands.EVENT_NEW_DESC,
+ TorControlCommands.EVENT_ADDRMAP));
+ if (Prefs.useDebugLogging()) {
+ events.add(TorControlCommands.EVENT_DEBUG_MSG);
+ events.add(TorControlCommands.EVENT_INFO_MSG);
+ }
+
+ conn.setEvents(events);
+ initControlConnection();
+ logNotice("SUCCESS added control port event handler");
+ } catch (InterruptedException | IOException e) {
+ e.printStackTrace();
+ stopTorOnError(e.getLocalizedMessage());
+ conn = null;
+ }
+ }
+ }.start();
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName componentName) {
+ conn = null;
+ torService = null;
+ mEventHandler = null;
+ }
+
+ @Override
+ public void onNullBinding(ComponentName componentName) {
+ stopTorOnError("Tor was unable to start: " + "onNullBinding");
+ conn = null;
+ torService = null;
+ mEventHandler = null;
+ }
+
+ @Override
+ public void onBindingDied(ComponentName componentName) {
+ stopTorOnError("Tor was unable to start: " + "onBindingDied");
+ conn = null;
+ torService = null;
+ mEventHandler = null;
+ }
+ };
+
+ BroadcastReceiver receiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (TorService.ACTION_STATUS.equals(intent.getAction())
+ && TorService.STATUS_ON.equals(intent.getStringExtra(TorService.EXTRA_STATUS))) {
+ initControlConnection();
+ unregisterReceiver(this);
+ }
+ }
+ };
+ // run the BroadcastReceiver in its own thread
+ HandlerThread handlerThread = new HandlerThread(receiver.getClass().getSimpleName());
+ handlerThread.start();
+ Looper looper = handlerThread.getLooper();
+ Handler handler = new Handler(looper);
+ registerReceiver(receiver, new IntentFilter(TorService.ACTION_STATUS), null, handler);
+
+ Intent serviceIntent = new Intent(this, TorService.class);
+ if (Build.VERSION.SDK_INT < 29) {
+ shouldUnbindTorService = bindService(serviceIntent, torServiceConnection, BIND_AUTO_CREATE);
+ } else {
+ shouldUnbindTorService = bindService(serviceIntent, BIND_AUTO_CREATE, mExecutor, torServiceConnection);
+ }
+ }
+
+ protected void exec(Runnable runn) {
+ mExecutor.execute(runn);
+ }
+
+ public int getNotifyId() {
+ return NOTIFY_ID;
+ }
+
+ public String getProxyStatus() {
+ return mCurrentStatus;
+ }
+
+ private static OrbotService self = null;
+
+ public static OrbotService getServiceObject(){
+ return self;
+ }
+
+ private boolean mConnectivity = true;
+ private int mNetworkType = -1;
+ private final BroadcastReceiver mNetworkStateReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+
+ SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
+
+ if(prefs==null){
+ }
+
+ boolean doNetworKSleep = prefs.getBoolean(PREF_DISABLE_NETWORK, true);
+
+ final ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
+ final NetworkInfo netInfo = cm.getActiveNetworkInfo();
+
+ boolean newConnectivityState;
+ int newNetType = -1;
+
+ if (netInfo!=null)
+ newNetType = netInfo.getType();
+
+ if(netInfo != null && netInfo.isConnected()) {
+ // WE ARE CONNECTED: DO SOMETHING
+ newConnectivityState = true;
+ }
+ else {
+ // WE ARE NOT: DO SOMETHING ELSE
+ newConnectivityState = false;
+ }
+
+ mNetworkType = newNetType;
+
+ if (newConnectivityState != mConnectivity) {
+ mConnectivity = newConnectivityState;
+ orbotLocalConstants.mNetworkState = mConnectivity;
+
+ if (mConnectivity){
+ newIdentity();
+ }
+ }
+
+ if (doNetworKSleep)
+ {
+ //setTorNetworkEnabled (mConnectivity);
+ if (!mConnectivity)
+ {
+ //sendCallbackStatus(STATUS_OFF);
+ orbotLocalConstants.mTorLogsStatus = "No internet connection";
+ if(orbotLocalConstants.mNotificationStatus!=0){
+ showToolbarNotification(getString(R.string.newnym), getNotifyId(), R.drawable.ic_stat_tor_off);
+ showToolbarNotification("Genesis is sleeping | Internet connectivity issue",NOTIFY_ID,R.drawable.ic_stat_tor_off);
+ }
+ }
+ else
+ {
+ //sendCallbackStatus(STATUS_STARTING);
+ if(orbotLocalConstants.mNotificationStatus!=0){
+ showToolbarNotification(getString(R.string.status_starting_up),NOTIFY_ID,R.drawable.ic_stat_starting_tor_logo);
+ }
+ }
+
+ }
+ orbotLocalConstants.mNetworkState = mConnectivity;
+ }
+ };
+
+ private void initControlConnection() {
+ if (conn != null) {
+ logNotice("SUCCESS connected to Tor control port.");
+ try {
+ String confSocks = conn.getInfo("net/listeners/socks");
+ StringTokenizer st = new StringTokenizer(confSocks, " ");
+
+ confSocks = st.nextToken().split(":")[1];
+ confSocks = confSocks.substring(0, confSocks.length() - 1);
+ mPortSOCKS = Integer.parseInt(confSocks);
+
+ String confHttp = conn.getInfo("net/listeners/httptunnel");
+ st = new StringTokenizer(confHttp, " ");
+
+ confHttp = st.nextToken().split(":")[1];
+ confHttp = confHttp.substring(0, confHttp.length() - 1);
+ mPortHTTP = Integer.parseInt(confHttp);
+
+ String confDns = conn.getInfo("net/listeners/dns");
+ st = new StringTokenizer(confDns, " ");
+ if (st.hasMoreTokens()) {
+ confDns = st.nextToken().split(":")[1];
+ confDns = confDns.substring(0, confDns.length() - 1);
+ mPortDns = Integer.parseInt(confDns);
+ Prefs.getSharedPrefs(getApplicationContext()).edit().putInt(VpnPrefs.PREFS_DNS_PORT, mPortDns).apply();
+ }
+
+ String confTrans = conn.getInfo("net/listeners/trans");
+ st = new StringTokenizer(confTrans, " ");
+ if (st.hasMoreTokens()) {
+ confTrans = st.nextToken().split(":")[1];
+ confTrans = confTrans.substring(0, confTrans.length() - 1);
+ mPortTrans = Integer.parseInt(confTrans);
+ }
+
+ sendCallbackPorts(mPortSOCKS, mPortHTTP, mPortDns, mPortTrans);
+ orbotLocalConstants.mIsTorInitialized = true;
+
+ } catch (IOException e) {
+ Log.i("sad","asd");
+ e.printStackTrace();
+ stopTorOnError(e.getLocalizedMessage());
+ conn = null;
+ }
+ }
+ }
+
+ public void sendSignalActive() {
+ if (conn != null && mCurrentStatus == STATUS_ON) {
+ try {
+ conn.signal("ACTIVE");
+ } catch (IOException e) {
+ debug("error send active: " + e.getLocalizedMessage());
+ }
+ }
+ }
+
+ public void newIdentity() {
+ //it is possible to not have a connection yet, and someone might try to newnym
+ if (conn != null) {
+ new Thread() {
+ public void run() {
+ try {
+ int iconId = R.mipmap.ic_stat_tor_logo;
+
+ if (conn != null && mCurrentStatus == STATUS_ON && Prefs.expandedNotifications() && mConnectivity)
+ showToolbarNotification(getString(R.string.newnym), NOTIFY_ID, R.drawable.ic_stat_starting_tor_logo);
+
+ conn.signal(TorControlCommands.SIGNAL_NEWNYM);
+
+ sleep(1000);
+ if(mConnectivity)
+ enableNotification();
+
+ } catch (Exception ioe) {
+ debug("error requesting newnym: " + ioe.getLocalizedMessage());
+ }
+ }
+ }.start();
+ }
+ }
+
+ protected void sendCallbackBandwidth(long lastWritten, long lastRead, long totalWritten, long totalRead) {
+ Intent intent = new Intent(LOCAL_ACTION_BANDWIDTH);
+
+ intent.putExtra("totalWritten", totalWritten);
+ intent.putExtra("totalRead", totalRead);
+ intent.putExtra("lastWritten", lastWritten);
+ intent.putExtra("lastRead", lastRead);
+ intent.putExtra(EXTRA_STATUS, mCurrentStatus);
+
+ LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
+ }
+
+ int e=0;
+ String mPrevLogs = "";
+ private void sendCallbackLogMessage(String logMessage)
+ {
+ if(mPrevLogs.equals(logMessage)){
+ return;
+ }else {
+ mPrevLogs = logMessage;
+ }
+ if(logMessage.contains("Bootstrapped 100%")){
+ orbotLocalConstants.mIsTorInitialized = true;
+ }
+ mHandler.post(() -> {
+ Intent intent = new Intent(LOCAL_ACTION_LOG);
+ intent.putExtra(LOCAL_EXTRA_LOG, logMessage);
+ intent.putExtra(EXTRA_STATUS, mCurrentStatus);
+ orbotLocalConstants.mTorLogsHistory.add(new logRowModel(logMessage, localHelperMethod.getCurrentTime()));
+
+ if(!mConnectivity){
+ orbotLocalConstants.mTorLogsStatus = "No internet connection";
+ }else {
+ orbotLocalConstants.mTorLogsStatus = logMessage;
+ }
+ LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
+ });
+
+ }
+
+ public boolean getConnectivity(){
+ return mConnectivity;
+ }
+
+ private void sendCallbackPorts(int socksPort, int httpPort, int dnsPort, int transPort) {
+
+ orbotLocalConstants.mSOCKSPort = socksPort;
+ orbotLocalConstants.mHTTPPort = httpPort;
+
+ Intent intent = new Intent(LOCAL_ACTION_PORTS); // You can also include some extra data.
+ intent.putExtra(EXTRA_SOCKS_PROXY_PORT, socksPort);
+ intent.putExtra(EXTRA_HTTP_PROXY_PORT, httpPort);
+ intent.putExtra(EXTRA_DNS_PORT, dnsPort);
+ intent.putExtra(EXTRA_TRANS_PORT, transPort);
+
+ LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
+
+ if (Prefs.useVpn())
+ mVpnManager.handleIntent(new Builder(), intent);
+
+ }
+
+ protected void sendCallbackStatus(String currentStatus) {
+ mCurrentStatus = currentStatus;
+ Intent intent = getActionStatusIntent(currentStatus);
+ sendBroadcastOnlyToOrbot(intent); // send for Orbot internals, using secure local broadcast
+ sendBroadcast(intent); // send for any apps that are interested
+ }
+
+ /**
+ * Send a secure broadcast only to Orbot itself
+ *
+ * @see {@link ContextWrapper#sendBroadcast(Intent)}
+ * @see {@link LocalBroadcastManager}
+ */
+ private boolean sendBroadcastOnlyToOrbot(Intent intent) {
+ return LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
+ }
+
+ private Intent getActionStatusIntent(String currentStatus) {
+ Intent intent = new Intent(ACTION_STATUS);
+ intent.putExtra(EXTRA_STATUS, currentStatus);
+ return intent;
+ }
+
+ private StringBuffer processSettingsImpl(StringBuffer extraLines) throws IOException {
+ logNotice(getString(R.string.updating_settings_in_tor_service));
+ SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
+
+ boolean useBridges = Prefs.bridgesEnabled();
+ boolean becomeRelay = prefs.getBoolean(PREF_OR, false);
+ boolean ReachableAddresses = prefs.getBoolean(PREF_REACHABLE_ADDRESSES, false);
+ boolean enableStrictNodes = prefs.getBoolean("pref_strict_nodes", false);
+ String entranceNodes = prefs.getString("pref_entrance_nodes", "");
+ String exitNodes = prefs.getString("pref_exit_nodes", "");
+ String excludeNodes = prefs.getString("pref_exclude_nodes", "");
+
+ if (!useBridges) {
+ extraLines.append("UseBridges 0").append('\n');
+ if (Prefs.useVpn()) { //set the proxy here if we aren't using a bridge
+ if (!mIsLollipop) {
+ String proxyType = "socks5";
+ extraLines.append(proxyType + "Proxy" + ' ' + OrbotVpnManager.sSocksProxyLocalhost + ':' + OrbotVpnManager.sSocksProxyServerPort).append('\n');
+ }
+
+ } else {
+ String proxyType = prefs.getString("pref_proxy_type", null);
+ if (proxyType != null && proxyType.length() > 0) {
+ String proxyHost = prefs.getString("pref_proxy_host", null);
+ String proxyPort = prefs.getString("pref_proxy_port", null);
+ String proxyUser = prefs.getString("pref_proxy_username", null);
+ String proxyPass = prefs.getString("pref_proxy_password", null);
+
+ if ((proxyHost != null && proxyHost.length() > 0) && (proxyPort != null && proxyPort.length() > 0)) {
+ extraLines.append(proxyType).append("Proxy").append(' ').append(proxyHost).append(':').append(proxyPort).append('\n');
+
+ if (proxyUser != null && proxyPass != null) {
+ if (proxyType.equalsIgnoreCase("socks5")) {
+ extraLines.append("Socks5ProxyUsername").append(' ').append(proxyUser).append('\n');
+ extraLines.append("Socks5ProxyPassword").append(' ').append(proxyPass).append('\n');
+ } else
+ extraLines.append(proxyType).append("ProxyAuthenticator").append(' ').append(proxyUser).append(':').append(proxyPort).append('\n');
+
+ } else if (proxyPass != null)
+ extraLines.append(proxyType).append("ProxyAuthenticator").append(' ').append(proxyUser).append(':').append(proxyPort).append('\n');
+ }
+ }
+ }
+ } else {
+
+ loadBridgeDefaults();
+ extraLines.append("UseBridges 1").append('\n');
+ // extraLines.append("UpdateBridgesFromAuthority 1").append('\n');
+
+ String bridgeList = Prefs.getBridgesList();
+
+ String builtInBridgeType = null;
+
+ //check if any PT bridges are needed
+ if (bridgeList.contains("obfs")) {
+
+ extraLines.append("ClientTransportPlugin obfs3 socks5 127.0.0.1:" + IPtProxy.obfs3Port()).append('\n');
+ extraLines.append("ClientTransportPlugin obfs4 socks5 127.0.0.1:" + IPtProxy.obfs4Port()).append('\n');
+
+ if (bridgeList.equals("obfs4"))
+ builtInBridgeType = "obfs4";
+ }
+
+ if (bridgeList.equals("meek")) {
+ extraLines.append("ClientTransportPlugin meek_lite socks5 127.0.0.1:" + IPtProxy.meekPort()).append('\n');
+ builtInBridgeType = "meek_lite";
+ }
+
+ if (bridgeList.equals("snowflake")) {
+ extraLines.append("ClientTransportPlugin snowflake socks5 127.0.0.1:" + IPtProxy.snowflakePort()).append('\n');
+ builtInBridgeType = "snowflake";
+ }
+
+ if (!TextUtils.isEmpty(builtInBridgeType))
+ getBridges(builtInBridgeType, extraLines);
+ else {
+ String[] bridgeListLines = parseBridgesFromSettings(bridgeList);
+ int bridgeIdx = (int) Math.floor(Math.random() * ((double) bridgeListLines.length));
+ String bridgeLine = bridgeListLines[bridgeIdx];
+ extraLines.append("Bridge ");
+ extraLines.append(bridgeLine);
+ extraLines.append("\n");
+ }
+ }
+
+ //only apply GeoIP if you need it
+ File fileGeoIP = new File(appBinHome, GEOIP_ASSET_KEY);
+ File fileGeoIP6 = new File(appBinHome, GEOIP6_ASSET_KEY);
+
+ if (fileGeoIP.exists()) {
+ extraLines.append("GeoIPFile" + ' ').append(fileGeoIP.getCanonicalPath()).append('\n');
+ extraLines.append("GeoIPv6File" + ' ').append(fileGeoIP6.getCanonicalPath()).append('\n');
+ }
+
+ if (!TextUtils.isEmpty(entranceNodes))
+ extraLines.append("EntryNodes" + ' ').append(entranceNodes).append('\n');
+
+ if (!TextUtils.isEmpty(exitNodes))
+ extraLines.append("ExitNodes" + ' ').append(exitNodes).append('\n');
+
+ if (!TextUtils.isEmpty(excludeNodes))
+ extraLines.append("ExcludeNodes" + ' ').append(excludeNodes).append('\n');
+
+ extraLines.append("StrictNodes" + ' ').append(enableStrictNodes ? "1" : "0").append('\n');
+
+ try {
+ if (ReachableAddresses) {
+ String ReachableAddressesPorts = prefs.getString(PREF_REACHABLE_ADDRESSES_PORTS, "*:80,*:443");
+ extraLines.append("ReachableAddresses" + ' ').append(ReachableAddressesPorts).append('\n');
+ }
+
+ } catch (Exception e) {
+ showToolbarNotification(getString(R.string.your_reachableaddresses_settings_caused_an_exception_), ERROR_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
+ return null;
+ }
+
+ try {
+ if (becomeRelay && (!useBridges) && (!ReachableAddresses)) {
+ int ORPort = Integer.parseInt(Objects.requireNonNull(prefs.getString(PREF_OR_PORT, "9001")));
+ String nickname = prefs.getString(PREF_OR_NICKNAME, "Orbot");
+ String dnsFile = writeDNSFile();
+
+ extraLines.append("ServerDNSResolvConfFile").append(' ').append(dnsFile).append('\n');
+ extraLines.append("ORPort").append(' ').append(ORPort).append('\n');
+ extraLines.append("Nickname").append(' ').append(nickname).append('\n');
+ extraLines.append("ExitPolicy").append(' ').append("reject *:*").append('\n');
+
+ }
+ } catch (Exception e) {
+ showToolbarNotification(getString(R.string.your_relay_settings_caused_an_exception_), ERROR_NOTIFY_ID, R.drawable.ic_stat_notifyerr);
+ return null;
+ }
+
+ if (false) {
+ ContentResolver contentResolver = getApplicationContext().getContentResolver();
+ addV3OnionServicesToTorrc(extraLines, contentResolver);
+ addV3ClientAuthToTorrc(extraLines, contentResolver);
+ addV2HiddenServicesToTorrc(extraLines, contentResolver);
+ addV2ClientCookiesToTorrc(extraLines, contentResolver);
+ }
+
+ return extraLines;
+ }
+
+ public static String formatBandwidthCount(Context context, long bitsPerSecond) {
+ NumberFormat nf = NumberFormat.getInstance(Locale.getDefault());
+ if (bitsPerSecond < 1e6)
+ return nf.format(Math.round(((float) ((int) (bitsPerSecond * 10 / 1024)) / 10)))
+ + "kbps";
+ else
+ return nf.format(Math.round(((float) ((int) (bitsPerSecond * 100 / 1024 / 1024)) / 100)))
+ + "mbps";
+ }
+
+ private void addV3OnionServicesToTorrc(StringBuffer torrc, ContentResolver contentResolver) {
+ try {
+ Cursor onionServices = contentResolver.query(V3_ONION_SERVICES_CONTENT_URI, V3_ONION_SERVICE_PROJECTION, OnionService.ENABLED + "=1", null, null);
+ if (onionServices != null) {
+ while (onionServices.moveToNext()) {
+ int id = onionServices.getInt(onionServices.getColumnIndex(OnionService._ID));
+ int localPort = onionServices.getInt(onionServices.getColumnIndex(OnionService.PORT));
+ int onionPort = onionServices.getInt(onionServices.getColumnIndex(OnionService.ONION_PORT));
+ String path = onionServices.getString(onionServices.getColumnIndex(OnionService.PATH));
+ String domain = onionServices.getString(onionServices.getColumnIndex(OnionService.DOMAIN));
+ if (path == null) {
+ path = "v3";
+ if (domain == null)
+ path += UUID.randomUUID().toString();
+ else
+ path += localPort;
+ ContentValues cv = new ContentValues();
+ cv.put(OnionService.PATH, path);
+ contentResolver.update(V3_ONION_SERVICES_CONTENT_URI, cv, OnionService._ID + "=" + id, null);
+ }
+ String v3DirPath = new File(mV3OnionBasePath.getAbsolutePath(), path).getCanonicalPath();
+ torrc.append("HiddenServiceDir ").append(v3DirPath).append("\n");
+ torrc.append("HiddenServiceVersion 3").append("\n");
+ torrc.append("HiddenServicePort ").append(onionPort).append(" 127.0.0.1:").append(localPort).append("\n");
+ }
+ onionServices.close();
+ }
+ } catch (Exception e) {
+ Log.i("sad","asd");
+ Log.e(TAG, e.getLocalizedMessage());
+ }
+ }
+
+ private void addV2HiddenServicesToTorrc(StringBuffer torrc, ContentResolver contentResolver) {
+ try {
+ Cursor hidden_services = contentResolver.query(V2_HS_CONTENT_URI, LEGACY_V2_ONION_SERVICE_PROJECTION, OnionService.ENABLED + "=1", null, null);
+ if (hidden_services != null) {
+ try {
+ while (hidden_services.moveToNext()) {
+ int id = hidden_services.getInt(hidden_services.getColumnIndex(OnionService._ID));
+ String HSname = hidden_services.getString(hidden_services.getColumnIndex(OnionService.NAME));
+ String domain = hidden_services.getString(hidden_services.getColumnIndex(OnionService.DOMAIN));
+ int HSLocalPort = hidden_services.getInt(hidden_services.getColumnIndex(OnionService.PORT));
+ int HSOnionPort = hidden_services.getInt(hidden_services.getColumnIndex(OnionService.ONION_PORT));
+ int HSAuthCookie = hidden_services.getInt(hidden_services.getColumnIndex(OnionService.AUTH_COOKIE));
+ String path = hidden_services.getString(hidden_services.getColumnIndex(OnionService.PATH));
+
+ // logic to fix bug where you can't have 2+ hidden services on same local port without breaking services that were configured before the bug fix
+ if (path == null) {
+ String newPath = "hs";
+ if (domain == null)
+ newPath +=UUID.randomUUID().toString();
+ else
+ newPath += HSLocalPort;
+
+ ContentValues cv = new ContentValues();
+ cv.put(OnionService.PATH, newPath);
+ contentResolver.update(V2_HS_CONTENT_URI, cv, OnionService._ID + "=" + id, null);
+ path = newPath;
+ }
+
+ String hsDirPath = new File(mHSBasePath.getAbsolutePath(), path).getCanonicalPath();
+
+
+ debug("Adding hidden service on port: " + HSLocalPort);
+
+ torrc.append("HiddenServiceDir" + ' ' + hsDirPath).append('\n');
+ torrc.append("HiddenServiceVersion 2").append('\n');
+ torrc.append("HiddenServicePort" + ' ' + HSOnionPort + " 127.0.0.1:" + HSLocalPort).append('\n');
+
+ if (HSAuthCookie == 1)
+ torrc.append("HiddenServiceAuthorizeClient stealth " + HSname).append('\n');
+ }
+ } catch (NumberFormatException e) {
+ Log.e(TAG, "error parsing hsport", e);
+ } catch (Exception e) {
+ Log.e(TAG, "error starting share server", e);
+ }
+
+ hidden_services.close();
+ }
+ } catch (SecurityException se) {
+ Log.i("sad","asd");
+ }
+ }
+
+ public static String buildV3ClientAuthFile(String domain, String keyHash) {
+ return domain + ":descriptor:x25519:" + keyHash;
+ }
+
+ private void addV3ClientAuthToTorrc(StringBuffer torrc, ContentResolver contentResolver) {
+ Cursor v3auths = contentResolver.query(V3_CLIENT_AUTH_URI, V3_CLIENT_AUTH_PROJECTION, V3ClientAuth.ENABLED + "=1", null, null);
+ if (v3auths != null) {
+ for (File file : mV3AuthBasePath.listFiles()) {
+ if (!file.isDirectory())
+ file.delete(); // todo the adapter should maybe just write these files and not do this in service...
+ }
+ torrc.append("ClientOnionAuthDir " + mV3AuthBasePath.getAbsolutePath()).append('\n');
+ try {
+ int i = 0;
+ while (v3auths.moveToNext()) {
+ String domain = v3auths.getString(v3auths.getColumnIndex(V3ClientAuth.DOMAIN));
+ String hash = v3auths.getString(v3auths.getColumnIndex(V3ClientAuth.HASH));
+ File authFile = new File(mV3AuthBasePath, (i++) + ".auth_private");
+ authFile.createNewFile();
+ FileOutputStream fos = new FileOutputStream(authFile);
+ fos.write(buildV3ClientAuthFile(domain, hash).getBytes());
+ fos.close();
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "error adding v3 client auth...");
+ }
+ }
+ }
+
+ private void addV2ClientCookiesToTorrc(StringBuffer torrc, ContentResolver contentResolver) {
+ try {
+ Cursor client_cookies = contentResolver.query(COOKIE_CONTENT_URI, LEGACY_COOKIE_PROJECTION, ClientCookie.ENABLED + "=1", null, null);
+ if (client_cookies != null) {
+ try {
+ while (client_cookies.moveToNext()) {
+ String domain = client_cookies.getString(client_cookies.getColumnIndex(ClientCookie.DOMAIN));
+ String cookie = client_cookies.getString(client_cookies.getColumnIndex(ClientCookie.AUTH_COOKIE_VALUE));
+ torrc.append("HidServAuth" + ' ' + domain + ' ' + cookie).append('\n');
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "error starting share server", e);
+ }
+ client_cookies.close();
+ }
+ } catch (SecurityException se) {
+ Log.i("sad","asd");
+ }
+ }
+
+ //using Google DNS for now as the public DNS server
+ private String writeDNSFile() throws IOException {
+ File file = new File(appBinHome, "resolv.conf");
+
+ PrintWriter bw = new PrintWriter(new FileWriter(file));
+ bw.println("nameserver 8.8.8.8");
+ bw.println("nameserver 8.8.4.4");
+ bw.close();
+
+ return file.getCanonicalPath();
+ }
+
+ @SuppressLint("NewApi")
+ @Override
+ public void onTrimMemory(int level) {
+ super.onTrimMemory(level);
+
+ switch (level) {
+ case TRIM_MEMORY_BACKGROUND:
+ debug("trim memory requested: app in the background");
+ break;
+
+ case TRIM_MEMORY_COMPLETE:
+ debug("trim memory requested: cleanup all memory");
+ break;
+
+ case TRIM_MEMORY_MODERATE:
+ debug("trim memory requested: clean up some memory");
+ break;
+
+ case TRIM_MEMORY_RUNNING_CRITICAL:
+ debug("trim memory requested: memory on device is very low and critical");
+ break;
+
+ case TRIM_MEMORY_RUNNING_LOW:
+ debug("trim memory requested: memory on device is running low");
+ break;
+
+ case TRIM_MEMORY_RUNNING_MODERATE:
+ debug("trim memory requested: memory on device is moderate");
+ break;
+
+ case TRIM_MEMORY_UI_HIDDEN:
+ debug("trim memory requested: app is not showing UI anymore");
+ break;
+ }
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ Log.e(TAG, "onBind");
+ return super.onBind(intent); // invoking super class will call onRevoke() when appropriate
+ }
+
+ // system calls this method when VPN disconnects (either by the user or another VPN app)
+ @Override
+ public void onRevoke() {
+ Prefs.putUseVpn(false);
+ mVpnManager.handleIntent(new Builder(), new Intent(ACTION_STOP_VPN));
+ // tell UI, if it's open, to update immediately (don't wait for onResume() in Activity...)
+ LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(ACTION_STOP_VPN));
+ }
+
+ private void setExitNode(String newExits) {
+ SharedPreferences prefs = Prefs.getSharedPrefs(getApplicationContext());
+
+ if (TextUtils.isEmpty(newExits)) {
+ prefs.edit().remove("pref_exit_nodes").apply();
+
+ if (conn != null) {
+ try {
+ ArrayList resetBuffer = new ArrayList<>();
+ resetBuffer.add("ExitNodes");
+ resetBuffer.add("StrictNodes");
+ conn.resetConf(resetBuffer);
+ conn.setConf("DisableNetwork", "1");
+ conn.setConf("DisableNetwork", "0");
+
+ } catch (Exception ioe) {
+ Log.e(TAG, "Connection exception occured resetting exits", ioe);
+ }
+ }
+ } else {
+ prefs.edit().putString("pref_exit_nodes", newExits).apply();
+
+ if (conn != null) {
+ try {
+ File fileGeoIP = new File(appBinHome, GEOIP_ASSET_KEY);
+ File fileGeoIP6 = new File(appBinHome, GEOIP6_ASSET_KEY);
+
+ conn.setConf("GeoIPFile", fileGeoIP.getCanonicalPath());
+ conn.setConf("GeoIPv6File", fileGeoIP6.getCanonicalPath());
+
+ conn.setConf("ExitNodes", newExits);
+ conn.setConf("StrictNodes", "1");
+
+ conn.setConf("DisableNetwork", "1");
+ conn.setConf("DisableNetwork", "0");
+
+ } catch (Exception ioe) {
+ Log.e(TAG, "Connection exception occured resetting exits", ioe);
+ }
+ }
+ }
+
+ }
+
+ private void loadBridgeDefaults() {
+ if (alBridges == null) {
+ alBridges = new ArrayList<>();
+
+ try {
+
+ BufferedReader in = new BufferedReader(new InputStreamReader(getResources().openRawResource(R.raw.bridges), "UTF-8"));
+
+ if(orbotLocalConstants.mBridgesDefault.length()>1){
+ Reader inputString = new StringReader(orbotLocalConstants.mBridgesDefault);
+ in = new BufferedReader(inputString);
+ }
+ String str;
+
+ while ((str = in.readLine()) != null) {
+
+ StringTokenizer st = new StringTokenizer(str, " ");
+ Bridge b = new Bridge();
+ b.type = st.nextToken();
+
+ StringBuffer sbConfig = new StringBuffer();
+
+ while (st.hasMoreTokens())
+ sbConfig.append(st.nextToken()).append(' ');
+
+ b.config = sbConfig.toString().trim();
+
+ alBridges.add(b);
+
+ }
+
+ in.close();
+ } catch (Exception e) {
+ Log.i("sad","asd");
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ private void getBridges(String type, StringBuffer extraLines) {
+
+ Collections.shuffle(alBridges, bridgeSelectRandom);
+
+ int maxBridges = 12;
+ int bridgeCount = 0;
+
+
+ if(orbotLocalConstants.mIsManualBridge){
+ List mList = Arrays.asList(orbotLocalConstants.mBridges.split("\n"));
+ alBridges.clear();
+
+ for(int e=0;e maxBridges)
+ break;
+ }
+ }
+ }
+
+
+ public static final class OnionService implements BaseColumns {
+ public static final String NAME = "name";
+ public static final String PORT = "port";
+ public static final String ONION_PORT = "onion_port";
+ public static final String DOMAIN = "domain";
+ public static final String AUTH_COOKIE = "auth_cookie";
+ public static final String AUTH_COOKIE_VALUE = "auth_cookie_value";
+ public static final String ENABLED = "enabled";
+ public static final String PATH = "filepath";
+ }
+
+ public static final class V3ClientAuth implements BaseColumns {
+ public static final String DOMAIN = "domain";
+ public static final String HASH = "hash";
+ public static final String ENABLED = "enabled";
+ }
+
+ public static final class ClientCookie implements BaseColumns {
+ public static final String DOMAIN = "domain";
+ public static final String AUTH_COOKIE_VALUE = "auth_cookie_value";
+ public static final String ENABLED = "enabled";
+ }
+
+ // for bridge loading from the assets default bridges.txt file
+ static class Bridge {
+ String type;
+ String config;
+
+ public Bridge(String pConfig,String pType){
+ config = pConfig;
+ type = pType;
+ }
+
+ public Bridge(){
+ }
+ }
+
+ private class IncomingIntentRouter implements Runnable {
+ Intent mIntent;
+
+ public IncomingIntentRouter(Intent intent) {
+ mIntent = intent;
+ }
+
+ public void run() {
+ String action = mIntent.getAction();
+
+ if (!TextUtils.isEmpty(action)) {
+ if (action.equals(ACTION_START) || action.equals(ACTION_START_ON_BOOT)) {
+
+ if (Prefs.bridgesEnabled()) {
+ if (useIPtObfsMeekProxy())
+ IPtProxy.startObfs4Proxy("DEBUG", false, false);
+ else if (useIPtSnowflakeProxy())
+ startSnowflakeClient();
+ } else if (Prefs.beSnowflakeProxy()) {
+
+ if (Prefs.limitSnowflakeProxying())
+ {
+ if (isChargingAndWifi(OrbotService.this))
+ {
+ enableSnowflakeProxy();
+ }
+
+ }
+ else
+ enableSnowflakeProxy();
+ }
+
+ startTor();
+ replyWithStatus(mIntent);
+
+ if (Prefs.useVpn()) {
+ if (mVpnManager != null
+ && (!mVpnManager.isStarted())) {
+ //start VPN here
+ Intent vpnIntent = VpnService.prepare(OrbotService.this);
+ if (vpnIntent == null) //then we can run the VPN
+ {
+ mVpnManager.handleIntent(new Builder(), mIntent);
+
+ }
+ }
+
+ if (mPortSOCKS != -1 && mPortHTTP != -1)
+ sendCallbackPorts(mPortSOCKS, mPortHTTP, mPortDns, mPortTrans);
+ }
+ } else if (action.equals(ACTION_STOP)) {
+ stopTorAsync();
+ } else if (action.equals(ACTION_START_VPN)) {
+ if (mVpnManager != null && (!mVpnManager.isStarted())) {
+ //start VPN here
+ Intent vpnIntent = VpnService.prepare(OrbotService.this);
+ if (vpnIntent == null) { //then we can run the VPN
+ mVpnManager.handleIntent(new Builder(), mIntent);
+ }
+ }
+
+ if (mPortSOCKS != -1 && mPortHTTP != -1)
+ sendCallbackPorts(mPortSOCKS, mPortHTTP, mPortDns, mPortTrans);
+
+
+ } else if (action.equals(ACTION_STOP_VPN)) {
+ if (mVpnManager != null)
+ mVpnManager.handleIntent(new Builder(), mIntent);
+ } else if (action.equals(ACTION_STATUS)) {
+ replyWithStatus(mIntent);
+ } else if (action.equals(TorControlCommands.SIGNAL_RELOAD)) {
+ requestTorRereadConfig();
+ } else if (action.equals(TorControlCommands.SIGNAL_NEWNYM)) {
+ newIdentity();
+ } else if (action.equals(CMD_ACTIVE)) {
+ sendSignalActive();
+ } else if (action.equals(CMD_SET_EXIT)) {
+ setExitNode(mIntent.getStringExtra("exit"));
+ } else {
+ Log.w(TAG, "unhandled OrbotService Intent: " + action);
+ }
+ }
+ }
+ }
+
+ 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(){
+ if(mNotificationManager!=null){
+ mNotificationManager.cancel(NOTIFY_ID);
+ stopForeground(true);
+ orbotLocalConstants.mNotificationStatus = 0;
+ }
+ }
+
+ public void enableTorNotificationNoBandwidth(){
+ orbotLocalConstants.mNotificationStatus = 1;
+ showToolbarNotification("Connected to the Tor network", HS_NOTIFY_ID, R.mipmap.ic_stat_tor_logo);
+ }
+
+ public void enableNotification(){
+ if(mConnectivity && orbotLocalConstants.mIsTorInitialized){
+ orbotLocalConstants.mNotificationStatus = 1;
+ showToolbarNotification(0+"kbps ⇣ / " +0+"kbps ⇡", HS_NOTIFY_ID, R.mipmap.ic_stat_tor_logo);
+ }
+ }
+
+ public void onSettingRegister(){
+ try {
+ Intent intent = null;
+ intent = new Intent(this, Class.forName("com.hiddenservices.genesissearchengine.production.appManager.settingManager.notificationManager.settingNotificationController"));
+ intent.setFlags(FLAG_ACTIVITY_NEW_TASK);
+ getApplicationContext().startActivity(intent);
+ } catch (ClassNotFoundException e) {
+ Log.i("sad","asd");
+ e.printStackTrace();
+ }
+ }
+
+ 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 {
+ public void onReceive(Context context, Intent intent) {
+ switch (intent.getAction()) {
+ case CMD_NEWNYM: {
+ newIdentity();
+ break;
+ }
+ case CMD_SETTING: {
+ onSettingRegister();
+ break;
+ }
+ case CMD_ACTIVE: {
+ sendSignalActive();
+ break;
+ }
+ }
+ }
+ }
+
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/StartTorReceiver.java b/orbotmanager/src/main/java/org/orbotproject/android/service/StartTorReceiver.java
similarity index 91%
rename from orbotmanager/src/main/java/org/torproject/android/service/StartTorReceiver.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/StartTorReceiver.java
index 943385c8..7e485950 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/StartTorReceiver.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/StartTorReceiver.java
@@ -1,42 +1,38 @@
-package org.torproject.android.service;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Build;
-import android.text.TextUtils;
-
-import org.torproject.android.service.util.Prefs;
-
-
-public class StartTorReceiver extends BroadcastReceiver implements TorServiceConstants {
-
- @Override
- public void onReceive(Context context, Intent intent) {
- /* sanitize the Intent before forwarding it to OrbotService */
- /*Prefs.setContext(context);
- String action = intent.getAction();
- if (TextUtils.equals(action, ACTION_START)) {
- String packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME);
- if (Prefs.allowBackgroundStarts()) {
- Intent startTorIntent = new Intent(context, OrbotService.class);
- startTorIntent.setAction(action);
- if (packageName != null) {
- startTorIntent.putExtra(OrbotService.EXTRA_PACKAGE_NAME, packageName);
- }
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && Prefs.persistNotifications()) {
- context.startForegroundService(startTorIntent);
- } else {
- context.startService(startTorIntent);
- }
- } else if (!TextUtils.isEmpty(packageName)) {
- // let the requesting app know that the user has disabled
- // starting via Intent
- Intent startsDisabledIntent = new Intent(ACTION_STATUS);
- startsDisabledIntent.putExtra(EXTRA_STATUS, STATUS_STARTS_DISABLED);
- startsDisabledIntent.setPackage(packageName);
- context.sendBroadcast(startsDisabledIntent);
- }
- }*/
- }
-}
+package org.orbotproject.android.service;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+
+public class StartTorReceiver extends BroadcastReceiver implements TorServiceConstants {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ /* sanitize the Intent before forwarding it to OrbotService */
+ /*Prefs.setContext(context);
+ String action = intent.getAction();
+ if (TextUtils.equals(action, ACTION_START)) {
+ String packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME);
+ if (Prefs.allowBackgroundStarts()) {
+ Intent startTorIntent = new Intent(context, OrbotService.class);
+ startTorIntent.setAction(action);
+ if (packageName != null) {
+ startTorIntent.putExtra(OrbotService.EXTRA_PACKAGE_NAME, packageName);
+ }
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && Prefs.persistNotifications()) {
+ context.startForegroundService(startTorIntent);
+ } else {
+ context.startService(startTorIntent);
+ }
+ } else if (!TextUtils.isEmpty(packageName)) {
+ // let the requesting app know that the user has disabled
+ // starting via Intent
+ Intent startsDisabledIntent = new Intent(ACTION_STATUS);
+ startsDisabledIntent.putExtra(EXTRA_STATUS, STATUS_STARTS_DISABLED);
+ startsDisabledIntent.setPackage(packageName);
+ context.sendBroadcast(startsDisabledIntent);
+ }
+ }*/
+ }
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/TorEventHandler.java b/orbotmanager/src/main/java/org/orbotproject/android/service/TorEventHandler.java
similarity index 94%
rename from orbotmanager/src/main/java/org/torproject/android/service/TorEventHandler.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/TorEventHandler.java
index 6bfa118a..328f58c5 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/TorEventHandler.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/TorEventHandler.java
@@ -1,215 +1,212 @@
-package org.torproject.android.service;
-
-import android.text.TextUtils;
-
-import net.freehaven.tor.control.EventHandler;
-
-import org.torproject.android.service.util.ExternalIPFetcher;
-import org.torproject.android.service.util.Prefs;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.StringTokenizer;
-
-/**
- * Created by n8fr8 on 9/25/16.
- */
-public class TorEventHandler implements EventHandler, TorServiceConstants {
-
- private final static int BW_THRESDHOLD = 10000;
- private final OrbotService mService;
- private long lastRead = -1;
- private long lastWritten = -1;
- private long mTotalTrafficWritten = 0;
- private long mTotalTrafficRead = 0;
- private final HashMap hmBuiltNodes = new HashMap<>();
-
- public TorEventHandler(OrbotService service) {
- mService = service;
- }
-
- public HashMap getNodes() {
- return hmBuiltNodes;
- }
-
- @Override
- public void message(String severity, String msg) {
- if (severity.equalsIgnoreCase("debug"))
- mService.debug(severity + ": " + msg);
- else
- mService.logNotice(severity + ": " + msg);
- }
-
- @Override
- public void newDescriptors(List orList) {
-
- for (String desc : orList)
- mService.debug("descriptors: " + desc);
-
- }
-
- @Override
- public void orConnStatus(String status, String orName) {
-
- String sb = "orConnStatus (" +
- parseNodeName(orName) +
- "): " +
- status;
- mService.debug(sb);
- }
-
- @Override
- public void streamStatus(String status, String streamID, String target) {
-
- String sb = "StreamStatus (" +
- (streamID) +
- "): " +
- status;
- mService.debug(sb);
- }
-
- @Override
- public void unrecognized(String type, String msg) {
-
- String sb = "Message (" +
- type +
- "): " +
- msg;
- mService.logNotice(sb);
- }
-
- @Override
- public void bandwidthUsed(long read, long written) {
-
- if (lastWritten > BW_THRESDHOLD || lastRead > BW_THRESDHOLD) {
-
- int iconId = R.mipmap.ic_stat_tor_logo;
-
- String sb = OrbotService.formatBandwidthCount(mService, read) + " \u2193" + " / " +
- OrbotService.formatBandwidthCount(mService, written) + " \u2191";
- mService.showToolbarNotification(sb, OrbotService.NOTIFY_ID, iconId);
-
- mTotalTrafficWritten += written;
- mTotalTrafficRead += read;
-
- mService.sendCallbackBandwidth(written, read, mTotalTrafficWritten, mTotalTrafficRead);
-
- lastWritten = 0;
- lastRead = 0;
- }
-
- lastWritten += written;
- lastRead += read;
-
- }
-
- public void circuitStatus(String status, String circID, String path) {
-
- /* once the first circuit is complete, then announce that Orbot is on*/
- if (mService.getCurrentStatus() == STATUS_STARTING && TextUtils.equals(status, "BUILT"))
- mService.sendCallbackStatus(STATUS_ON);
-
- if (Prefs.useDebugLogging()) {
- StringBuilder sb = new StringBuilder();
- sb.append("Circuit (");
- sb.append((circID));
- sb.append(") ");
- sb.append(status);
- sb.append(": ");
-
- StringTokenizer st = new StringTokenizer(path, ",");
- Node node;
-
- boolean isFirstNode = true;
- int nodeCount = st.countTokens();
-
- while (st.hasMoreTokens()) {
- String nodePath = st.nextToken();
- String nodeId = null, nodeName = null;
-
- String[] nodeParts;
-
- if (nodePath.contains("="))
- nodeParts = nodePath.split("=");
- else
- nodeParts = nodePath.split("~");
-
- if (nodeParts.length == 1) {
- nodeId = nodeParts[0].substring(1);
- nodeName = nodeId;
- } else if (nodeParts.length == 2) {
- nodeId = nodeParts[0].substring(1);
- nodeName = nodeParts[1];
- }
-
- if (nodeId == null)
- continue;
-
- node = hmBuiltNodes.get(nodeId);
-
- if (node == null) {
- node = new Node();
- node.id = nodeId;
- node.name = nodeName;
- }
-
- node.status = status;
-
- sb.append(node.name);
-
- if (!TextUtils.isEmpty(node.ipAddress))
- sb.append("(").append(node.ipAddress).append(")");
-
- if (st.hasMoreTokens())
- sb.append(" > ");
-
- if (status.equals("EXTENDED")) {
-
- if (isFirstNode) {
- hmBuiltNodes.put(node.id, node);
-
- if (node.ipAddress == null && (!node.isFetchingInfo) && Prefs.useDebugLogging()) {
- node.isFetchingInfo = true;
- mService.exec(new ExternalIPFetcher(mService, node, OrbotService.mPortHTTP));
- }
-
- isFirstNode = false;
- }
- } else if (status.equals("BUILT")) {
- // mService.logNotice(sb.toString());
-
- if (Prefs.useDebugLogging() && nodeCount > 3)
- mService.debug(sb.toString());
- } else if (status.equals("CLOSED")) {
- // mService.logNotice(sb.toString());
- hmBuiltNodes.remove(node.id);
- }
-
- }
-
-
- }
-
-
- }
-
- private String parseNodeName(String node) {
- if (node.indexOf('=') != -1) {
- return (node.substring(node.indexOf("=") + 1));
- } else if (node.indexOf('~') != -1) {
- return (node.substring(node.indexOf("~") + 1));
- } else
- return node;
- }
-
- public static class Node {
- public String status;
- public String id;
- public String name;
- public String ipAddress;
- public String country;
- public String organization;
-
- public boolean isFetchingInfo = false;
- }
-}
+package org.orbotproject.android.service;
+
+import android.text.TextUtils;
+import net.freehaven.tor.control.EventHandler;
+import org.orbotproject.android.service.util.ExternalIPFetcher;
+import org.orbotproject.android.service.util.Prefs;
+import java.util.HashMap;
+import java.util.List;
+import java.util.StringTokenizer;
+
+/**
+ * Created by n8fr8 on 9/25/16.
+ */
+public class TorEventHandler implements EventHandler, TorServiceConstants {
+
+ private final static int BW_THRESDHOLD = 10000;
+ private final OrbotService mService;
+ private long lastRead = -1;
+ private long lastWritten = -1;
+ private long mTotalTrafficWritten = 0;
+ private long mTotalTrafficRead = 0;
+ private final HashMap hmBuiltNodes = new HashMap<>();
+
+ public TorEventHandler(OrbotService service) {
+ mService = service;
+ }
+
+ public HashMap getNodes() {
+ return hmBuiltNodes;
+ }
+
+ @Override
+ public void message(String severity, String msg) {
+ if (severity.equalsIgnoreCase("debug"))
+ mService.debug(severity + ": " + msg);
+ else
+ mService.logNotice(severity + ": " + msg);
+ }
+
+ @Override
+ public void newDescriptors(List orList) {
+
+ for (String desc : orList)
+ mService.debug("descriptors: " + desc);
+
+ }
+
+ @Override
+ public void orConnStatus(String status, String orName) {
+
+ String sb = "orConnStatus (" +
+ parseNodeName(orName) +
+ "): " +
+ status;
+ mService.debug(sb);
+ }
+
+ @Override
+ public void streamStatus(String status, String streamID, String target) {
+
+ String sb = "StreamStatus (" +
+ (streamID) +
+ "): " +
+ status;
+ mService.debug(sb);
+ }
+
+ @Override
+ public void unrecognized(String type, String msg) {
+
+ String sb = "Message (" +
+ type +
+ "): " +
+ msg;
+ mService.logNotice(sb);
+ }
+
+ @Override
+ public void bandwidthUsed(long read, long written) {
+
+ if (lastWritten > BW_THRESDHOLD || lastRead > BW_THRESDHOLD) {
+
+ int iconId = R.mipmap.ic_stat_tor_logo;
+
+ String sb = OrbotService.formatBandwidthCount(mService, read) + " \u2193" + " / " +
+ OrbotService.formatBandwidthCount(mService, written) + " \u2191";
+ mService.showToolbarNotification(sb, OrbotService.NOTIFY_ID, iconId);
+
+ mTotalTrafficWritten += written;
+ mTotalTrafficRead += read;
+
+ mService.sendCallbackBandwidth(written, read, mTotalTrafficWritten, mTotalTrafficRead);
+
+ lastWritten = 0;
+ lastRead = 0;
+ }
+
+ lastWritten += written;
+ lastRead += read;
+
+ }
+
+ public void circuitStatus(String status, String circID, String path) {
+
+ /* once the first circuit is complete, then announce that Orbot is on*/
+ if (mService.getCurrentStatus() == STATUS_STARTING && TextUtils.equals(status, "BUILT"))
+ mService.sendCallbackStatus(STATUS_ON);
+
+ if (Prefs.useDebugLogging()) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("Circuit (");
+ sb.append((circID));
+ sb.append(") ");
+ sb.append(status);
+ sb.append(": ");
+
+ StringTokenizer st = new StringTokenizer(path, ",");
+ Node node;
+
+ boolean isFirstNode = true;
+ int nodeCount = st.countTokens();
+
+ while (st.hasMoreTokens()) {
+ String nodePath = st.nextToken();
+ String nodeId = null, nodeName = null;
+
+ String[] nodeParts;
+
+ if (nodePath.contains("="))
+ nodeParts = nodePath.split("=");
+ else
+ nodeParts = nodePath.split("~");
+
+ if (nodeParts.length == 1) {
+ nodeId = nodeParts[0].substring(1);
+ nodeName = nodeId;
+ } else if (nodeParts.length == 2) {
+ nodeId = nodeParts[0].substring(1);
+ nodeName = nodeParts[1];
+ }
+
+ if (nodeId == null)
+ continue;
+
+ node = hmBuiltNodes.get(nodeId);
+
+ if (node == null) {
+ node = new Node();
+ node.id = nodeId;
+ node.name = nodeName;
+ }
+
+ node.status = status;
+
+ sb.append(node.name);
+
+ if (!TextUtils.isEmpty(node.ipAddress))
+ sb.append("(").append(node.ipAddress).append(")");
+
+ if (st.hasMoreTokens())
+ sb.append(" > ");
+
+ if (status.equals("EXTENDED")) {
+
+ if (isFirstNode) {
+ hmBuiltNodes.put(node.id, node);
+
+ if (node.ipAddress == null && (!node.isFetchingInfo) && Prefs.useDebugLogging()) {
+ node.isFetchingInfo = true;
+ mService.exec(new ExternalIPFetcher(mService, node, OrbotService.mPortHTTP));
+ }
+
+ isFirstNode = false;
+ }
+ } else if (status.equals("BUILT")) {
+ // mService.logNotice(sb.toString());
+
+ if (Prefs.useDebugLogging() && nodeCount > 3)
+ mService.debug(sb.toString());
+ } else if (status.equals("CLOSED")) {
+ // mService.logNotice(sb.toString());
+ hmBuiltNodes.remove(node.id);
+ }
+
+ }
+
+
+ }
+
+
+ }
+
+ private String parseNodeName(String node) {
+ if (node.indexOf('=') != -1) {
+ return (node.substring(node.indexOf("=") + 1));
+ } else if (node.indexOf('~') != -1) {
+ return (node.substring(node.indexOf("~") + 1));
+ } else
+ return node;
+ }
+
+ public static class Node {
+ public String status;
+ public String id;
+ public String name;
+ public String ipAddress;
+ public String country;
+ public String organization;
+
+ public boolean isFetchingInfo = false;
+ }
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/TorServiceConstants.java b/orbotmanager/src/main/java/org/orbotproject/android/service/TorServiceConstants.java
similarity index 96%
rename from orbotmanager/src/main/java/org/torproject/android/service/TorServiceConstants.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/TorServiceConstants.java
index 6fc1d1d5..7403123a 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/TorServiceConstants.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/TorServiceConstants.java
@@ -1,103 +1,103 @@
-/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - http://openideals.com/guardian */
-/* See LICENSE for licensing information */
-
-package org.torproject.android.service;
-
-import android.content.Intent;
-
-public interface TorServiceConstants {
-
- String DIRECTORY_TOR_DATA = "tordata";
-
- //geoip data file asset key
- String GEOIP_ASSET_KEY = "geoip";
- String GEOIP6_ASSET_KEY = "geoip6";
-
- String IP_LOCALHOST = "127.0.0.1";
- int TOR_TRANSPROXY_PORT_DEFAULT = 9040;
-
- int TOR_DNS_PORT_DEFAULT = 5400;
-
- String HTTP_PROXY_PORT_DEFAULT = "8118"; // like Privoxy!
- String SOCKS_PROXY_PORT_DEFAULT = "9050";
-
- //control port
- String LOG_NOTICE_HEADER = "NOTICE";
- String LOG_NOTICE_BOOTSTRAPPED = "Bootstrapped";
-
- /**
- * A request to Orbot to transparently start Tor services
- */
- String ACTION_START = "org.torproject.android.intent.action.START";
- String ACTION_STOP = "org.torproject.android.intent.action.STOP";
-
- String ACTION_START_VPN = "org.torproject.android.intent.action.START_VPN";
- String ACTION_STOP_VPN = "org.torproject.android.intent.action.STOP_VPN";
-
- String ACTION_START_ON_BOOT = "org.torproject.android.intent.action.START_BOOT";
-
- int REQUEST_VPN = 7777;
-
- /**
- * {@link Intent} send by Orbot with {@code ON/OFF/STARTING/STOPPING} status
- */
- String ACTION_STATUS = "org.torproject.android.intent.action.STATUS";
- /**
- * {@code String} that contains a status constant: {@link #STATUS_ON},
- * {@link #STATUS_OFF}, {@link #STATUS_STARTING}, or
- * {@link #STATUS_STOPPING}
- */
- String EXTRA_STATUS = "org.torproject.android.intent.extra.STATUS";
- /**
- * A {@link String} {@code packageName} for Orbot to direct its status reply
- * to, used in {@link #ACTION_START} {@link Intent}s sent to Orbot
- */
- String EXTRA_PACKAGE_NAME = "org.torproject.android.intent.extra.PACKAGE_NAME";
- /**
- * The SOCKS proxy settings in URL form.
- */
- String EXTRA_SOCKS_PROXY = "org.torproject.android.intent.extra.SOCKS_PROXY";
- String EXTRA_SOCKS_PROXY_HOST = "org.torproject.android.intent.extra.SOCKS_PROXY_HOST";
- String EXTRA_SOCKS_PROXY_PORT = "org.torproject.android.intent.extra.SOCKS_PROXY_PORT";
- /**
- * The HTTP proxy settings in URL form.
- */
- String EXTRA_HTTP_PROXY = "org.torproject.android.intent.extra.HTTP_PROXY";
- String EXTRA_HTTP_PROXY_HOST = "org.torproject.android.intent.extra.HTTP_PROXY_HOST";
- String EXTRA_HTTP_PROXY_PORT = "org.torproject.android.intent.extra.HTTP_PROXY_PORT";
-
- String EXTRA_DNS_PORT = "org.torproject.android.intent.extra.DNS_PORT";
- String EXTRA_TRANS_PORT = "org.torproject.android.intent.extra.TRANS_PORT";
-
- String LOCAL_ACTION_LOG = "log";
- String LOCAL_ACTION_BANDWIDTH = "bandwidth";
- String LOCAL_EXTRA_LOG = "log";
- String LOCAL_ACTION_PORTS = "ports";
-
- /**
- * All tor-related services and daemons are stopped
- */
- String STATUS_OFF = "OFF";
- /**
- * All tor-related services and daemons have completed starting
- */
- String STATUS_ON = "ON";
- String STATUS_STARTING = "STARTING";
- String STATUS_STOPPING = "STOPPING";
-
- String STATUS_STARTS_DISABLED = "STARTS_DISABLED";
-
- // actions for internal command Intents
- String CMD_SET_EXIT = "setexit";
- String CMD_ACTIVE = "ACTIVE";
-
- String CMD_NEWNYM = "newnym";
- String CMD_SETTING = "setting";
- //obfsproxy
- String OBFSCLIENT_ASSET_KEY = "obfs4proxy";
-
- String HIDDEN_SERVICES_DIR = "hidden_services";
- String ONION_SERVICES_DIR = "v3_onion_services";
- String V3_CLIENT_AUTH_DIR = "v3_client_auth";
-
-}
+/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - http://openideals.com/guardian */
+/* See LICENSE for licensing information */
+
+package org.orbotproject.android.service;
+
+import android.content.Intent;
+
+public interface TorServiceConstants {
+
+ String DIRECTORY_TOR_DATA = "tordata";
+
+ //geoip data file asset key
+ String GEOIP_ASSET_KEY = "geoip";
+ String GEOIP6_ASSET_KEY = "geoip6";
+
+ String IP_LOCALHOST = "127.0.0.1";
+ int TOR_TRANSPROXY_PORT_DEFAULT = 9040;
+
+ int TOR_DNS_PORT_DEFAULT = 5400;
+
+ String HTTP_PROXY_PORT_DEFAULT = "8118"; // like Privoxy!
+ String SOCKS_PROXY_PORT_DEFAULT = "9050";
+
+ //control port
+ String LOG_NOTICE_HEADER = "NOTICE";
+ String LOG_NOTICE_BOOTSTRAPPED = "Bootstrapped";
+
+ /**
+ * A request to Orbot to transparently start Tor services
+ */
+ String ACTION_START = "org.torproject.android.intent.action.START";
+ String ACTION_STOP = "org.torproject.android.intent.action.STOP";
+
+ String ACTION_START_VPN = "org.torproject.android.intent.action.START_VPN";
+ String ACTION_STOP_VPN = "org.torproject.android.intent.action.STOP_VPN";
+
+ String ACTION_START_ON_BOOT = "org.torproject.android.intent.action.START_BOOT";
+
+ int REQUEST_VPN = 7777;
+
+ /**
+ * {@link Intent} send by Orbot with {@code ON/OFF/STARTING/STOPPING} status
+ */
+ String ACTION_STATUS = "org.torproject.android.intent.action.STATUS";
+ /**
+ * {@code String} that contains a status constant: {@link #STATUS_ON},
+ * {@link #STATUS_OFF}, {@link #STATUS_STARTING}, or
+ * {@link #STATUS_STOPPING}
+ */
+ String EXTRA_STATUS = "org.torproject.android.intent.extra.STATUS";
+ /**
+ * A {@link String} {@code packageName} for Orbot to direct its status reply
+ * to, used in {@link #ACTION_START} {@link Intent}s sent to Orbot
+ */
+ String EXTRA_PACKAGE_NAME = "org.torproject.android.intent.extra.PACKAGE_NAME";
+ /**
+ * The SOCKS proxy settings in URL form.
+ */
+ String EXTRA_SOCKS_PROXY = "org.torproject.android.intent.extra.SOCKS_PROXY";
+ String EXTRA_SOCKS_PROXY_HOST = "org.torproject.android.intent.extra.SOCKS_PROXY_HOST";
+ String EXTRA_SOCKS_PROXY_PORT = "org.torproject.android.intent.extra.SOCKS_PROXY_PORT";
+ /**
+ * The HTTP proxy settings in URL form.
+ */
+ String EXTRA_HTTP_PROXY = "org.torproject.android.intent.extra.HTTP_PROXY";
+ String EXTRA_HTTP_PROXY_HOST = "org.torproject.android.intent.extra.HTTP_PROXY_HOST";
+ String EXTRA_HTTP_PROXY_PORT = "org.torproject.android.intent.extra.HTTP_PROXY_PORT";
+
+ String EXTRA_DNS_PORT = "org.torproject.android.intent.extra.DNS_PORT";
+ String EXTRA_TRANS_PORT = "org.torproject.android.intent.extra.TRANS_PORT";
+
+ String LOCAL_ACTION_LOG = "log";
+ String LOCAL_ACTION_BANDWIDTH = "bandwidth";
+ String LOCAL_EXTRA_LOG = "log";
+ String LOCAL_ACTION_PORTS = "ports";
+
+ /**
+ * All tor-related services and daemons are stopped
+ */
+ String STATUS_OFF = "OFF";
+ /**
+ * All tor-related services and daemons have completed starting
+ */
+ String STATUS_ON = "ON";
+ String STATUS_STARTING = "STARTING";
+ String STATUS_STOPPING = "STOPPING";
+
+ String STATUS_STARTS_DISABLED = "STARTS_DISABLED";
+
+ // actions for internal command Intents
+ String CMD_SET_EXIT = "setexit";
+ String CMD_ACTIVE = "ACTIVE";
+
+ String CMD_NEWNYM = "newnym";
+ String CMD_SETTING = "setting";
+ //obfsproxy
+ String OBFSCLIENT_ASSET_KEY = "obfs4proxy";
+
+ String HIDDEN_SERVICES_DIR = "hidden_services";
+ String ONION_SERVICES_DIR = "v3_onion_services";
+ String V3_CLIENT_AUTH_DIR = "v3_client_auth";
+
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/util/CustomNativeLoader.java b/orbotmanager/src/main/java/org/orbotproject/android/service/util/CustomNativeLoader.java
similarity index 95%
rename from orbotmanager/src/main/java/org/torproject/android/service/util/CustomNativeLoader.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/util/CustomNativeLoader.java
index fb528621..9b9edb97 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/util/CustomNativeLoader.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/util/CustomNativeLoader.java
@@ -1,128 +1,128 @@
-package org.torproject.android.service.util;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.os.Build;
-import android.util.Log;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-public class CustomNativeLoader {
-
- private final static String TAG = "CNL";
-
- @SuppressLint("SetWorldReadable")
- private static boolean loadFromZip(Context context, String libname, File destLocalFile, String arch) {
-
-
- ZipFile zipFile = null;
- InputStream stream = null;
-
- try {
- zipFile = new ZipFile(context.getApplicationInfo().sourceDir);
- ZipEntry entry = zipFile.getEntry("lib/" + arch + "/" + libname + ".so");
- if (entry == null) {
- entry = zipFile.getEntry("jni/" + arch + "/" + libname + ".so");
- if (entry == null)
- throw new Exception("Unable to find file in apk:" + "lib/" + arch + "/" + libname);
- }
-
- //how we wrap this in another stream because the native .so is zipped itself
- stream = zipFile.getInputStream(entry);
-
- OutputStream out = new FileOutputStream(destLocalFile);
- byte[] buf = new byte[4096];
- int len;
- while ((len = stream.read(buf)) > 0) {
- Thread.yield();
- out.write(buf, 0, len);
- }
- out.close();
-
- destLocalFile.setReadable(true, false);
- destLocalFile.setExecutable(true, false);
- destLocalFile.setWritable(true);
-
- return true;
- } catch (Exception e) {
- Log.e(TAG, e.getMessage());
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (Exception e) {
- Log.e(TAG, e.getMessage());
- }
- }
- if (zipFile != null) {
- try {
- zipFile.close();
- } catch (Exception e) {
- Log.e(TAG, e.getMessage());
- }
- }
- }
- return false;
- }
-
- public static File loadNativeBinary(Context context, String libname, File destLocalFile) {
-
- try {
-
-
- File fileNativeBin = new File(getNativeLibraryDir(context), libname + ".so");
- if (!fileNativeBin.exists())
- fileNativeBin = new File(getNativeLibraryDir(context), "lib" + libname + ".so");
-
- if (fileNativeBin.exists()) {
- if (fileNativeBin.canExecute())
- return fileNativeBin;
- else {
- setExecutable(fileNativeBin);
-
- if (fileNativeBin.canExecute())
- return fileNativeBin;
- }
- }
-
- String folder = Build.CPU_ABI;
-
-
- String javaArch = System.getProperty("os.arch");
- if (javaArch != null && javaArch.contains("686")) {
- folder = "x86";
- }
-
- if (loadFromZip(context, libname, destLocalFile, folder)) {
- return destLocalFile;
- }
-
- } catch (Throwable e) {
- Log.e(TAG, e.getMessage(), e);
- }
-
-
- return null;
- }
-
- private static void setExecutable(File fileBin) {
- fileBin.setReadable(true);
- fileBin.setExecutable(true);
- fileBin.setWritable(false);
- fileBin.setWritable(true, true);
- }
-
- // Return Full path to the directory where native JNI libraries are stored.
- private static String getNativeLibraryDir(Context context) {
- ApplicationInfo appInfo = context.getApplicationInfo();
- return appInfo.nativeLibraryDir;
- }
-
-}
-
+package org.orbotproject.android.service.util;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.os.Build;
+import android.util.Log;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+public class CustomNativeLoader {
+
+ private final static String TAG = "CNL";
+
+ @SuppressLint("SetWorldReadable")
+ private static boolean loadFromZip(Context context, String libname, File destLocalFile, String arch) {
+
+
+ ZipFile zipFile = null;
+ InputStream stream = null;
+
+ try {
+ zipFile = new ZipFile(context.getApplicationInfo().sourceDir);
+ ZipEntry entry = zipFile.getEntry("lib/" + arch + "/" + libname + ".so");
+ if (entry == null) {
+ entry = zipFile.getEntry("jni/" + arch + "/" + libname + ".so");
+ if (entry == null)
+ throw new Exception("Unable to find file in apk:" + "lib/" + arch + "/" + libname);
+ }
+
+ //how we wrap this in another stream because the native .so is zipped itself
+ stream = zipFile.getInputStream(entry);
+
+ OutputStream out = new FileOutputStream(destLocalFile);
+ byte[] buf = new byte[4096];
+ int len;
+ while ((len = stream.read(buf)) > 0) {
+ Thread.yield();
+ out.write(buf, 0, len);
+ }
+ out.close();
+
+ destLocalFile.setReadable(true, false);
+ destLocalFile.setExecutable(true, false);
+ destLocalFile.setWritable(true);
+
+ return true;
+ } catch (Exception e) {
+ Log.e(TAG, e.getMessage());
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (Exception e) {
+ Log.e(TAG, e.getMessage());
+ }
+ }
+ if (zipFile != null) {
+ try {
+ zipFile.close();
+ } catch (Exception e) {
+ Log.e(TAG, e.getMessage());
+ }
+ }
+ }
+ return false;
+ }
+
+ public static File loadNativeBinary(Context context, String libname, File destLocalFile) {
+
+ try {
+
+
+ File fileNativeBin = new File(getNativeLibraryDir(context), libname + ".so");
+ if (!fileNativeBin.exists())
+ fileNativeBin = new File(getNativeLibraryDir(context), "lib" + libname + ".so");
+
+ if (fileNativeBin.exists()) {
+ if (fileNativeBin.canExecute())
+ return fileNativeBin;
+ else {
+ setExecutable(fileNativeBin);
+
+ if (fileNativeBin.canExecute())
+ return fileNativeBin;
+ }
+ }
+
+ String folder = Build.CPU_ABI;
+
+
+ String javaArch = System.getProperty("os.arch");
+ if (javaArch != null && javaArch.contains("686")) {
+ folder = "x86";
+ }
+
+ if (loadFromZip(context, libname, destLocalFile, folder)) {
+ return destLocalFile;
+ }
+
+ } catch (Throwable e) {
+ Log.e(TAG, e.getMessage(), e);
+ }
+
+
+ return null;
+ }
+
+ private static void setExecutable(File fileBin) {
+ fileBin.setReadable(true);
+ fileBin.setExecutable(true);
+ fileBin.setWritable(false);
+ fileBin.setWritable(true, true);
+ }
+
+ // Return Full path to the directory where native JNI libraries are stored.
+ private static String getNativeLibraryDir(Context context) {
+ ApplicationInfo appInfo = context.getApplicationInfo();
+ return appInfo.nativeLibraryDir;
+ }
+
+}
+
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/util/CustomShell.java b/orbotmanager/src/main/java/org/orbotproject/android/service/util/CustomShell.java
similarity index 95%
rename from orbotmanager/src/main/java/org/torproject/android/service/util/CustomShell.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/util/CustomShell.java
index 8f50ccf2..5db0547a 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/util/CustomShell.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/util/CustomShell.java
@@ -1,80 +1,80 @@
-package org.torproject.android.service.util;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.annotation.WorkerThread;
-
-import com.jaredrummler.android.shell.CommandResult;
-import com.jaredrummler.android.shell.Shell;
-import com.jaredrummler.android.shell.ShellExitCode;
-import com.jaredrummler.android.shell.StreamGobbler;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-public class CustomShell extends Shell {
-
-
- @WorkerThread
- public static CommandResult run(@NonNull String shell, boolean waitFor, @Nullable Map env, @NonNull String command) {
- List stdout = Collections.synchronizedList(new ArrayList<>());
- List stderr = Collections.synchronizedList(new ArrayList<>());
- int exitCode = -1;
-
- try {
-
- // setup our process, retrieve stdin stream, and stdout/stderr gobblers
- //Process process = runWithEnv(command, env);
- ProcessBuilder builder = new ProcessBuilder();
-
- if (env != null && (!env.isEmpty()))
- builder.environment().putAll(env);
-
- builder.command("/system/bin/" + shell, "-c", command);
- Process process = builder.start();
-
- StreamGobbler stdoutGobbler = null;
- StreamGobbler stderrGobbler = null;
-
- if (waitFor) {
- stdoutGobbler = new StreamGobbler(process.getInputStream(), stdout);
- stderrGobbler = new StreamGobbler(process.getErrorStream(), stderr);
-
- // start gobbling and write our commands to the shell
- stdoutGobbler.start();
- stderrGobbler.start();
- }
-
- // wait for our process to finish, while we gobble away in the background
- if (waitFor)
- exitCode = process.waitFor();
- else
- exitCode = 0;
-
- // make sure our threads are done gobbling, our streams are closed, and the process is destroyed - while the
- // latter two shouldn't be needed in theory, and may even produce warnings, in "normal" Java they are required
- // for guaranteed cleanup of resources, so lets be safe and do this on Android as well
- /**
- try {
- stdin.close();
- } catch (IOException e) {
- // might be closed already
- }**/
-
- if (waitFor) {
- stdoutGobbler.join();
- stderrGobbler.join();
- }
-
- } catch (InterruptedException e) {
- exitCode = ShellExitCode.WATCHDOG_EXIT;
- } catch (IOException e) {
- exitCode = ShellExitCode.SHELL_WRONG_UID;
- }
-
- return new CommandResult(stdout, stderr, exitCode);
- }
-}
+package org.orbotproject.android.service.util;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.WorkerThread;
+
+import com.jaredrummler.android.shell.CommandResult;
+import com.jaredrummler.android.shell.Shell;
+import com.jaredrummler.android.shell.ShellExitCode;
+import com.jaredrummler.android.shell.StreamGobbler;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+public class CustomShell extends Shell {
+
+
+ @WorkerThread
+ public static CommandResult run(@NonNull String shell, boolean waitFor, @Nullable Map env, @NonNull String command) {
+ List stdout = Collections.synchronizedList(new ArrayList<>());
+ List stderr = Collections.synchronizedList(new ArrayList<>());
+ int exitCode = -1;
+
+ try {
+
+ // setup our process, retrieve stdin stream, and stdout/stderr gobblers
+ //Process process = runWithEnv(command, env);
+ ProcessBuilder builder = new ProcessBuilder();
+
+ if (env != null && (!env.isEmpty()))
+ builder.environment().putAll(env);
+
+ builder.command("/system/bin/" + shell, "-c", command);
+ Process process = builder.start();
+
+ StreamGobbler stdoutGobbler = null;
+ StreamGobbler stderrGobbler = null;
+
+ if (waitFor) {
+ stdoutGobbler = new StreamGobbler(process.getInputStream(), stdout);
+ stderrGobbler = new StreamGobbler(process.getErrorStream(), stderr);
+
+ // start gobbling and write our commands to the shell
+ stdoutGobbler.start();
+ stderrGobbler.start();
+ }
+
+ // wait for our process to finish, while we gobble away in the background
+ if (waitFor)
+ exitCode = process.waitFor();
+ else
+ exitCode = 0;
+
+ // make sure our threads are done gobbling, our streams are closed, and the process is destroyed - while the
+ // latter two shouldn't be needed in theory, and may even produce warnings, in "normal" Java they are required
+ // for guaranteed cleanup of resources, so lets be safe and do this on Android as well
+ /**
+ try {
+ stdin.close();
+ } catch (IOException e) {
+ // might be closed already
+ }**/
+
+ if (waitFor) {
+ stdoutGobbler.join();
+ stderrGobbler.join();
+ }
+
+ } catch (InterruptedException e) {
+ exitCode = ShellExitCode.WATCHDOG_EXIT;
+ } catch (IOException e) {
+ exitCode = ShellExitCode.SHELL_WRONG_UID;
+ }
+
+ return new CommandResult(stdout, stderr, exitCode);
+ }
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/util/CustomTorResourceInstaller.java b/orbotmanager/src/main/java/org/orbotproject/android/service/util/CustomTorResourceInstaller.java
similarity index 93%
rename from orbotmanager/src/main/java/org/torproject/android/service/util/CustomTorResourceInstaller.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/util/CustomTorResourceInstaller.java
index fc8acde1..c925a7b2 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/util/CustomTorResourceInstaller.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/util/CustomTorResourceInstaller.java
@@ -1,127 +1,127 @@
-package org.torproject.android.service.util;
-
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.util.Log;
-
-import org.torproject.android.service.TorServiceConstants;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-public class CustomTorResourceInstaller {
-
- private static final String TAG = "CustomTorResourceInstaller";
-
- private File installFolder;
- private Context context;
-
- public CustomTorResourceInstaller(Context context, File installFolder) {
- this.installFolder = installFolder;
- this.context = context;
- }
-
- // Return Full path to the directory where native JNI libraries are stored.
- private static String getNativeLibraryDir(Context context) {
- ApplicationInfo appInfo = context.getApplicationInfo();
- return appInfo.nativeLibraryDir;
- }
-
- /*
- * Write the inputstream contents to the file
- */
- private static boolean streamToFile(InputStream stm, File outFile, boolean append, boolean zip) throws IOException {
- byte[] buffer = new byte[1024];
-
- int bytecount;
-
- OutputStream stmOut = new FileOutputStream(outFile.getAbsolutePath(), append);
- ZipInputStream zis = null;
-
- if (zip) {
- zis = new ZipInputStream(stm);
- ZipEntry ze = zis.getNextEntry();
- stm = zis;
-
- }
-
- while ((bytecount = stm.read(buffer)) > 0) {
-
- stmOut.write(buffer, 0, bytecount);
-
- }
-
- stmOut.close();
- stm.close();
-
- if (zis != null)
- zis.close();
-
-
- return true;
-
- }
-
-
-
-
- /*
- * Extract the Tor binary from the APK file using ZIP
- */
-
- private static File[] listf(String directoryName) {
-
- // .............list file
- File directory = new File(directoryName);
-
- // get all the files from a directory
- File[] fList = directory.listFiles();
-
- if (fList != null)
- for (File file : fList) {
- if (file.isFile()) {
- Log.d(TAG, file.getAbsolutePath());
- } else if (file.isDirectory()) {
- listf(file.getAbsolutePath());
- }
- }
-
- return fList;
- }
-
- /*
- * Extract the Tor resources from the APK file using ZIP
- */
- public void installGeoIP() throws IOException {
- if (!installFolder.exists())
- installFolder.mkdirs();
- assetToFile(TorServiceConstants.GEOIP_ASSET_KEY, TorServiceConstants.GEOIP_ASSET_KEY, false, false);
- assetToFile(TorServiceConstants.GEOIP6_ASSET_KEY, TorServiceConstants.GEOIP6_ASSET_KEY, false, false);
- }
-
- /*
- * Reads file from assetPath/assetKey writes it to the install folder
- */
- private File assetToFile(String assetPath, String assetKey, boolean isZipped, boolean isExecutable) throws IOException {
- InputStream is = context.getAssets().open(assetPath);
- File outFile = new File(installFolder, assetKey);
- streamToFile(is, outFile, false, isZipped);
- if (isExecutable) {
- setExecutable(outFile);
- }
- return outFile;
- }
-
- private void setExecutable(File fileBin) {
- fileBin.setReadable(true);
- fileBin.setExecutable(true);
- fileBin.setWritable(false);
- fileBin.setWritable(true, true);
- }
-}
-
+package org.orbotproject.android.service.util;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.util.Log;
+
+import org.orbotproject.android.service.TorServiceConstants;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+public class CustomTorResourceInstaller {
+
+ private static final String TAG = "CustomTorResourceInstaller";
+
+ private File installFolder;
+ private Context context;
+
+ public CustomTorResourceInstaller(Context context, File installFolder) {
+ this.installFolder = installFolder;
+ this.context = context;
+ }
+
+ // Return Full path to the directory where native JNI libraries are stored.
+ private static String getNativeLibraryDir(Context context) {
+ ApplicationInfo appInfo = context.getApplicationInfo();
+ return appInfo.nativeLibraryDir;
+ }
+
+ /*
+ * Write the inputstream contents to the file
+ */
+ private static boolean streamToFile(InputStream stm, File outFile, boolean append, boolean zip) throws IOException {
+ byte[] buffer = new byte[1024];
+
+ int bytecount;
+
+ OutputStream stmOut = new FileOutputStream(outFile.getAbsolutePath(), append);
+ ZipInputStream zis = null;
+
+ if (zip) {
+ zis = new ZipInputStream(stm);
+ ZipEntry ze = zis.getNextEntry();
+ stm = zis;
+
+ }
+
+ while ((bytecount = stm.read(buffer)) > 0) {
+
+ stmOut.write(buffer, 0, bytecount);
+
+ }
+
+ stmOut.close();
+ stm.close();
+
+ if (zis != null)
+ zis.close();
+
+
+ return true;
+
+ }
+
+
+
+
+ /*
+ * Extract the Tor binary from the APK file using ZIP
+ */
+
+ private static File[] listf(String directoryName) {
+
+ // .............list file
+ File directory = new File(directoryName);
+
+ // get all the files from a directory
+ File[] fList = directory.listFiles();
+
+ if (fList != null)
+ for (File file : fList) {
+ if (file.isFile()) {
+ Log.d(TAG, file.getAbsolutePath());
+ } else if (file.isDirectory()) {
+ listf(file.getAbsolutePath());
+ }
+ }
+
+ return fList;
+ }
+
+ /*
+ * Extract the Tor resources from the APK file using ZIP
+ */
+ public void installGeoIP() throws IOException {
+ if (!installFolder.exists())
+ installFolder.mkdirs();
+ assetToFile(TorServiceConstants.GEOIP_ASSET_KEY, TorServiceConstants.GEOIP_ASSET_KEY, false, false);
+ assetToFile(TorServiceConstants.GEOIP6_ASSET_KEY, TorServiceConstants.GEOIP6_ASSET_KEY, false, false);
+ }
+
+ /*
+ * Reads file from assetPath/assetKey writes it to the install folder
+ */
+ private File assetToFile(String assetPath, String assetKey, boolean isZipped, boolean isExecutable) throws IOException {
+ InputStream is = context.getAssets().open(assetPath);
+ File outFile = new File(installFolder, assetKey);
+ streamToFile(is, outFile, false, isZipped);
+ if (isExecutable) {
+ setExecutable(outFile);
+ }
+ return outFile;
+ }
+
+ private void setExecutable(File fileBin) {
+ fileBin.setReadable(true);
+ fileBin.setExecutable(true);
+ fileBin.setWritable(false);
+ fileBin.setWritable(true, true);
+ }
+}
+
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/util/DummyActivity.java b/orbotmanager/src/main/java/org/orbotproject/android/service/util/DummyActivity.java
similarity index 81%
rename from orbotmanager/src/main/java/org/torproject/android/service/util/DummyActivity.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/util/DummyActivity.java
index c818c96f..424334d4 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/util/DummyActivity.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/util/DummyActivity.java
@@ -1,15 +1,15 @@
-package org.torproject.android.service.util;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-/*
- * To combat background service being stopped/swiped
- */
-public class DummyActivity extends Activity {
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- finish();
- }
+package org.orbotproject.android.service.util;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+/*
+ * To combat background service being stopped/swiped
+ */
+public class DummyActivity extends Activity {
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ finish();
+ }
}
\ No newline at end of file
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/util/ExternalIPFetcher.java b/orbotmanager/src/main/java/org/orbotproject/android/service/util/ExternalIPFetcher.java
similarity index 91%
rename from orbotmanager/src/main/java/org/torproject/android/service/util/ExternalIPFetcher.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/util/ExternalIPFetcher.java
index 957e1e65..1e277664 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/util/ExternalIPFetcher.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/util/ExternalIPFetcher.java
@@ -1,85 +1,85 @@
-package org.torproject.android.service.util;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.torproject.android.service.OrbotService;
-import org.torproject.android.service.TorEventHandler;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.InetSocketAddress;
-import java.net.Proxy;
-import java.net.URL;
-import java.net.URLConnection;
-
-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 OrbotService mService;
- private TorEventHandler.Node mNode;
- private int mLocalHttpProxyPort = 8118;
-
- public ExternalIPFetcher(OrbotService service, TorEventHandler.Node node, int localProxyPort) {
- mService = service;
- mNode = node;
- mLocalHttpProxyPort = localProxyPort;
- }
-
- public void run() {
- try {
-
- URLConnection conn;
-
- Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", mLocalHttpProxyPort));
- conn = new URL(ONIONOO_BASE_URL + mNode.id).openConnection(proxy);
-
- conn.setRequestProperty("Connection", "Close");
- conn.setConnectTimeout(60000);
- conn.setReadTimeout(60000);
-
- InputStream is = conn.getInputStream();
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
-
- // getting JSON string from URL
-
- StringBuffer json = new StringBuffer();
- String line;
-
- while ((line = reader.readLine()) != null)
- json.append(line);
-
- JSONObject jsonNodeInfo = new org.json.JSONObject(json.toString());
-
- JSONArray jsonRelays = jsonNodeInfo.getJSONArray("relays");
-
- if (jsonRelays.length() > 0) {
- mNode.ipAddress = jsonRelays.getJSONObject(0).getJSONArray("or_addresses").getString(0).split(":")[0];
- mNode.country = jsonRelays.getJSONObject(0).getString("country_name");
- mNode.organization = jsonRelays.getJSONObject(0).getString("as_name");
-
- StringBuffer sbInfo = new StringBuffer();
- sbInfo.append(mNode.name).append("(");
- sbInfo.append(mNode.ipAddress).append(")");
-
- if (mNode.country != null)
- sbInfo.append(' ').append(mNode.country);
-
- if (mNode.organization != null)
- sbInfo.append(" (").append(mNode.organization).append(')');
-
- mService.debug(sbInfo.toString());
-
- }
-
- reader.close();
- is.close();
-
-
- } catch (Exception e) {
-
- // mService.debug ("Error getting node details from onionoo: " + e.getMessage());
- }
- }
-}
+package org.orbotproject.android.service.util;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.orbotproject.android.service.OrbotService;
+import org.orbotproject.android.service.TorEventHandler;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.net.URL;
+import java.net.URLConnection;
+
+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 OrbotService mService;
+ private TorEventHandler.Node mNode;
+ private int mLocalHttpProxyPort = 8118;
+
+ public ExternalIPFetcher(OrbotService service, TorEventHandler.Node node, int localProxyPort) {
+ mService = service;
+ mNode = node;
+ mLocalHttpProxyPort = localProxyPort;
+ }
+
+ public void run() {
+ try {
+
+ URLConnection conn;
+
+ Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", mLocalHttpProxyPort));
+ conn = new URL(ONIONOO_BASE_URL + mNode.id).openConnection(proxy);
+
+ conn.setRequestProperty("Connection", "Close");
+ conn.setConnectTimeout(60000);
+ conn.setReadTimeout(60000);
+
+ InputStream is = conn.getInputStream();
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+
+ // getting JSON string from URL
+
+ StringBuffer json = new StringBuffer();
+ String line;
+
+ while ((line = reader.readLine()) != null)
+ json.append(line);
+
+ JSONObject jsonNodeInfo = new org.json.JSONObject(json.toString());
+
+ JSONArray jsonRelays = jsonNodeInfo.getJSONArray("relays");
+
+ if (jsonRelays.length() > 0) {
+ mNode.ipAddress = jsonRelays.getJSONObject(0).getJSONArray("or_addresses").getString(0).split(":")[0];
+ mNode.country = jsonRelays.getJSONObject(0).getString("country_name");
+ mNode.organization = jsonRelays.getJSONObject(0).getString("as_name");
+
+ StringBuffer sbInfo = new StringBuffer();
+ sbInfo.append(mNode.name).append("(");
+ sbInfo.append(mNode.ipAddress).append(")");
+
+ if (mNode.country != null)
+ sbInfo.append(' ').append(mNode.country);
+
+ if (mNode.organization != null)
+ sbInfo.append(" (").append(mNode.organization).append(')');
+
+ mService.debug(sbInfo.toString());
+
+ }
+
+ reader.close();
+ is.close();
+
+
+ } catch (Exception e) {
+
+ // mService.debug ("Error getting node details from onionoo: " + e.getMessage());
+ }
+ }
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/util/NativeLoader.java b/orbotmanager/src/main/java/org/orbotproject/android/service/util/NativeLoader.java
similarity index 95%
rename from orbotmanager/src/main/java/org/torproject/android/service/util/NativeLoader.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/util/NativeLoader.java
index c870025a..88c96423 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/util/NativeLoader.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/util/NativeLoader.java
@@ -1,98 +1,98 @@
-package org.torproject.android.service.util;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.os.Build;
-import android.util.Log;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-public class NativeLoader {
-
- private final static String TAG = "TorNativeLoader";
-
- @SuppressLint("SetWorldReadable")
- private static boolean loadFromZip(Context context, String libName, File destLocalFile, String folder) {
-
-
- ZipFile zipFile = null;
- InputStream stream = null;
- try {
- zipFile = new ZipFile(context.getApplicationInfo().sourceDir);
-
- /**
- Enumeration extends ZipEntry> entries = zipFile.entries();
- while (entries.hasMoreElements())
- {
- ZipEntry entry = entries.nextElement();
- Log.d("Zip","entry: " + entry.getName());
- }
- **/
-
- ZipEntry entry = zipFile.getEntry("lib/" + folder + "/" + libName + ".so");
- if (entry == null) {
- entry = zipFile.getEntry("lib/" + folder + "/" + libName);
- if (entry == null)
- throw new Exception("Unable to find file in apk:" + "lib/" + folder + "/" + libName);
- }
- stream = zipFile.getInputStream(entry);
-
- OutputStream out = new FileOutputStream(destLocalFile);
- byte[] buf = new byte[4096];
- int len;
- while ((len = stream.read(buf)) > 0) {
- Thread.yield();
- out.write(buf, 0, len);
- }
- out.close();
-
- destLocalFile.setReadable(true, false);
- destLocalFile.setExecutable(true, false);
- destLocalFile.setWritable(true);
-
- return true;
- } catch (Exception e) {
- Log.e(TAG, e.getMessage());
- } finally {
- if (stream != null) {
- try {
- stream.close();
- } catch (Exception e) {
- Log.e(TAG, e.getMessage());
- }
- }
- if (zipFile != null) {
- try {
- zipFile.close();
- } catch (Exception e) {
- Log.e(TAG, e.getMessage());
- }
- }
- }
- return false;
- }
-
- public static synchronized boolean initNativeLibs(Context context, String binaryName, File destLocalFile) {
-
- try {
- String folder = Build.CPU_ABI;
-
- String javaArch = System.getProperty("os.arch");
- if (javaArch != null && javaArch.contains("686")) {
- folder = "x86";
- }
-
- return loadFromZip(context, binaryName, destLocalFile, folder);
-
- } catch (Throwable e) {
- e.printStackTrace();
- }
-
- return false;
- }
-}
+package org.orbotproject.android.service.util;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.os.Build;
+import android.util.Log;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+public class NativeLoader {
+
+ private final static String TAG = "TorNativeLoader";
+
+ @SuppressLint("SetWorldReadable")
+ private static boolean loadFromZip(Context context, String libName, File destLocalFile, String folder) {
+
+
+ ZipFile zipFile = null;
+ InputStream stream = null;
+ try {
+ zipFile = new ZipFile(context.getApplicationInfo().sourceDir);
+
+ /**
+ Enumeration extends ZipEntry> entries = zipFile.entries();
+ while (entries.hasMoreElements())
+ {
+ ZipEntry entry = entries.nextElement();
+ Log.d("Zip","entry: " + entry.getName());
+ }
+ **/
+
+ ZipEntry entry = zipFile.getEntry("lib/" + folder + "/" + libName + ".so");
+ if (entry == null) {
+ entry = zipFile.getEntry("lib/" + folder + "/" + libName);
+ if (entry == null)
+ throw new Exception("Unable to find file in apk:" + "lib/" + folder + "/" + libName);
+ }
+ stream = zipFile.getInputStream(entry);
+
+ OutputStream out = new FileOutputStream(destLocalFile);
+ byte[] buf = new byte[4096];
+ int len;
+ while ((len = stream.read(buf)) > 0) {
+ Thread.yield();
+ out.write(buf, 0, len);
+ }
+ out.close();
+
+ destLocalFile.setReadable(true, false);
+ destLocalFile.setExecutable(true, false);
+ destLocalFile.setWritable(true);
+
+ return true;
+ } catch (Exception e) {
+ Log.e(TAG, e.getMessage());
+ } finally {
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (Exception e) {
+ Log.e(TAG, e.getMessage());
+ }
+ }
+ if (zipFile != null) {
+ try {
+ zipFile.close();
+ } catch (Exception e) {
+ Log.e(TAG, e.getMessage());
+ }
+ }
+ }
+ return false;
+ }
+
+ public static synchronized boolean initNativeLibs(Context context, String binaryName, File destLocalFile) {
+
+ try {
+ String folder = Build.CPU_ABI;
+
+ String javaArch = System.getProperty("os.arch");
+ if (javaArch != null && javaArch.contains("686")) {
+ folder = "x86";
+ }
+
+ return loadFromZip(context, binaryName, destLocalFile, folder);
+
+ } catch (Throwable e) {
+ e.printStackTrace();
+ }
+
+ return false;
+ }
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/util/PortForwarder.java b/orbotmanager/src/main/java/org/orbotproject/android/service/util/PortForwarder.java
similarity index 95%
rename from orbotmanager/src/main/java/org/torproject/android/service/util/PortForwarder.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/util/PortForwarder.java
index 26c3a3ff..6779748b 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/util/PortForwarder.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/util/PortForwarder.java
@@ -1,77 +1,77 @@
-package org.torproject.android.service.util;
-
-import android.util.Log;
-
-import com.offbynull.portmapper.PortMapperFactory;
-import com.offbynull.portmapper.gateway.Bus;
-import com.offbynull.portmapper.gateway.Gateway;
-import com.offbynull.portmapper.gateways.network.NetworkGateway;
-import com.offbynull.portmapper.gateways.network.internalmessages.KillNetworkRequest;
-import com.offbynull.portmapper.gateways.process.ProcessGateway;
-import com.offbynull.portmapper.gateways.process.internalmessages.KillProcessRequest;
-import com.offbynull.portmapper.mapper.MappedPort;
-import com.offbynull.portmapper.mapper.PortMapper;
-import com.offbynull.portmapper.mapper.PortType;
-
-import java.util.List;
-
-public class PortForwarder {
-
- private boolean shutdown = false;
- private Thread mThread = null;
-
- public void shutdown() {
- shutdown = true;
- }
-
- public void forward(final int internalPort, final int externalPort, final long lifetime) throws InterruptedException {
-
- mThread = new Thread() {
- public void run() {
- try {
- forwardSync(internalPort, externalPort, lifetime);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- };
-
- mThread.start();
- }
-
-
- public void forwardSync(int internalPort, int externalPort, long lifetime) throws InterruptedException {
- // Start gateways
- Gateway network = NetworkGateway.create();
- Gateway process = ProcessGateway.create();
- Bus networkBus = network.getBus();
- Bus processBus = process.getBus();
-
-// Discover port forwarding devices and take the first one found
- List mappers = PortMapperFactory.discover(networkBus, processBus);
- PortMapper mapper = mappers.get(0);
-
-// Map internal port 12345 to some external port (55555 preferred)
-//
-// IMPORTANT NOTE: Many devices prevent you from mapping ports that are <= 1024
-// (both internal and external ports). Be mindful of this when choosing which
-// ports you want to map.
- MappedPort mappedPort = mapper.mapPort(PortType.TCP, internalPort, externalPort, lifetime);
- Log.d(getClass().getName(), "Port mapping added: " + mappedPort);
-
-// Refresh mapping half-way through the lifetime of the mapping (for example,
-// if the mapping is available for 40 seconds, refresh it every 20 seconds)
- while (!shutdown) {
- mappedPort = mapper.refreshPort(mappedPort, mappedPort.getLifetime() / 2L);
- Log.d(getClass().getName(), "Port mapping refreshed: " + mappedPort);
- Thread.sleep(mappedPort.getLifetime() * 1000L);
- }
-
-// Unmap port 12345
- mapper.unmapPort(mappedPort);
-
-// Stop gateways
- networkBus.send(new KillNetworkRequest());
- processBus.send(new KillProcessRequest()); // can kill this after discovery
- }
-}
+package org.orbotproject.android.service.util;
+
+import android.util.Log;
+
+import com.offbynull.portmapper.PortMapperFactory;
+import com.offbynull.portmapper.gateway.Bus;
+import com.offbynull.portmapper.gateway.Gateway;
+import com.offbynull.portmapper.gateways.network.NetworkGateway;
+import com.offbynull.portmapper.gateways.network.internalmessages.KillNetworkRequest;
+import com.offbynull.portmapper.gateways.process.ProcessGateway;
+import com.offbynull.portmapper.gateways.process.internalmessages.KillProcessRequest;
+import com.offbynull.portmapper.mapper.MappedPort;
+import com.offbynull.portmapper.mapper.PortMapper;
+import com.offbynull.portmapper.mapper.PortType;
+
+import java.util.List;
+
+public class PortForwarder {
+
+ private boolean shutdown = false;
+ private Thread mThread = null;
+
+ public void shutdown() {
+ shutdown = true;
+ }
+
+ public void forward(final int internalPort, final int externalPort, final long lifetime) throws InterruptedException {
+
+ mThread = new Thread() {
+ public void run() {
+ try {
+ forwardSync(internalPort, externalPort, lifetime);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ mThread.start();
+ }
+
+
+ public void forwardSync(int internalPort, int externalPort, long lifetime) throws InterruptedException {
+ // Start gateways
+ Gateway network = NetworkGateway.create();
+ Gateway process = ProcessGateway.create();
+ Bus networkBus = network.getBus();
+ Bus processBus = process.getBus();
+
+// Discover port forwarding devices and take the first one found
+ List mappers = PortMapperFactory.discover(networkBus, processBus);
+ PortMapper mapper = mappers.get(0);
+
+// Map internal port 12345 to some external port (55555 preferred)
+//
+// IMPORTANT NOTE: Many devices prevent you from mapping ports that are <= 1024
+// (both internal and external ports). Be mindful of this when choosing which
+// ports you want to map.
+ MappedPort mappedPort = mapper.mapPort(PortType.TCP, internalPort, externalPort, lifetime);
+ Log.d(getClass().getName(), "Port mapping added: " + mappedPort);
+
+// Refresh mapping half-way through the lifetime of the mapping (for example,
+// if the mapping is available for 40 seconds, refresh it every 20 seconds)
+ while (!shutdown) {
+ mappedPort = mapper.refreshPort(mappedPort, mappedPort.getLifetime() / 2L);
+ Log.d(getClass().getName(), "Port mapping refreshed: " + mappedPort);
+ Thread.sleep(mappedPort.getLifetime() * 1000L);
+ }
+
+// Unmap port 12345
+ mapper.unmapPort(mappedPort);
+
+// Stop gateways
+ networkBus.send(new KillNetworkRequest());
+ processBus.send(new KillProcessRequest()); // can kill this after discovery
+ }
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/util/Prefs.java b/orbotmanager/src/main/java/org/orbotproject/android/service/util/Prefs.java
similarity index 95%
rename from orbotmanager/src/main/java/org/torproject/android/service/util/Prefs.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/util/Prefs.java
index 6c60fa83..025ca04a 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/util/Prefs.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/util/Prefs.java
@@ -1,167 +1,167 @@
-package org.torproject.android.service.util;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-
-import org.torproject.android.service.OrbotConstants;
-
-import java.util.Locale;
-
-public class Prefs {
-
- private final static String PREF_BRIDGES_ENABLED = "pref_bridges_enabled";
- private final static String PREF_BRIDGES_LIST = "pref_bridges_list";
- private final static String PREF_DEFAULT_LOCALE = "pref_default_locale";
- private final static String PREF_ENABLE_LOGGING = "pref_enable_logging";
- private final static String PREF_EXPANDED_NOTIFICATIONS = "pref_expanded_notifications";
- private final static String PREF_PERSIST_NOTIFICATIONS = "pref_persistent_notifications";
- private final static String PREF_START_ON_BOOT = "pref_start_boot";
- private final static String PREF_ALLOW_BACKGROUND_STARTS = "pref_allow_background_starts";
- private final static String PREF_OPEN_PROXY_ON_ALL_INTERFACES = "pref_open_proxy_on_all_interfaces";
- private final static String PREF_USE_VPN = "pref_vpn";
- 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_LIMIT = "pref_be_a_snowflake_limit";
-
- private final static String PREF_HOST_ONION_SERVICES = "pref_host_onionservices";
-
-
- private static SharedPreferences prefs;
-
- public static void setContext(Context context) {
- if (prefs == null)
- prefs = getSharedPrefs(context);
- }
-
- private static void putBoolean(String key, boolean value) {
- prefs.edit().putBoolean(key, value).apply();
- }
-
- private static void putString(String key, String value) {
- prefs.edit().putString(key, value).apply();
- }
-
- public static boolean hostOnionServicesEnabled () {
- if(prefs == null){
- return false;
- }
- return prefs.getBoolean(PREF_HOST_ONION_SERVICES, true);
- }
-
- public static void putHostOnionServicesEnabled(boolean value) {
- putBoolean(PREF_HOST_ONION_SERVICES, value);
- }
-
- public static boolean bridgesEnabled() {
- if(prefs == null){
- return false;
- }
- //if phone is in Farsi, enable bridges by default
- boolean bridgesEnabledDefault = Locale.getDefault().getLanguage().equals("fa");
- return prefs.getBoolean(PREF_BRIDGES_ENABLED, bridgesEnabledDefault);
- }
-
- public static void putBridgesEnabled(boolean value) {
- putBoolean(PREF_BRIDGES_ENABLED, value);
- }
-
- public static String getBridgesList() {
- String defaultBridgeType = "obfs4";
- if (Locale.getDefault().getLanguage().equals("fa"))
- defaultBridgeType = "meek"; //if Farsi, use meek as the default bridge type
- return prefs.getString(PREF_BRIDGES_LIST, defaultBridgeType);
- }
-
- public static void setBridgesList(String value) {
- putString(PREF_BRIDGES_LIST, value);
- }
-
- public static String getDefaultLocale() {
- return prefs.getString(PREF_DEFAULT_LOCALE, Locale.getDefault().getLanguage());
- }
-
- public static boolean beSnowflakeProxy () {
- if(prefs == null){
- return false;
- }
- return prefs.getBoolean(PREF_BE_A_SNOWFLAKE,false);
- }
-
- public static void setBeSnowflakeProxy (boolean beSnowflakeProxy) {
- putBoolean(PREF_BE_A_SNOWFLAKE,beSnowflakeProxy);
- }
-
- public static boolean limitSnowflakeProxying () {
- if(prefs == null){
- return false;
- }
- return prefs.getBoolean(PREF_BE_A_SNOWFLAKE_LIMIT,true);
- }
-
- public static void setDefaultLocale(String value) {
- putString(PREF_DEFAULT_LOCALE, value);
- }
-
- public static boolean expandedNotifications() {
- if(prefs == null){
- return false;
- }
- return prefs.getBoolean(PREF_EXPANDED_NOTIFICATIONS, true);
- }
-
- public static boolean useDebugLogging() {
- return false;
- }
-
- public static boolean persistNotifications() {
- if(prefs == null){
- return false;
- }
- return prefs.getBoolean(PREF_PERSIST_NOTIFICATIONS, true);
- }
-
- public static boolean allowBackgroundStarts() {
- if(prefs == null){
- return false;
- }
- return prefs.getBoolean(PREF_ALLOW_BACKGROUND_STARTS, true);
- }
-
- public static boolean openProxyOnAllInterfaces() {
- if(prefs == null){
- return false;
- }
- return prefs.getBoolean(PREF_OPEN_PROXY_ON_ALL_INTERFACES, false);
- }
-
- public static boolean useVpn() {
- return false;
- }
-
- public static void putUseVpn(boolean value) {
- putBoolean(PREF_USE_VPN, value);
- }
-
- public static boolean startOnBoot() {
- if(prefs == null){
- return false;
- }
- return prefs.getBoolean(PREF_START_ON_BOOT, true);
- }
-
- public static void putStartOnBoot(boolean value) {
- putBoolean(PREF_START_ON_BOOT, value);
- }
-
- public static String getExitNodes() {
- return prefs.getString(PREF_EXIT_NODES, "");
- }
-
- public static void setExitNodes(String exits) {
- putString(PREF_EXIT_NODES, exits);
- }
-
- public static SharedPreferences getSharedPrefs(Context context) {
- return context.getSharedPreferences(OrbotConstants.PREF_TOR_SHARED_PREFS, Context.MODE_MULTI_PROCESS);
- }
-}
+package org.orbotproject.android.service.util;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+
+import org.orbotproject.android.service.OrbotConstants;
+
+import java.util.Locale;
+
+public class Prefs {
+
+ private final static String PREF_BRIDGES_ENABLED = "pref_bridges_enabled";
+ private final static String PREF_BRIDGES_LIST = "pref_bridges_list";
+ private final static String PREF_DEFAULT_LOCALE = "pref_default_locale";
+ private final static String PREF_ENABLE_LOGGING = "pref_enable_logging";
+ private final static String PREF_EXPANDED_NOTIFICATIONS = "pref_expanded_notifications";
+ private final static String PREF_PERSIST_NOTIFICATIONS = "pref_persistent_notifications";
+ private final static String PREF_START_ON_BOOT = "pref_start_boot";
+ private final static String PREF_ALLOW_BACKGROUND_STARTS = "pref_allow_background_starts";
+ private final static String PREF_OPEN_PROXY_ON_ALL_INTERFACES = "pref_open_proxy_on_all_interfaces";
+ private final static String PREF_USE_VPN = "pref_vpn";
+ 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_LIMIT = "pref_be_a_snowflake_limit";
+
+ private final static String PREF_HOST_ONION_SERVICES = "pref_host_onionservices";
+
+
+ private static SharedPreferences prefs;
+
+ public static void setContext(Context context) {
+ if (prefs == null)
+ prefs = getSharedPrefs(context);
+ }
+
+ private static void putBoolean(String key, boolean value) {
+ prefs.edit().putBoolean(key, value).apply();
+ }
+
+ private static void putString(String key, String value) {
+ prefs.edit().putString(key, value).apply();
+ }
+
+ public static boolean hostOnionServicesEnabled () {
+ if(prefs == null){
+ return false;
+ }
+ return prefs.getBoolean(PREF_HOST_ONION_SERVICES, true);
+ }
+
+ public static void putHostOnionServicesEnabled(boolean value) {
+ putBoolean(PREF_HOST_ONION_SERVICES, value);
+ }
+
+ public static boolean bridgesEnabled() {
+ if(prefs == null){
+ return false;
+ }
+ //if phone is in Farsi, enable bridges by default
+ boolean bridgesEnabledDefault = Locale.getDefault().getLanguage().equals("fa");
+ return prefs.getBoolean(PREF_BRIDGES_ENABLED, bridgesEnabledDefault);
+ }
+
+ public static void putBridgesEnabled(boolean value) {
+ putBoolean(PREF_BRIDGES_ENABLED, value);
+ }
+
+ public static String getBridgesList() {
+ String defaultBridgeType = "obfs4";
+ if (Locale.getDefault().getLanguage().equals("fa"))
+ defaultBridgeType = "meek"; //if Farsi, use meek as the default bridge type
+ return prefs.getString(PREF_BRIDGES_LIST, defaultBridgeType);
+ }
+
+ public static void setBridgesList(String value) {
+ putString(PREF_BRIDGES_LIST, value);
+ }
+
+ public static String getDefaultLocale() {
+ return prefs.getString(PREF_DEFAULT_LOCALE, Locale.getDefault().getLanguage());
+ }
+
+ public static boolean beSnowflakeProxy () {
+ if(prefs == null){
+ return false;
+ }
+ return prefs.getBoolean(PREF_BE_A_SNOWFLAKE,false);
+ }
+
+ public static void setBeSnowflakeProxy (boolean beSnowflakeProxy) {
+ putBoolean(PREF_BE_A_SNOWFLAKE,beSnowflakeProxy);
+ }
+
+ public static boolean limitSnowflakeProxying () {
+ if(prefs == null){
+ return false;
+ }
+ return prefs.getBoolean(PREF_BE_A_SNOWFLAKE_LIMIT,true);
+ }
+
+ public static void setDefaultLocale(String value) {
+ putString(PREF_DEFAULT_LOCALE, value);
+ }
+
+ public static boolean expandedNotifications() {
+ if(prefs == null){
+ return false;
+ }
+ return prefs.getBoolean(PREF_EXPANDED_NOTIFICATIONS, true);
+ }
+
+ public static boolean useDebugLogging() {
+ return false;
+ }
+
+ public static boolean persistNotifications() {
+ if(prefs == null){
+ return false;
+ }
+ return prefs.getBoolean(PREF_PERSIST_NOTIFICATIONS, true);
+ }
+
+ public static boolean allowBackgroundStarts() {
+ if(prefs == null){
+ return false;
+ }
+ return prefs.getBoolean(PREF_ALLOW_BACKGROUND_STARTS, true);
+ }
+
+ public static boolean openProxyOnAllInterfaces() {
+ if(prefs == null){
+ return false;
+ }
+ return prefs.getBoolean(PREF_OPEN_PROXY_ON_ALL_INTERFACES, false);
+ }
+
+ public static boolean useVpn() {
+ return false;
+ }
+
+ public static void putUseVpn(boolean value) {
+ putBoolean(PREF_USE_VPN, value);
+ }
+
+ public static boolean startOnBoot() {
+ if(prefs == null){
+ return false;
+ }
+ return prefs.getBoolean(PREF_START_ON_BOOT, true);
+ }
+
+ public static void putStartOnBoot(boolean value) {
+ putBoolean(PREF_START_ON_BOOT, value);
+ }
+
+ public static String getExitNodes() {
+ return prefs.getString(PREF_EXIT_NODES, "");
+ }
+
+ public static void setExitNodes(String exits) {
+ putString(PREF_EXIT_NODES, exits);
+ }
+
+ public static SharedPreferences getSharedPrefs(Context context) {
+ return context.getSharedPreferences(OrbotConstants.PREF_TOR_SHARED_PREFS, Context.MODE_MULTI_PROCESS);
+ }
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/util/TCPSourceApp.java b/orbotmanager/src/main/java/org/orbotproject/android/service/util/TCPSourceApp.java
similarity index 97%
rename from orbotmanager/src/main/java/org/torproject/android/service/util/TCPSourceApp.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/util/TCPSourceApp.java
index cb61a9c7..4d34cfda 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/util/TCPSourceApp.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/util/TCPSourceApp.java
@@ -1,307 +1,307 @@
-package org.torproject.android.service.util;
-
-/***********************************************************************
- *
- * Copyright (c) 2013, Sebastiano Gottardo
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the MegaDevs nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL SEBASTIANO GOTTARDO BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.Inet4Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.util.Collections;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Main class for the TCPSourceApp library.
- *
- * @author Sebastiano Gottardo
- */
-public class TCPSourceApp {
-
- /*
- * In a Linux-based OS, each active TCP socket is mapped in the following
- * two files. A socket may be mapped in the '/proc/net/tcp' file in case
- * of a simple IPv4 address, or in the '/proc/net/tcp6' if an IPv6 address
- * is available.
- */
- private static final String TCP_4_FILE_PATH = "/proc/net/tcp";
- private static final String TCP_6_FILE_PATH = "/proc/net/tcp6";
- /*
- * Two regular expressions that are able to extract valuable informations
- * from the two /proc/net/tcp* files. More specifically, there are three
- * fields that are extracted:
- * - address
- * - port
- * - PID
- */
- private static final String TCP_6_PATTERN = "\\d+:\\s([0-9A-F]{32}):([0-9A-F]{4})\\s[0-9A-F]{32}:[0-9A-F]{4}\\s[0-9A-F]{2}\\s[0-9]{8}:[0-9]{8}\\s[0-9]{2}:[0-9]{8}\\s[0-9]{8}\\s+([0-9]+)";
- private static final String TCP_4_PATTERN = "\\d+:\\s([0-9A-F]{8}):([0-9A-F]{4})\\s[0-9A-F]{8}:[0-9A-F]{4}\\s[0-9A-F]{2}\\s[0-9A-F]{8}:[0-9A-F]{8}\\s[0-9]{2}:[0-9]{8}\\s[0-9A-F]{8}\\s+([0-9]+)";
-//sargo:/ $ cat /proc/net/tcp6
-// sl local_address remote_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
-// 0: 00000000000000000000000000000000:C36A 00000000000000000000000000000000:0000 8A 00000000:00000000 00:00000000 00000000 1001 0 35059 1 0000000000000000 99 0 0 10 0
-// 1: 00000000000000000000000000000000:A64B 00000000000000000000000000000000:0000 8A 00000000:00000000 00:00000000 00000000 1001 0 910009 1 0000000000000000 99 0 0 10 0
- /*
- * Optimises the socket lookup by checking if the connected network
- * interface has a 'valid' IPv6 address (a global address, not a link-local
- * one).
- */
- private static boolean checkConnectedIfaces = true;
-// sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
-// 0: 00000000:C368 00000000:0000 8A 00000000:00000000 00:00000000 00000000 1001 0 34999 1 0000000000000000 99 0 0 10 0
-
- /**
- * The main method of the TCPSourceApp library. This method receives an
- * Android Context instance, which is used to access the PackageManager.
- * It parses the /proc/net/tcp* files, looking for a socket entry that
- * matches the given port. If it finds an entry, this method extracts the
- * PID value and it uses the PackageManager.getPackagesFromPid() method to
- * find the originating application.
- *
- * @param context a valid Android Context instance
- * @param daddr the (logical) address of the destination
- * @param dport the (logical) port of the destination
- * @return an AppDescriptor object, representing the found application; null
- * if no application could be found
- */
- public static AppDescriptor getApplicationInfo(Context context, String saddr, int sport, String daddr, int dport) {
-
- File tcp;
- BufferedReader reader;
- String line;
- StringBuilder builder;
- String content;
-
- try {
- boolean hasIPv6 = true;
-
- // if true, checks for a connected network interface with a valid
- // IPv4 / IPv6 address
- if (checkConnectedIfaces) {
- String ipv4Address = getIPAddress(true);
- String ipv6Address = getIPAddress(false);
-
- hasIPv6 = (ipv6Address.length() > 0);
- }
-
- tcp = new File(TCP_6_FILE_PATH);
- reader = new BufferedReader(new FileReader(tcp));
- builder = new StringBuilder();
-
- while ((line = reader.readLine()) != null) {
- builder.append(line);
- }
-
- content = builder.toString();
-
- Matcher m6 = Pattern.compile(TCP_6_PATTERN, Pattern.CASE_INSENSITIVE | Pattern.UNIX_LINES | Pattern.DOTALL).matcher(content);
-
- if (hasIPv6)
- while (m6.find()) {
- String addressEntry = m6.group(1);
- String portEntry = m6.group(2);
- int pidEntry = Integer.valueOf(m6.group(3));
-
- if (Integer.parseInt(portEntry, 16) == dport) {
- PackageManager manager = context.getPackageManager();
- String[] packagesForUid = manager.getPackagesForUid(pidEntry);
-
- if (packagesForUid != null) {
- String packageName = packagesForUid[0];
- PackageInfo pInfo = manager.getPackageInfo(packageName, 0);
- String version = pInfo.versionName;
-
- return new AppDescriptor(pidEntry, packageName, version);
- }
- }
- }
-
- } catch (SocketException e) {
- e.printStackTrace();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (NameNotFoundException e) {
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- // From here, no connection with the given port could be found in the tcp6 file
- // So let's try the tcp (IPv4) one
-
- try {
- tcp = new File(TCP_4_FILE_PATH);
- reader = new BufferedReader(new FileReader(tcp));
- builder = new StringBuilder();
-
- while ((line = reader.readLine()) != null) {
- builder.append(line);
- }
-
- content = builder.toString();
-
- Matcher m4 = Pattern.compile(TCP_4_PATTERN, Pattern.CASE_INSENSITIVE | Pattern.UNIX_LINES | Pattern.DOTALL).matcher(content);
-
- while (m4.find()) {
- String addressEntry = m4.group(1);
- String portEntry = m4.group(2);
- int pidEntry = Integer.valueOf(m4.group(3));
-
- if (Integer.parseInt(portEntry, 16) == dport) {
- PackageManager manager = context.getPackageManager();
- String[] packagesForUid = manager.getPackagesForUid(pidEntry);
-
- if (packagesForUid != null) {
- String packageName = packagesForUid[0];
- PackageInfo pInfo = manager.getPackageInfo(packageName, 0);
- String version = pInfo.versionName;
-
- return new AppDescriptor(pidEntry, packageName, version);
- }
- }
- }
-
- } catch (SocketException e) {
- e.printStackTrace();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (NameNotFoundException e) {
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return null;
- }
-
- @SuppressLint("DefaultLocale")
- public static String getIPAddress(boolean useIPv4) throws SocketException {
-
- List interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
-
- for (NetworkInterface intf : interfaces) {
- List addrs = Collections.list(intf.getInetAddresses());
-
- for (InetAddress addr : addrs) {
- if (!addr.isLoopbackAddress()) {
- String sAddr = addr.getHostAddress().toUpperCase();
-
- boolean isIPv4 = addr instanceof Inet4Address;
-
- if (useIPv4) {
- if (isIPv4)
- return sAddr;
- } else {
- if (!isIPv4) {
- if (sAddr.startsWith("fe80") || sAddr.startsWith("FE80")) // skipping link-local addresses
- continue;
-
- int delim = sAddr.indexOf('%'); // drop ip6 port suffix
- return delim < 0 ? sAddr : sAddr.substring(0, delim);
- }
- }
- }
- }
- }
-
- return "";
- }
-
- /*
- * Sets the connected interfaces optimisation.
- */
- public static void setCheckConnectedIfaces(boolean value) {
- checkConnectedIfaces = value;
- }
-
- /*
- * This class represents an Android application. Each application is
- * uniquely identified by its package name (e.g. com.megadevs.tcpsourceapp)
- * and its version (e.g. 1.0).
- */
- public static class AppDescriptor {
-
- private String packageName;
- private String version;
- private int uid;
-
- public AppDescriptor(int uid, String pName, String ver) {
- this.uid = uid;
- packageName = pName;
- version = ver;
- }
-
- public int getUid() {
- return uid;
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public String getVersion() {
- return version;
- }
-
- /*
- * Override of the 'equals' method, in order to have a proper
- * comparison between two AppDescriptor objects.
- *
- * (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object o) {
-
- if (o instanceof AppDescriptor) {
- boolean c1 = ((AppDescriptor) o).packageName.compareTo(this.packageName) == 0;
- boolean c2 = ((AppDescriptor) o).version.compareTo(this.version) == 0;
-
- return c1 && c2;
- }
-
- return false;
- }
-
- }
-
+package org.orbotproject.android.service.util;
+
+/***********************************************************************
+ *
+ * Copyright (c) 2013, Sebastiano Gottardo
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the MegaDevs nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL SEBASTIANO GOTTARDO BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Main class for the TCPSourceApp library.
+ *
+ * @author Sebastiano Gottardo
+ */
+public class TCPSourceApp {
+
+ /*
+ * In a Linux-based OS, each active TCP socket is mapped in the following
+ * two files. A socket may be mapped in the '/proc/net/tcp' file in case
+ * of a simple IPv4 address, or in the '/proc/net/tcp6' if an IPv6 address
+ * is available.
+ */
+ private static final String TCP_4_FILE_PATH = "/proc/net/tcp";
+ private static final String TCP_6_FILE_PATH = "/proc/net/tcp6";
+ /*
+ * Two regular expressions that are able to extract valuable informations
+ * from the two /proc/net/tcp* files. More specifically, there are three
+ * fields that are extracted:
+ * - address
+ * - port
+ * - PID
+ */
+ private static final String TCP_6_PATTERN = "\\d+:\\s([0-9A-F]{32}):([0-9A-F]{4})\\s[0-9A-F]{32}:[0-9A-F]{4}\\s[0-9A-F]{2}\\s[0-9]{8}:[0-9]{8}\\s[0-9]{2}:[0-9]{8}\\s[0-9]{8}\\s+([0-9]+)";
+ private static final String TCP_4_PATTERN = "\\d+:\\s([0-9A-F]{8}):([0-9A-F]{4})\\s[0-9A-F]{8}:[0-9A-F]{4}\\s[0-9A-F]{2}\\s[0-9A-F]{8}:[0-9A-F]{8}\\s[0-9]{2}:[0-9]{8}\\s[0-9A-F]{8}\\s+([0-9]+)";
+//sargo:/ $ cat /proc/net/tcp6
+// sl local_address remote_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
+// 0: 00000000000000000000000000000000:C36A 00000000000000000000000000000000:0000 8A 00000000:00000000 00:00000000 00000000 1001 0 35059 1 0000000000000000 99 0 0 10 0
+// 1: 00000000000000000000000000000000:A64B 00000000000000000000000000000000:0000 8A 00000000:00000000 00:00000000 00000000 1001 0 910009 1 0000000000000000 99 0 0 10 0
+ /*
+ * Optimises the socket lookup by checking if the connected network
+ * interface has a 'valid' IPv6 address (a global address, not a link-local
+ * one).
+ */
+ private static boolean checkConnectedIfaces = true;
+// sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
+// 0: 00000000:C368 00000000:0000 8A 00000000:00000000 00:00000000 00000000 1001 0 34999 1 0000000000000000 99 0 0 10 0
+
+ /**
+ * The main method of the TCPSourceApp library. This method receives an
+ * Android Context instance, which is used to access the PackageManager.
+ * It parses the /proc/net/tcp* files, looking for a socket entry that
+ * matches the given port. If it finds an entry, this method extracts the
+ * PID value and it uses the PackageManager.getPackagesFromPid() method to
+ * find the originating application.
+ *
+ * @param context a valid Android Context instance
+ * @param daddr the (logical) address of the destination
+ * @param dport the (logical) port of the destination
+ * @return an AppDescriptor object, representing the found application; null
+ * if no application could be found
+ */
+ public static AppDescriptor getApplicationInfo(Context context, String saddr, int sport, String daddr, int dport) {
+
+ File tcp;
+ BufferedReader reader;
+ String line;
+ StringBuilder builder;
+ String content;
+
+ try {
+ boolean hasIPv6 = true;
+
+ // if true, checks for a connected network interface with a valid
+ // IPv4 / IPv6 address
+ if (checkConnectedIfaces) {
+ String ipv4Address = getIPAddress(true);
+ String ipv6Address = getIPAddress(false);
+
+ hasIPv6 = (ipv6Address.length() > 0);
+ }
+
+ tcp = new File(TCP_6_FILE_PATH);
+ reader = new BufferedReader(new FileReader(tcp));
+ builder = new StringBuilder();
+
+ while ((line = reader.readLine()) != null) {
+ builder.append(line);
+ }
+
+ content = builder.toString();
+
+ Matcher m6 = Pattern.compile(TCP_6_PATTERN, Pattern.CASE_INSENSITIVE | Pattern.UNIX_LINES | Pattern.DOTALL).matcher(content);
+
+ if (hasIPv6)
+ while (m6.find()) {
+ String addressEntry = m6.group(1);
+ String portEntry = m6.group(2);
+ int pidEntry = Integer.valueOf(m6.group(3));
+
+ if (Integer.parseInt(portEntry, 16) == dport) {
+ PackageManager manager = context.getPackageManager();
+ String[] packagesForUid = manager.getPackagesForUid(pidEntry);
+
+ if (packagesForUid != null) {
+ String packageName = packagesForUid[0];
+ PackageInfo pInfo = manager.getPackageInfo(packageName, 0);
+ String version = pInfo.versionName;
+
+ return new AppDescriptor(pidEntry, packageName, version);
+ }
+ }
+ }
+
+ } catch (SocketException e) {
+ e.printStackTrace();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (NameNotFoundException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ // From here, no connection with the given port could be found in the tcp6 file
+ // So let's try the tcp (IPv4) one
+
+ try {
+ tcp = new File(TCP_4_FILE_PATH);
+ reader = new BufferedReader(new FileReader(tcp));
+ builder = new StringBuilder();
+
+ while ((line = reader.readLine()) != null) {
+ builder.append(line);
+ }
+
+ content = builder.toString();
+
+ Matcher m4 = Pattern.compile(TCP_4_PATTERN, Pattern.CASE_INSENSITIVE | Pattern.UNIX_LINES | Pattern.DOTALL).matcher(content);
+
+ while (m4.find()) {
+ String addressEntry = m4.group(1);
+ String portEntry = m4.group(2);
+ int pidEntry = Integer.valueOf(m4.group(3));
+
+ if (Integer.parseInt(portEntry, 16) == dport) {
+ PackageManager manager = context.getPackageManager();
+ String[] packagesForUid = manager.getPackagesForUid(pidEntry);
+
+ if (packagesForUid != null) {
+ String packageName = packagesForUid[0];
+ PackageInfo pInfo = manager.getPackageInfo(packageName, 0);
+ String version = pInfo.versionName;
+
+ return new AppDescriptor(pidEntry, packageName, version);
+ }
+ }
+ }
+
+ } catch (SocketException e) {
+ e.printStackTrace();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (NameNotFoundException e) {
+ e.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ @SuppressLint("DefaultLocale")
+ public static String getIPAddress(boolean useIPv4) throws SocketException {
+
+ List interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
+
+ for (NetworkInterface intf : interfaces) {
+ List addrs = Collections.list(intf.getInetAddresses());
+
+ for (InetAddress addr : addrs) {
+ if (!addr.isLoopbackAddress()) {
+ String sAddr = addr.getHostAddress().toUpperCase();
+
+ boolean isIPv4 = addr instanceof Inet4Address;
+
+ if (useIPv4) {
+ if (isIPv4)
+ return sAddr;
+ } else {
+ if (!isIPv4) {
+ if (sAddr.startsWith("fe80") || sAddr.startsWith("FE80")) // skipping link-local addresses
+ continue;
+
+ int delim = sAddr.indexOf('%'); // drop ip6 port suffix
+ return delim < 0 ? sAddr : sAddr.substring(0, delim);
+ }
+ }
+ }
+ }
+ }
+
+ return "";
+ }
+
+ /*
+ * Sets the connected interfaces optimisation.
+ */
+ public static void setCheckConnectedIfaces(boolean value) {
+ checkConnectedIfaces = value;
+ }
+
+ /*
+ * This class represents an Android application. Each application is
+ * uniquely identified by its package name (e.g. com.megadevs.tcpsourceapp)
+ * and its version (e.g. 1.0).
+ */
+ public static class AppDescriptor {
+
+ private String packageName;
+ private String version;
+ private int uid;
+
+ public AppDescriptor(int uid, String pName, String ver) {
+ this.uid = uid;
+ packageName = pName;
+ version = ver;
+ }
+
+ public int getUid() {
+ return uid;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ /*
+ * Override of the 'equals' method, in order to have a proper
+ * comparison between two AppDescriptor objects.
+ *
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object o) {
+
+ if (o instanceof AppDescriptor) {
+ boolean c1 = ((AppDescriptor) o).packageName.compareTo(this.packageName) == 0;
+ boolean c2 = ((AppDescriptor) o).version.compareTo(this.version) == 0;
+
+ return c1 && c2;
+ }
+
+ return false;
+ }
+
+ }
+
}
\ No newline at end of file
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/util/TorServiceUtils.java b/orbotmanager/src/main/java/org/orbotproject/android/service/util/TorServiceUtils.java
similarity index 85%
rename from orbotmanager/src/main/java/org/torproject/android/service/util/TorServiceUtils.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/util/TorServiceUtils.java
index ebc829a0..cb9afd0e 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/util/TorServiceUtils.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/util/TorServiceUtils.java
@@ -1,27 +1,27 @@
-/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - http://openideals.com/guardian */
-/* See LICENSE for licensing information */
-package org.torproject.android.service.util;
-
-import org.torproject.android.service.TorServiceConstants;
-
-import java.net.ConnectException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-
-public class TorServiceUtils implements TorServiceConstants {
-
- public static boolean isPortOpen(final String ip, final int port, final int timeout) {
- try {
- Socket socket = new Socket();
- socket.connect(new InetSocketAddress(ip, port), timeout);
- socket.close();
- return true;
- } catch (ConnectException ce) {
- //ce.printStackTrace();
- return false;
- } catch (Exception ex) {
- //ex.printStackTrace();
- return false;
- }
- }
-}
+/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - http://openideals.com/guardian */
+/* See LICENSE for licensing information */
+package org.orbotproject.android.service.util;
+
+import org.orbotproject.android.service.TorServiceConstants;
+
+import java.net.ConnectException;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+
+public class TorServiceUtils implements TorServiceConstants {
+
+ public static boolean isPortOpen(final String ip, final int port, final int timeout) {
+ try {
+ Socket socket = new Socket();
+ socket.connect(new InetSocketAddress(ip, port), timeout);
+ socket.close();
+ return true;
+ } catch (ConnectException ce) {
+ //ce.printStackTrace();
+ return false;
+ } catch (Exception ex) {
+ //ex.printStackTrace();
+ return false;
+ }
+ }
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/util/Utils.java b/orbotmanager/src/main/java/org/orbotproject/android/service/util/Utils.java
similarity index 95%
rename from orbotmanager/src/main/java/org/torproject/android/service/util/Utils.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/util/Utils.java
index 2cb34389..eb53169d 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/util/Utils.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/util/Utils.java
@@ -1,183 +1,183 @@
-/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - http://openideals.com/guardian */
-/* See LICENSE for licensing information */
-
-
-package org.torproject.android.service.util;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-public class Utils {
-
-
- public static String readString(InputStream stream) {
- String line;
-
- StringBuffer out = new StringBuffer();
-
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
-
- while ((line = reader.readLine()) != null) {
- out.append(line);
- out.append('\n');
-
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return out.toString();
-
- }
-
- /*
- * Load the log file text
- */
- public static String loadTextFile(String path) {
- String line;
-
- StringBuffer out = new StringBuffer();
-
- try {
- BufferedReader reader = new BufferedReader((new FileReader(new File(path))));
-
- while ((line = reader.readLine()) != null) {
- out.append(line);
- out.append('\n');
-
- }
-
- reader.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return out.toString();
-
- }
-
-
- /*
- * Load the log file text
- */
- public static boolean saveTextFile(String path, String contents) {
-
- try {
-
- FileWriter writer = new FileWriter(path, false);
- writer.write(contents);
-
- writer.close();
-
-
- return true;
-
- } catch (IOException e) {
- // Log.d(TAG, "error writing file: " + path, e);
- e.printStackTrace();
- return false;
- }
-
-
- }
-
-
- /*
- *
- * Zips a file at a location and places the resulting zip file at the toLocation
- * Example: zipFileAtPath("downloads/myfolder", "downloads/myFolder.zip");
- */
-
- public static boolean zipFileAtPath(String sourcePath, String toLocation) {
- final int BUFFER = 2048;
-
- File sourceFile = new File(sourcePath);
- try {
- BufferedInputStream origin;
- FileOutputStream dest = new FileOutputStream(toLocation);
- ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(
- dest));
- if (sourceFile.isDirectory()) {
- zipSubFolder(out, sourceFile, sourceFile.getParent().length());
- } else {
- byte[] data = new byte[BUFFER];
- FileInputStream fi = new FileInputStream(sourcePath);
- origin = new BufferedInputStream(fi, BUFFER);
- ZipEntry entry = new ZipEntry(getLastPathComponent(sourcePath));
- entry.setTime(sourceFile.lastModified()); // to keep modification time after unzipping
- out.putNextEntry(entry);
- int count;
- while ((count = origin.read(data, 0, BUFFER)) != -1) {
- out.write(data, 0, count);
- }
- }
- out.close();
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- return true;
- }
-
- /*
- *
- * Zips a subfolder
- *
- */
-
- private static void zipSubFolder(ZipOutputStream out, File folder,
- int basePathLength) throws IOException {
-
- final int BUFFER = 2048;
-
- File[] fileList = folder.listFiles();
- BufferedInputStream origin;
- for (File file : fileList) {
- if (file.isDirectory()) {
- zipSubFolder(out, file, basePathLength);
- } else {
- byte[] data = new byte[BUFFER];
- String unmodifiedFilePath = file.getPath();
- String relativePath = unmodifiedFilePath
- .substring(basePathLength);
- FileInputStream fi = new FileInputStream(unmodifiedFilePath);
- origin = new BufferedInputStream(fi, BUFFER);
- ZipEntry entry = new ZipEntry(relativePath);
- entry.setTime(file.lastModified()); // to keep modification time after unzipping
- out.putNextEntry(entry);
- int count;
- while ((count = origin.read(data, 0, BUFFER)) != -1) {
- out.write(data, 0, count);
- }
- origin.close();
- }
- }
- }
-
- /*
- * gets the last path component
- *
- * Example: getLastPathComponent("downloads/example/fileToZip");
- * Result: "fileToZip"
- */
- public static String getLastPathComponent(String filePath) {
- String[] segments = filePath.split("/");
- if (segments.length == 0)
- return "";
- return segments[segments.length - 1];
- }
-}
+/* Copyright (c) 2009, Nathan Freitas, Orbot / The Guardian Project - http://openideals.com/guardian */
+/* See LICENSE for licensing information */
+
+
+package org.orbotproject.android.service.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class Utils {
+
+
+ public static String readString(InputStream stream) {
+ String line;
+
+ StringBuffer out = new StringBuffer();
+
+ try {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
+
+ while ((line = reader.readLine()) != null) {
+ out.append(line);
+ out.append('\n');
+
+ }
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return out.toString();
+
+ }
+
+ /*
+ * Load the log file text
+ */
+ public static String loadTextFile(String path) {
+ String line;
+
+ StringBuffer out = new StringBuffer();
+
+ try {
+ BufferedReader reader = new BufferedReader((new FileReader(new File(path))));
+
+ while ((line = reader.readLine()) != null) {
+ out.append(line);
+ out.append('\n');
+
+ }
+
+ reader.close();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return out.toString();
+
+ }
+
+
+ /*
+ * Load the log file text
+ */
+ public static boolean saveTextFile(String path, String contents) {
+
+ try {
+
+ FileWriter writer = new FileWriter(path, false);
+ writer.write(contents);
+
+ writer.close();
+
+
+ return true;
+
+ } catch (IOException e) {
+ // Log.d(TAG, "error writing file: " + path, e);
+ e.printStackTrace();
+ return false;
+ }
+
+
+ }
+
+
+ /*
+ *
+ * Zips a file at a location and places the resulting zip file at the toLocation
+ * Example: zipFileAtPath("downloads/myfolder", "downloads/myFolder.zip");
+ */
+
+ public static boolean zipFileAtPath(String sourcePath, String toLocation) {
+ final int BUFFER = 2048;
+
+ File sourceFile = new File(sourcePath);
+ try {
+ BufferedInputStream origin;
+ FileOutputStream dest = new FileOutputStream(toLocation);
+ ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(
+ dest));
+ if (sourceFile.isDirectory()) {
+ zipSubFolder(out, sourceFile, sourceFile.getParent().length());
+ } else {
+ byte[] data = new byte[BUFFER];
+ FileInputStream fi = new FileInputStream(sourcePath);
+ origin = new BufferedInputStream(fi, BUFFER);
+ ZipEntry entry = new ZipEntry(getLastPathComponent(sourcePath));
+ entry.setTime(sourceFile.lastModified()); // to keep modification time after unzipping
+ out.putNextEntry(entry);
+ int count;
+ while ((count = origin.read(data, 0, BUFFER)) != -1) {
+ out.write(data, 0, count);
+ }
+ }
+ out.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ *
+ * Zips a subfolder
+ *
+ */
+
+ private static void zipSubFolder(ZipOutputStream out, File folder,
+ int basePathLength) throws IOException {
+
+ final int BUFFER = 2048;
+
+ File[] fileList = folder.listFiles();
+ BufferedInputStream origin;
+ for (File file : fileList) {
+ if (file.isDirectory()) {
+ zipSubFolder(out, file, basePathLength);
+ } else {
+ byte[] data = new byte[BUFFER];
+ String unmodifiedFilePath = file.getPath();
+ String relativePath = unmodifiedFilePath
+ .substring(basePathLength);
+ FileInputStream fi = new FileInputStream(unmodifiedFilePath);
+ origin = new BufferedInputStream(fi, BUFFER);
+ ZipEntry entry = new ZipEntry(relativePath);
+ entry.setTime(file.lastModified()); // to keep modification time after unzipping
+ out.putNextEntry(entry);
+ int count;
+ while ((count = origin.read(data, 0, BUFFER)) != -1) {
+ out.write(data, 0, count);
+ }
+ origin.close();
+ }
+ }
+ }
+
+ /*
+ * gets the last path component
+ *
+ * Example: getLastPathComponent("downloads/example/fileToZip");
+ * Result: "fileToZip"
+ */
+ public static String getLastPathComponent(String filePath) {
+ String[] segments = filePath.split("/");
+ if (segments.length == 0)
+ return "";
+ return segments[segments.length - 1];
+ }
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java b/orbotmanager/src/main/java/org/orbotproject/android/service/vpn/OrbotVpnManager.java
similarity index 91%
rename from orbotmanager/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/vpn/OrbotVpnManager.java
index 7e991ace..6e73d8a8 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/vpn/OrbotVpnManager.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/vpn/OrbotVpnManager.java
@@ -1,412 +1,409 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.torproject.android.service.vpn;
-
-import android.annotation.TargetApi;
-import android.app.Service;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.net.VpnService;
-import android.os.Build;
-import android.os.Handler;
-import android.os.Message;
-import android.os.ParcelFileDescriptor;
-import android.text.TextUtils;
-import android.util.Log;
-import android.widget.Toast;
-
-import com.runjva.sourceforge.jsocks.protocol.ProxyServer;
-import com.runjva.sourceforge.jsocks.server.ServerAuthenticatorNone;
-
-import org.torproject.android.service.OrbotConstants;
-import org.torproject.android.service.OrbotService;
-import org.torproject.android.service.R;
-import org.torproject.android.service.TorServiceConstants;
-import org.torproject.android.service.util.CustomNativeLoader;
-import org.torproject.android.service.util.Prefs;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.concurrent.TimeoutException;
-
-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_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 {
- private static final String TAG = "OrbotVpnService";
- private final static int VPN_MTU = 1500;
- private final static boolean mIsLollipop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
- private final static String PDNSD_BIN = "pdnsd";
- public static int sSocksProxyServerPort = -1;
- public static String sSocksProxyLocalhost = null;
- boolean isStarted = false;
- File filePdnsPid;
- private Thread mThreadVPN;
- private final static String mSessionName = "OrbotVPN";
- private ParcelFileDescriptor mInterface;
- private int mTorSocks = -1;
- private int mTorDns = -1;
- private int pdnsdPort = 8091;
- private ProxyServer mSocksProxyServer;
- private final File filePdnsd;
- private boolean isRestart = false;
- private final VpnService mService;
-
- public OrbotVpnManager(VpnService service) {
- mService = service;
- filePdnsd = CustomNativeLoader.loadNativeBinary(service.getApplicationContext(), PDNSD_BIN, new File(service.getFilesDir(), PDNSD_BIN));
- Tun2Socks.init();
- }
-
- 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.getAbsolutePath(), pdnsdHost, pdnsdPort);
-
- Log.d(TAG, "pdsnd conf:" + conf);
-
- File fPid = new File(fileDir, pdnsdPort + "pdnsd.conf");
-
- if (fPid.exists()) {
- fPid.delete();
- }
-
- PrintWriter ps = new PrintWriter(new FileWriter(fPid, false));
- ps.write(conf);
- ps.close();
-
- File cache = new File(fileDir, "pdnsd.cache");
-
- if (!cache.exists()) {
- try {
- cache.createNewFile();
- } catch (Exception e) {
- }
- }
- return fPid;
- }
-
- public int handleIntent(VpnService.Builder builder, Intent intent) {
- if (intent != null) {
- String action = intent.getAction();
-
- if (action != null) {
- if (action.equals(ACTION_START_VPN) || action.equals(ACTION_START)) {
- Log.d(TAG, "starting VPN");
-
- isStarted = true;
-
- // Stop the previous session by interrupting the thread.
- if (mThreadVPN != null && mThreadVPN.isAlive())
- stopVPN();
-
- if (mTorSocks != -1) {
- if (!mIsLollipop) {
- startSocksBypass();
- }
-
- setupTun2Socks(builder);
- }
-
- } else if (action.equals(ACTION_STOP_VPN)) {
- isStarted = false;
-
- Log.d(TAG, "stopping VPN");
-
- stopVPN();
- } else if (action.equals(TorServiceConstants.LOCAL_ACTION_PORTS)) {
- Log.d(TAG, "setting VPN ports");
-
- int torSocks = intent.getIntExtra(OrbotService.EXTRA_SOCKS_PROXY_PORT, TOR_TRANSPROXY_PORT_DEFAULT);
- int torDns = intent.getIntExtra(OrbotService.EXTRA_DNS_PORT, TOR_DNS_PORT_DEFAULT);
-
- //if running, we need to restart
- if ((torSocks != mTorSocks || torDns != mTorDns)) {
-
- mTorSocks = torSocks;
- mTorDns = torDns;
-
- if (!mIsLollipop) {
- stopSocksBypass();
- startSocksBypass();
- }
-
- setupTun2Socks(builder);
- }
- }
- }
-
- }
-
-
- return Service.START_STICKY;
- }
-
- private void startSocksBypass() {
- new Thread() {
- public void run() {
-
- //generate the proxy port that the
- if (sSocksProxyServerPort == -1) {
- try {
-
- sSocksProxyLocalhost = "127.0.0.1";// InetAddress.getLocalHost().getHostAddress();
- sSocksProxyServerPort = (int) ((Math.random() * 1000) + 10000);
-
- } catch (Exception e) {
- Log.e(TAG, "Unable to access localhost", e);
- throw new RuntimeException("Unable to access localhost: " + e);
-
- }
-
- }
-
-
- if (mSocksProxyServer != null) {
- stopSocksBypass();
- }
-
- try {
- mSocksProxyServer = new ProxyServer(new ServerAuthenticatorNone(null, null));
- ProxyServer.setVpnService(mService);
- mSocksProxyServer.start(sSocksProxyServerPort, 5, InetAddress.getLocalHost());
-
- } catch (Exception e) {
- Log.e(TAG, "error getting host", e);
- }
- }
- }.start();
- }
-
- private synchronized void stopSocksBypass() {
- if (mSocksProxyServer != null) {
- mSocksProxyServer.stop();
- mSocksProxyServer = null;
- }
- }
-
- private void stopVPN() {
- if (mIsLollipop)
- stopSocksBypass();
-
- Tun2Socks.Stop();
-
- if (mInterface != null) {
- try {
- Log.d(TAG, "closing interface, destroying VPN interface");
-
- mInterface.close();
- mInterface = null;
-
- } catch (Exception e) {
- Log.d(TAG, "error stopping tun2socks", e);
- } catch (Error e) {
- Log.d(TAG, "error stopping tun2socks", e);
- }
- }
- stopDns();
- mThreadVPN = null;
- }
-
- @Override
- public boolean handleMessage(Message message) {
- if (message != null) {
- Toast.makeText(mService, message.what, Toast.LENGTH_SHORT).show();
- }
- return true;
- }
-
- private synchronized void setupTun2Socks(final VpnService.Builder builder) {
- if (mInterface != null) //stop tun2socks now to give it time to clean up
- {
- isRestart = true;
- Tun2Socks.Stop();
-
- stopDns();
-
- }
-
- mThreadVPN = new Thread() {
-
- public void run() {
- try {
-
- if (isRestart) {
- Log.d(TAG, "is a restart... let's wait for a few seconds");
- Thread.sleep(3000);
- }
-
- final String vpnName = "OrbotVPN";
- final String localhost = "127.0.0.1";
-
- final String virtualGateway = "192.168.200.1";
- final String virtualIP = "192.168.200.2";
- final String virtualNetMask = "255.255.255.0";
- final String dummyDNS = "1.1.1.1"; //this is intercepted by the tun2socks library, but we must put in a valid DNS to start
- final String defaultRoute = "0.0.0.0";
-
- final String localSocks = localhost + ':' + mTorSocks;
-
- builder.setMtu(VPN_MTU);
- builder.addAddress(virtualGateway, 32);
-
- builder.setSession(vpnName);
-
- //route all traffic through VPN (we might offer country specific exclude lists in the future)
- builder.addRoute(defaultRoute, 0);
-
- builder.addDnsServer(dummyDNS);
- builder.addRoute(dummyDNS, 32);
-
- //handle ipv6
- //builder.addAddress("fdfe:dcba:9876::1", 126);
- //builder.addRoute("::", 0);
-
- if (mIsLollipop)
- doLollipopAppRouting(builder);
-
- // https://developer.android.com/reference/android/net/VpnService.Builder#setMetered(boolean)
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
- builder.setMetered(false);
- }
-
- // Create a new interface using the builder and save the parameters.
- ParcelFileDescriptor newInterface = builder.setSession(mSessionName)
- .setConfigureIntent(null) // previously this was set to a null member variable
- .establish();
-
- if (mInterface != null) {
- Log.d(TAG, "Stopping existing VPN interface");
- mInterface.close();
- mInterface = null;
- }
-
- mInterface = newInterface;
-
- isRestart = false;
-
- //start PDNSD daemon pointing to actual DNS
- if (filePdnsd != null) {
-
- pdnsdPort++;
- startDNS(filePdnsd.getCanonicalPath(), localhost, mTorDns, virtualGateway, pdnsdPort);
- final boolean localDnsTransparentProxy = true;
-
- Tun2Socks.Start(mService, mInterface, VPN_MTU, virtualIP, virtualNetMask, localSocks, virtualGateway + ":" + pdnsdPort, localDnsTransparentProxy);
- }
-
- } catch (Exception e) {
- Log.d(TAG, "tun2Socks has stopped", e);
- }
- }
-
- };
-
- mThreadVPN.start();
-
- }
-
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- private void doLollipopAppRouting(VpnService.Builder builder) throws NameNotFoundException {
- SharedPreferences prefs = Prefs.getSharedPrefs(mService.getApplicationContext());
- ArrayList apps = TorifiedApp.getApps(mService, prefs);
-
-
- boolean perAppEnabled = false;
-
- for (TorifiedApp app : apps) {
- if (app.isTorified() && (!app.getPackageName().equals(mService.getPackageName()))) {
- if (prefs.getBoolean(app.getPackageName() + OrbotConstants.APP_TOR_KEY, true)) {
-
- builder.addAllowedApplication(app.getPackageName());
-
- }
-
- perAppEnabled = true;
-
- }
- }
-
- if (!perAppEnabled)
- builder.addDisallowedApplication(mService.getPackageName());
-
- }
-
- private void startDNS(String pdnsPath, String torDnsHost, int torDnsPort, String pdnsdHost, int pdnsdPort) throws IOException, TimeoutException {
-
- File fileConf = makePdnsdConf(mService, mService.getFilesDir(), torDnsHost, torDnsPort, pdnsdHost, pdnsdPort);
-
- String[] cmdString = {pdnsPath, "-c", fileConf.toString(), "-g", "-v2"};
- ProcessBuilder pb = new ProcessBuilder(cmdString);
- pb.redirectErrorStream(true);
- Process proc = pb.start();
- try {
- proc.waitFor();
- } catch (Exception e) {
- }
-
- Log.i(TAG, "PDNSD: " + proc.exitValue());
-
- if (proc.exitValue() != 0) {
- BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
-
- String line;
- while ((line = br.readLine()) != null) {
- Log.d(TAG, "pdnsd: " + line);
- }
- }
-
-
- }
-
- private void stopDns() {
- if (filePdnsPid != null && filePdnsPid.exists()) {
- ArrayList lines = new ArrayList<>();
- try {
- BufferedReader reader = new BufferedReader(new FileReader(filePdnsPid));
-
- String line = null;
- while ((line = reader.readLine())!= null)
- lines.add(line);
-
- String dnsPid = lines.get(0);
- VpnUtils.killProcess(dnsPid, "");
- filePdnsPid.delete();
- filePdnsPid = null;
- } catch (Exception e) {
- Log.e("OrbotVPN", "error killing dns process", e);
- }
- }
- }
-
- public boolean isStarted() {
- return isStarted;
- }
-}
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.orbotproject.android.service.vpn;
+
+import android.annotation.TargetApi;
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.net.VpnService;
+import android.os.Build;
+import android.os.Handler;
+import android.os.Message;
+import android.os.ParcelFileDescriptor;
+import android.util.Log;
+import android.widget.Toast;
+
+import com.runjva.sourceforge.jsocks.protocol.ProxyServer;
+import com.runjva.sourceforge.jsocks.server.ServerAuthenticatorNone;
+
+import org.orbotproject.android.service.R;
+import org.orbotproject.android.service.util.CustomNativeLoader;
+import org.orbotproject.android.service.util.Prefs;
+import org.orbotproject.android.service.OrbotConstants;
+import org.orbotproject.android.service.OrbotService;
+import org.orbotproject.android.service.TorServiceConstants;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.concurrent.TimeoutException;
+
+import static org.orbotproject.android.service.TorServiceConstants.ACTION_START;
+import static org.orbotproject.android.service.TorServiceConstants.ACTION_START_VPN;
+import static org.orbotproject.android.service.TorServiceConstants.ACTION_STOP_VPN;
+import static org.orbotproject.android.service.TorServiceConstants.TOR_DNS_PORT_DEFAULT;
+import static org.orbotproject.android.service.TorServiceConstants.TOR_TRANSPROXY_PORT_DEFAULT;
+
+public class OrbotVpnManager implements Handler.Callback {
+ private static final String TAG = "OrbotVpnService";
+ private final static int VPN_MTU = 1500;
+ private final static boolean mIsLollipop = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
+ private final static String PDNSD_BIN = "pdnsd";
+ public static int sSocksProxyServerPort = -1;
+ public static String sSocksProxyLocalhost = null;
+ boolean isStarted = false;
+ File filePdnsPid;
+ private Thread mThreadVPN;
+ private final static String mSessionName = "OrbotVPN";
+ private ParcelFileDescriptor mInterface;
+ private int mTorSocks = -1;
+ private int mTorDns = -1;
+ private int pdnsdPort = 8091;
+ private ProxyServer mSocksProxyServer;
+ private final File filePdnsd;
+ private boolean isRestart = false;
+ private final VpnService mService;
+
+ public OrbotVpnManager(VpnService service) {
+ mService = service;
+ filePdnsd = CustomNativeLoader.loadNativeBinary(service.getApplicationContext(), PDNSD_BIN, new File(service.getFilesDir(), PDNSD_BIN));
+ Tun2Socks.init();
+ }
+
+ 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.getAbsolutePath(), pdnsdHost, pdnsdPort);
+
+ Log.d(TAG, "pdsnd conf:" + conf);
+
+ File fPid = new File(fileDir, pdnsdPort + "pdnsd.conf");
+
+ if (fPid.exists()) {
+ fPid.delete();
+ }
+
+ PrintWriter ps = new PrintWriter(new FileWriter(fPid, false));
+ ps.write(conf);
+ ps.close();
+
+ File cache = new File(fileDir, "pdnsd.cache");
+
+ if (!cache.exists()) {
+ try {
+ cache.createNewFile();
+ } catch (Exception e) {
+ }
+ }
+ return fPid;
+ }
+
+ public int handleIntent(VpnService.Builder builder, Intent intent) {
+ if (intent != null) {
+ String action = intent.getAction();
+
+ if (action != null) {
+ if (action.equals(ACTION_START_VPN) || action.equals(ACTION_START)) {
+ Log.d(TAG, "starting VPN");
+
+ isStarted = true;
+
+ // Stop the previous session by interrupting the thread.
+ if (mThreadVPN != null && mThreadVPN.isAlive())
+ stopVPN();
+
+ if (mTorSocks != -1) {
+ if (!mIsLollipop) {
+ startSocksBypass();
+ }
+
+ setupTun2Socks(builder);
+ }
+
+ } else if (action.equals(ACTION_STOP_VPN)) {
+ isStarted = false;
+
+ Log.d(TAG, "stopping VPN");
+
+ stopVPN();
+ } else if (action.equals(TorServiceConstants.LOCAL_ACTION_PORTS)) {
+ Log.d(TAG, "setting VPN ports");
+
+ int torSocks = intent.getIntExtra(OrbotService.EXTRA_SOCKS_PROXY_PORT, TOR_TRANSPROXY_PORT_DEFAULT);
+ int torDns = intent.getIntExtra(OrbotService.EXTRA_DNS_PORT, TOR_DNS_PORT_DEFAULT);
+
+ //if running, we need to restart
+ if ((torSocks != mTorSocks || torDns != mTorDns)) {
+
+ mTorSocks = torSocks;
+ mTorDns = torDns;
+
+ if (!mIsLollipop) {
+ stopSocksBypass();
+ startSocksBypass();
+ }
+
+ setupTun2Socks(builder);
+ }
+ }
+ }
+
+ }
+
+
+ return Service.START_STICKY;
+ }
+
+ private void startSocksBypass() {
+ new Thread() {
+ public void run() {
+
+ //generate the proxy port that the
+ if (sSocksProxyServerPort == -1) {
+ try {
+
+ sSocksProxyLocalhost = "127.0.0.1";// InetAddress.getLocalHost().getHostAddress();
+ sSocksProxyServerPort = (int) ((Math.random() * 1000) + 10000);
+
+ } catch (Exception e) {
+ Log.e(TAG, "Unable to access localhost", e);
+ throw new RuntimeException("Unable to access localhost: " + e);
+
+ }
+
+ }
+
+
+ if (mSocksProxyServer != null) {
+ stopSocksBypass();
+ }
+
+ try {
+ mSocksProxyServer = new ProxyServer(new ServerAuthenticatorNone(null, null));
+ ProxyServer.setVpnService(mService);
+ mSocksProxyServer.start(sSocksProxyServerPort, 5, InetAddress.getLocalHost());
+
+ } catch (Exception e) {
+ Log.e(TAG, "error getting host", e);
+ }
+ }
+ }.start();
+ }
+
+ private synchronized void stopSocksBypass() {
+ if (mSocksProxyServer != null) {
+ mSocksProxyServer.stop();
+ mSocksProxyServer = null;
+ }
+ }
+
+ private void stopVPN() {
+ if (mIsLollipop)
+ stopSocksBypass();
+
+ Tun2Socks.Stop();
+
+ if (mInterface != null) {
+ try {
+ Log.d(TAG, "closing interface, destroying VPN interface");
+
+ mInterface.close();
+ mInterface = null;
+
+ } catch (Exception e) {
+ Log.d(TAG, "error stopping tun2socks", e);
+ } catch (Error e) {
+ Log.d(TAG, "error stopping tun2socks", e);
+ }
+ }
+ stopDns();
+ mThreadVPN = null;
+ }
+
+ @Override
+ public boolean handleMessage(Message message) {
+ if (message != null) {
+ Toast.makeText(mService, message.what, Toast.LENGTH_SHORT).show();
+ }
+ return true;
+ }
+
+ private synchronized void setupTun2Socks(final VpnService.Builder builder) {
+ if (mInterface != null) //stop tun2socks now to give it time to clean up
+ {
+ isRestart = true;
+ Tun2Socks.Stop();
+
+ stopDns();
+
+ }
+
+ mThreadVPN = new Thread() {
+
+ public void run() {
+ try {
+
+ if (isRestart) {
+ Log.d(TAG, "is a restart... let's wait for a few seconds");
+ Thread.sleep(3000);
+ }
+
+ final String vpnName = "OrbotVPN";
+ final String localhost = "127.0.0.1";
+
+ final String virtualGateway = "192.168.200.1";
+ final String virtualIP = "192.168.200.2";
+ final String virtualNetMask = "255.255.255.0";
+ final String dummyDNS = "1.1.1.1"; //this is intercepted by the tun2socks library, but we must put in a valid DNS to start
+ final String defaultRoute = "0.0.0.0";
+
+ final String localSocks = localhost + ':' + mTorSocks;
+
+ builder.setMtu(VPN_MTU);
+ builder.addAddress(virtualGateway, 32);
+
+ builder.setSession(vpnName);
+
+ //route all traffic through VPN (we might offer country specific exclude lists in the future)
+ builder.addRoute(defaultRoute, 0);
+
+ builder.addDnsServer(dummyDNS);
+ builder.addRoute(dummyDNS, 32);
+
+ //handle ipv6
+ //builder.addAddress("fdfe:dcba:9876::1", 126);
+ //builder.addRoute("::", 0);
+
+ if (mIsLollipop)
+ doLollipopAppRouting(builder);
+
+ // https://developer.android.com/reference/android/net/VpnService.Builder#setMetered(boolean)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ builder.setMetered(false);
+ }
+
+ // Create a new interface using the builder and save the parameters.
+ ParcelFileDescriptor newInterface = builder.setSession(mSessionName)
+ .setConfigureIntent(null) // previously this was set to a null member variable
+ .establish();
+
+ if (mInterface != null) {
+ Log.d(TAG, "Stopping existing VPN interface");
+ mInterface.close();
+ mInterface = null;
+ }
+
+ mInterface = newInterface;
+
+ isRestart = false;
+
+ //start PDNSD daemon pointing to actual DNS
+ if (filePdnsd != null) {
+
+ pdnsdPort++;
+ startDNS(filePdnsd.getCanonicalPath(), localhost, mTorDns, virtualGateway, pdnsdPort);
+ final boolean localDnsTransparentProxy = true;
+
+ Tun2Socks.Start(mService, mInterface, VPN_MTU, virtualIP, virtualNetMask, localSocks, virtualGateway + ":" + pdnsdPort, localDnsTransparentProxy);
+ }
+
+ } catch (Exception e) {
+ Log.d(TAG, "tun2Socks has stopped", e);
+ }
+ }
+
+ };
+
+ mThreadVPN.start();
+
+ }
+
+ @TargetApi(Build.VERSION_CODES.LOLLIPOP)
+ private void doLollipopAppRouting(VpnService.Builder builder) throws NameNotFoundException {
+ SharedPreferences prefs = Prefs.getSharedPrefs(mService.getApplicationContext());
+ ArrayList apps = TorifiedApp.getApps(mService, prefs);
+
+
+ boolean perAppEnabled = false;
+
+ for (TorifiedApp app : apps) {
+ if (app.isTorified() && (!app.getPackageName().equals(mService.getPackageName()))) {
+ if (prefs.getBoolean(app.getPackageName() + OrbotConstants.APP_TOR_KEY, true)) {
+
+ builder.addAllowedApplication(app.getPackageName());
+
+ }
+
+ perAppEnabled = true;
+
+ }
+ }
+
+ if (!perAppEnabled)
+ builder.addDisallowedApplication(mService.getPackageName());
+
+ }
+
+ private void startDNS(String pdnsPath, String torDnsHost, int torDnsPort, String pdnsdHost, int pdnsdPort) throws IOException, TimeoutException {
+
+ File fileConf = makePdnsdConf(mService, mService.getFilesDir(), torDnsHost, torDnsPort, pdnsdHost, pdnsdPort);
+
+ String[] cmdString = {pdnsPath, "-c", fileConf.toString(), "-g", "-v2"};
+ ProcessBuilder pb = new ProcessBuilder(cmdString);
+ pb.redirectErrorStream(true);
+ Process proc = pb.start();
+ try {
+ proc.waitFor();
+ } catch (Exception e) {
+ }
+
+ Log.i(TAG, "PDNSD: " + proc.exitValue());
+
+ if (proc.exitValue() != 0) {
+ BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+
+ String line;
+ while ((line = br.readLine()) != null) {
+ Log.d(TAG, "pdnsd: " + line);
+ }
+ }
+
+
+ }
+
+ private void stopDns() {
+ if (filePdnsPid != null && filePdnsPid.exists()) {
+ ArrayList lines = new ArrayList<>();
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(filePdnsPid));
+
+ String line = null;
+ while ((line = reader.readLine())!= null)
+ lines.add(line);
+
+ String dnsPid = lines.get(0);
+ VpnUtils.killProcess(dnsPid, "");
+ filePdnsPid.delete();
+ filePdnsPid = null;
+ } catch (Exception e) {
+ Log.e("OrbotVPN", "error killing dns process", e);
+ }
+ }
+ }
+
+ public boolean isStarted() {
+ return isStarted;
+ }
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/vpn/TorifiedApp.java b/orbotmanager/src/main/java/org/orbotproject/android/service/vpn/TorifiedApp.java
similarity index 93%
rename from orbotmanager/src/main/java/org/torproject/android/service/vpn/TorifiedApp.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/vpn/TorifiedApp.java
index b7bc01e6..48a2f548 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/vpn/TorifiedApp.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/vpn/TorifiedApp.java
@@ -1,260 +1,260 @@
-package org.torproject.android.service.vpn;
-
-import android.Manifest;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.graphics.drawable.Drawable;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import static org.torproject.android.service.vpn.VpnPrefs.PREFS_KEY_TORIFIED;
-
-public class TorifiedApp implements Comparable {
-
- private boolean enabled;
- private int uid;
- private String username;
- private String procname;
- private String name;
- private Drawable icon;
- private String packageName;
-
- private boolean torified = false;
- private boolean usesInternet = false;
- private int[] enabledPorts;
-
- public static ArrayList getApps(Context context, SharedPreferences prefs) {
-
- String tordAppString = prefs.getString(PREFS_KEY_TORIFIED, "");
- String[] tordApps;
-
- StringTokenizer st = new StringTokenizer(tordAppString, "|");
- tordApps = new String[st.countTokens()];
- int tordIdx = 0;
- while (st.hasMoreTokens()) {
- tordApps[tordIdx++] = st.nextToken();
- }
-
- Arrays.sort(tordApps);
-
- //else load the apps up
- PackageManager pMgr = context.getPackageManager();
-
- List lAppInfo = pMgr.getInstalledApplications(0);
-
- Iterator itAppInfo = lAppInfo.iterator();
-
- ArrayList apps = new ArrayList<>();
-
- ApplicationInfo aInfo;
-
- int appIdx = 0;
- TorifiedApp app;
-
- while (itAppInfo.hasNext()) {
- aInfo = itAppInfo.next();
-
- app = new TorifiedApp();
-
- try {
- PackageInfo pInfo = pMgr.getPackageInfo(aInfo.packageName, PackageManager.GET_PERMISSIONS);
-
- if (pInfo != null && pInfo.requestedPermissions != null) {
- for (String permInfo : pInfo.requestedPermissions) {
- if (permInfo.equals(Manifest.permission.INTERNET)) {
- app.setUsesInternet(true);
-
- }
- }
-
- }
-
-
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- if ((aInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
- //System app
- app.setUsesInternet(true);
- }
-
-
- if (!app.usesInternet())
- continue;
- else {
- apps.add(app);
- }
-
-
- app.setEnabled(aInfo.enabled);
- app.setUid(aInfo.uid);
- app.setUsername(pMgr.getNameForUid(app.getUid()));
- app.setProcname(aInfo.processName);
- app.setPackageName(aInfo.packageName);
-
- try {
- app.setName(pMgr.getApplicationLabel(aInfo).toString());
- } catch (Exception e) {
- app.setName(aInfo.packageName);
- }
-
-
- //app.setIcon(pMgr.getApplicationIcon(aInfo));
-
- // check if this application is allowed
- if (Arrays.binarySearch(tordApps, app.getUsername()) >= 0) {
- app.setTorified(true);
- } else {
- app.setTorified(false);
- }
-
- appIdx++;
- }
-
- Collections.sort(apps);
-
- return apps;
- }
-
- public boolean usesInternet() {
- return usesInternet;
- }
-
- public void setUsesInternet(boolean usesInternet) {
- this.usesInternet = usesInternet;
- }
-
- /**
- * @return the torified
- */
- public boolean isTorified() {
- return torified;
- }
-
- /**
- * @param torified the torified to set
- */
- public void setTorified(boolean torified) {
- this.torified = torified;
- }
-
- /**
- * @return the enabledPorts
- */
- public int[] getEnabledPorts() {
- return enabledPorts;
- }
-
- /**
- * @param enabledPorts the enabledPorts to set
- */
- public void setEnabledPorts(int[] enabledPorts) {
- this.enabledPorts = enabledPorts;
- }
-
- /**
- * @return the enabled
- */
- public boolean isEnabled() {
- return enabled;
- }
-
- /**
- * @param enabled the enabled to set
- */
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- /**
- * @return the uid
- */
- public int getUid() {
- return uid;
- }
-
- /**
- * @param uid the uid to set
- */
- public void setUid(int uid) {
- this.uid = uid;
- }
-
- /**
- * @return the username
- */
- public String getUsername() {
- return username;
- }
-
- /**
- * @param username the username to set
- */
- public void setUsername(String username) {
- this.username = username;
- }
-
- /**
- * @return the procname
- */
- public String getProcname() {
- return procname;
- }
-
- /**
- * @param procname the procname to set
- */
- public void setProcname(String procname) {
- this.procname = procname;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- public Drawable getIcon() {
- return icon;
- }
-
- public void setIcon(Drawable icon) {
- this.icon = icon;
- }
-
- @Override
- public int compareTo(Object another) {
- return this.toString().compareToIgnoreCase(another.toString());
- }
-
- @Override
- public String toString() {
- return getName();
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
-}
+package org.orbotproject.android.service.vpn;
+
+import android.Manifest;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import static org.orbotproject.android.service.vpn.VpnPrefs.PREFS_KEY_TORIFIED;
+
+public class TorifiedApp implements Comparable {
+
+ private boolean enabled;
+ private int uid;
+ private String username;
+ private String procname;
+ private String name;
+ private Drawable icon;
+ private String packageName;
+
+ private boolean torified = false;
+ private boolean usesInternet = false;
+ private int[] enabledPorts;
+
+ public static ArrayList getApps(Context context, SharedPreferences prefs) {
+
+ String tordAppString = prefs.getString(PREFS_KEY_TORIFIED, "");
+ String[] tordApps;
+
+ StringTokenizer st = new StringTokenizer(tordAppString, "|");
+ tordApps = new String[st.countTokens()];
+ int tordIdx = 0;
+ while (st.hasMoreTokens()) {
+ tordApps[tordIdx++] = st.nextToken();
+ }
+
+ Arrays.sort(tordApps);
+
+ //else load the apps up
+ PackageManager pMgr = context.getPackageManager();
+
+ List lAppInfo = pMgr.getInstalledApplications(0);
+
+ Iterator itAppInfo = lAppInfo.iterator();
+
+ ArrayList apps = new ArrayList<>();
+
+ ApplicationInfo aInfo;
+
+ int appIdx = 0;
+ TorifiedApp app;
+
+ while (itAppInfo.hasNext()) {
+ aInfo = itAppInfo.next();
+
+ app = new TorifiedApp();
+
+ try {
+ PackageInfo pInfo = pMgr.getPackageInfo(aInfo.packageName, PackageManager.GET_PERMISSIONS);
+
+ if (pInfo != null && pInfo.requestedPermissions != null) {
+ for (String permInfo : pInfo.requestedPermissions) {
+ if (permInfo.equals(Manifest.permission.INTERNET)) {
+ app.setUsesInternet(true);
+
+ }
+ }
+
+ }
+
+
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ if ((aInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
+ //System app
+ app.setUsesInternet(true);
+ }
+
+
+ if (!app.usesInternet())
+ continue;
+ else {
+ apps.add(app);
+ }
+
+
+ app.setEnabled(aInfo.enabled);
+ app.setUid(aInfo.uid);
+ app.setUsername(pMgr.getNameForUid(app.getUid()));
+ app.setProcname(aInfo.processName);
+ app.setPackageName(aInfo.packageName);
+
+ try {
+ app.setName(pMgr.getApplicationLabel(aInfo).toString());
+ } catch (Exception e) {
+ app.setName(aInfo.packageName);
+ }
+
+
+ //app.setIcon(pMgr.getApplicationIcon(aInfo));
+
+ // check if this application is allowed
+ if (Arrays.binarySearch(tordApps, app.getUsername()) >= 0) {
+ app.setTorified(true);
+ } else {
+ app.setTorified(false);
+ }
+
+ appIdx++;
+ }
+
+ Collections.sort(apps);
+
+ return apps;
+ }
+
+ public boolean usesInternet() {
+ return usesInternet;
+ }
+
+ public void setUsesInternet(boolean usesInternet) {
+ this.usesInternet = usesInternet;
+ }
+
+ /**
+ * @return the torified
+ */
+ public boolean isTorified() {
+ return torified;
+ }
+
+ /**
+ * @param torified the torified to set
+ */
+ public void setTorified(boolean torified) {
+ this.torified = torified;
+ }
+
+ /**
+ * @return the enabledPorts
+ */
+ public int[] getEnabledPorts() {
+ return enabledPorts;
+ }
+
+ /**
+ * @param enabledPorts the enabledPorts to set
+ */
+ public void setEnabledPorts(int[] enabledPorts) {
+ this.enabledPorts = enabledPorts;
+ }
+
+ /**
+ * @return the enabled
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * @param enabled the enabled to set
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ /**
+ * @return the uid
+ */
+ public int getUid() {
+ return uid;
+ }
+
+ /**
+ * @param uid the uid to set
+ */
+ public void setUid(int uid) {
+ this.uid = uid;
+ }
+
+ /**
+ * @return the username
+ */
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * @param username the username to set
+ */
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ /**
+ * @return the procname
+ */
+ public String getProcname() {
+ return procname;
+ }
+
+ /**
+ * @param procname the procname to set
+ */
+ public void setProcname(String procname) {
+ this.procname = procname;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Drawable getIcon() {
+ return icon;
+ }
+
+ public void setIcon(Drawable icon) {
+ this.icon = icon;
+ }
+
+ @Override
+ public int compareTo(Object another) {
+ return this.toString().compareToIgnoreCase(another.toString());
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/vpn/Tun2Socks.java b/orbotmanager/src/main/java/org/orbotproject/android/service/vpn/Tun2Socks.java
similarity index 95%
rename from orbotmanager/src/main/java/org/torproject/android/service/vpn/Tun2Socks.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/vpn/Tun2Socks.java
index 461a5a8d..d3816fa4 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/vpn/Tun2Socks.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/vpn/Tun2Socks.java
@@ -1,173 +1,173 @@
-package org.torproject.android.service.vpn;
-
-/*
- * Copyright (c) 2013, Psiphon Inc.
- * All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- */
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.net.ConnectivityManager;
-import android.os.Build;
-import android.os.ParcelFileDescriptor;
-import android.util.Log;
-
-import org.torproject.android.service.util.TCPSourceApp;
-
-import java.net.DatagramSocket;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.util.HashMap;
-
-import static android.content.Context.CONNECTIVITY_SERVICE;
-
-public class Tun2Socks {
-
- private static final String TAG = Tun2Socks.class.getSimpleName();
- private static final boolean LOGD = true;
-
- private static ParcelFileDescriptor mVpnInterfaceFileDescriptor;
- private static int mVpnInterfaceMTU;
- private static String mVpnIpAddress;
- private static String mVpnNetMask;
- private static String mSocksServerAddress;
- private static String mUdpgwServerAddress;
- private static boolean mUdpgwTransparentDNS;
- private static HashMap mAppUidBlacklist = new HashMap<>();
-
- static {
- System.loadLibrary("tun2socks");
- }
-
- public static void init() {
- }
- // Note: this class isn't a singleton, but you can't run more
- // than one instance due to the use of global state (the lwip
- // module, etc.) in the native code.
-
- public static void Start(
- Context context,
- ParcelFileDescriptor vpnInterfaceFileDescriptor,
- int vpnInterfaceMTU,
- String vpnIpAddress,
- String vpnNetMask,
- String socksServerAddress,
- String udpgwServerAddress,
- boolean udpgwTransparentDNS) {
-
- mVpnInterfaceFileDescriptor = vpnInterfaceFileDescriptor;
- mVpnInterfaceMTU = vpnInterfaceMTU;
- mVpnIpAddress = vpnIpAddress;
- mVpnNetMask = vpnNetMask;
- mSocksServerAddress = socksServerAddress;
- mUdpgwServerAddress = udpgwServerAddress;
- mUdpgwTransparentDNS = udpgwTransparentDNS;
-
- if (mVpnInterfaceFileDescriptor != null)
- runTun2Socks(
- mVpnInterfaceFileDescriptor.detachFd(),
- mVpnInterfaceMTU,
- mVpnIpAddress,
- mVpnNetMask,
- mSocksServerAddress,
- mUdpgwServerAddress,
- mUdpgwTransparentDNS ? 1 : 0);
- }
-
- public static void Stop() {
-
- terminateTun2Socks();
-
- }
-
- public static void logTun2Socks(
- String level,
- String channel,
- String msg) {
- String logMsg = level + "(" + channel + "): " + msg;
- if (0 == level.compareTo("ERROR")) {
- Log.e(TAG, logMsg);
- } else {
- if (LOGD) Log.d(TAG, logMsg);
- }
- }
-
- private native static int runTun2Socks(
- int vpnInterfaceFileDescriptor,
- int vpnInterfaceMTU,
- String vpnIpAddress,
- String vpnNetMask,
- String socksServerAddress,
- String udpgwServerAddress,
- int udpgwTransparentDNS);
-
- private native static void terminateTun2Socks();
-
- public static boolean checkIsAllowed(Context context, int protocol, String sourceAddr, int sourcePort, String destAddr, int destPort) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
- return isAllowedQ(context, protocol, sourceAddr, sourcePort, destAddr, destPort);
- } else
- return isAllowed(context, protocol, sourceAddr, sourcePort, destAddr, destPort);
- }
-
- public static boolean isAllowed(Context context, int protocol, String sourceAddr, int sourcePort, String destAddr, int destPort) {
-
- TCPSourceApp.AppDescriptor aInfo = TCPSourceApp.getApplicationInfo(context, sourceAddr, sourcePort, destAddr, destPort);
-
- if (aInfo != null) {
- int uid = aInfo.getUid();
- return mAppUidBlacklist.containsKey(uid);
- } else
- return true;
- }
-
- @TargetApi(Build.VERSION_CODES.Q)
- public static boolean isAllowedQ(Context context, int protocol, String sourceAddr, int sourcePort, String destAddr, int destPort) {
- ConnectivityManager cm = (ConnectivityManager) context.getSystemService(CONNECTIVITY_SERVICE);
- if (cm == null)
- return false;
-
- InetSocketAddress local = new InetSocketAddress(sourceAddr, sourcePort);
- InetSocketAddress remote = new InetSocketAddress(destAddr, destPort);
-
- int uid = cm.getConnectionOwnerUid(protocol, local, remote);
- return mAppUidBlacklist.containsKey(uid);
- }
-
- public static void setBlacklist(HashMap appUidBlacklist) {
- mAppUidBlacklist = appUidBlacklist;
- }
-
- public static void clearBlacklist() {
- mAppUidBlacklist.clear();
- }
-
- public static void addToBlacklist(int uid, String pkgId) {
- mAppUidBlacklist.put(uid, pkgId);
- }
-
- public static void removeFromBlacklist(int uid) {
- mAppUidBlacklist.remove(uid);
- }
-
- public interface IProtectSocket {
- boolean doVpnProtect(Socket socket);
-
- boolean doVpnProtect(DatagramSocket socket);
- }
-
+package org.orbotproject.android.service.vpn;
+
+/*
+ * Copyright (c) 2013, Psiphon Inc.
+ * All rights reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.os.Build;
+import android.os.ParcelFileDescriptor;
+import android.util.Log;
+
+import org.orbotproject.android.service.util.TCPSourceApp;
+
+import java.net.DatagramSocket;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.util.HashMap;
+
+import static android.content.Context.CONNECTIVITY_SERVICE;
+
+public class Tun2Socks {
+
+ private static final String TAG = Tun2Socks.class.getSimpleName();
+ private static final boolean LOGD = true;
+
+ private static ParcelFileDescriptor mVpnInterfaceFileDescriptor;
+ private static int mVpnInterfaceMTU;
+ private static String mVpnIpAddress;
+ private static String mVpnNetMask;
+ private static String mSocksServerAddress;
+ private static String mUdpgwServerAddress;
+ private static boolean mUdpgwTransparentDNS;
+ private static HashMap mAppUidBlacklist = new HashMap<>();
+
+ static {
+ System.loadLibrary("tun2socks");
+ }
+
+ public static void init() {
+ }
+ // Note: this class isn't a singleton, but you can't run more
+ // than one instance due to the use of global state (the lwip
+ // module, etc.) in the native code.
+
+ public static void Start(
+ Context context,
+ ParcelFileDescriptor vpnInterfaceFileDescriptor,
+ int vpnInterfaceMTU,
+ String vpnIpAddress,
+ String vpnNetMask,
+ String socksServerAddress,
+ String udpgwServerAddress,
+ boolean udpgwTransparentDNS) {
+
+ mVpnInterfaceFileDescriptor = vpnInterfaceFileDescriptor;
+ mVpnInterfaceMTU = vpnInterfaceMTU;
+ mVpnIpAddress = vpnIpAddress;
+ mVpnNetMask = vpnNetMask;
+ mSocksServerAddress = socksServerAddress;
+ mUdpgwServerAddress = udpgwServerAddress;
+ mUdpgwTransparentDNS = udpgwTransparentDNS;
+
+ if (mVpnInterfaceFileDescriptor != null)
+ runTun2Socks(
+ mVpnInterfaceFileDescriptor.detachFd(),
+ mVpnInterfaceMTU,
+ mVpnIpAddress,
+ mVpnNetMask,
+ mSocksServerAddress,
+ mUdpgwServerAddress,
+ mUdpgwTransparentDNS ? 1 : 0);
+ }
+
+ public static void Stop() {
+
+ terminateTun2Socks();
+
+ }
+
+ public static void logTun2Socks(
+ String level,
+ String channel,
+ String msg) {
+ String logMsg = level + "(" + channel + "): " + msg;
+ if (0 == level.compareTo("ERROR")) {
+ Log.e(TAG, logMsg);
+ } else {
+ if (LOGD) Log.d(TAG, logMsg);
+ }
+ }
+
+ private native static int runTun2Socks(
+ int vpnInterfaceFileDescriptor,
+ int vpnInterfaceMTU,
+ String vpnIpAddress,
+ String vpnNetMask,
+ String socksServerAddress,
+ String udpgwServerAddress,
+ int udpgwTransparentDNS);
+
+ private native static void terminateTun2Socks();
+
+ public static boolean checkIsAllowed(Context context, int protocol, String sourceAddr, int sourcePort, String destAddr, int destPort) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ return isAllowedQ(context, protocol, sourceAddr, sourcePort, destAddr, destPort);
+ } else
+ return isAllowed(context, protocol, sourceAddr, sourcePort, destAddr, destPort);
+ }
+
+ public static boolean isAllowed(Context context, int protocol, String sourceAddr, int sourcePort, String destAddr, int destPort) {
+
+ TCPSourceApp.AppDescriptor aInfo = TCPSourceApp.getApplicationInfo(context, sourceAddr, sourcePort, destAddr, destPort);
+
+ if (aInfo != null) {
+ int uid = aInfo.getUid();
+ return mAppUidBlacklist.containsKey(uid);
+ } else
+ return true;
+ }
+
+ @TargetApi(Build.VERSION_CODES.Q)
+ public static boolean isAllowedQ(Context context, int protocol, String sourceAddr, int sourcePort, String destAddr, int destPort) {
+ ConnectivityManager cm = (ConnectivityManager) context.getSystemService(CONNECTIVITY_SERVICE);
+ if (cm == null)
+ return false;
+
+ InetSocketAddress local = new InetSocketAddress(sourceAddr, sourcePort);
+ InetSocketAddress remote = new InetSocketAddress(destAddr, destPort);
+
+ int uid = cm.getConnectionOwnerUid(protocol, local, remote);
+ return mAppUidBlacklist.containsKey(uid);
+ }
+
+ public static void setBlacklist(HashMap appUidBlacklist) {
+ mAppUidBlacklist = appUidBlacklist;
+ }
+
+ public static void clearBlacklist() {
+ mAppUidBlacklist.clear();
+ }
+
+ public static void addToBlacklist(int uid, String pkgId) {
+ mAppUidBlacklist.put(uid, pkgId);
+ }
+
+ public static void removeFromBlacklist(int uid) {
+ mAppUidBlacklist.remove(uid);
+ }
+
+ public interface IProtectSocket {
+ boolean doVpnProtect(Socket socket);
+
+ boolean doVpnProtect(DatagramSocket socket);
+ }
+
}
\ No newline at end of file
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/vpn/VpnPrefs.java b/orbotmanager/src/main/java/org/orbotproject/android/service/vpn/VpnPrefs.java
similarity index 69%
rename from orbotmanager/src/main/java/org/torproject/android/service/vpn/VpnPrefs.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/vpn/VpnPrefs.java
index 4945241a..9162cfa1 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/vpn/VpnPrefs.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/vpn/VpnPrefs.java
@@ -1,8 +1,8 @@
-package org.torproject.android.service.vpn;
-
-public interface VpnPrefs {
-
- String PREFS_DNS_PORT = "PREFS_DNS_PORT";
-
- String PREFS_KEY_TORIFIED = "PrefTord";
-}
+package org.orbotproject.android.service.vpn;
+
+public interface VpnPrefs {
+
+ String PREFS_DNS_PORT = "PREFS_DNS_PORT";
+
+ String PREFS_KEY_TORIFIED = "PrefTord";
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/vpn/VpnUtils.java b/orbotmanager/src/main/java/org/orbotproject/android/service/vpn/VpnUtils.java
similarity index 95%
rename from orbotmanager/src/main/java/org/torproject/android/service/vpn/VpnUtils.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/vpn/VpnUtils.java
index 604b1c44..c7464dfb 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/vpn/VpnUtils.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/vpn/VpnUtils.java
@@ -1,136 +1,136 @@
-package org.torproject.android.service.vpn;
-
-import android.util.Log;
-
-import org.apache.commons.io.IOUtils;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.List;
-
-import static java.lang.Runtime.getRuntime;
-
-public class VpnUtils {
-
- public static int findProcessId(String command) throws IOException {
-
- String[] cmds = {"ps -ef", "ps -A", "toolbox ps"};
-
- for (int i = 0; i < cmds.length; i++) {
- Process procPs = getRuntime().exec(cmds[i]);
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
-
- String line;
- while ((line = reader.readLine()) != null) {
- if (!line.contains("PID") && line.contains(command)) {
- String[] lineParts = line.split("\\s+");
- try {
- return Integer.parseInt(lineParts[1]); //for most devices it is the second
- } catch (NumberFormatException e) {
- return Integer.parseInt(lineParts[0]); //but for samsungs it is the first
- } finally {
- try {
- procPs.destroy();
- } catch (Exception e) {
- }
- }
- }
- }
- }
-
- return -1;
- }
-
- public static void killProcess(File fileProcBin) throws Exception {
- killProcess(fileProcBin, "-9"); // this is -KILL
- }
-
- public static int killProcess(File fileProcBin, String signal) throws Exception {
-
- int procId = -1;
- int killAttempts = 0;
-
- while ((procId = findProcessId(fileProcBin.getName())) != -1) {
- killAttempts++;
- String pidString = String.valueOf(procId);
- boolean itBeDead = killProcess(pidString, signal);
-
- if (!itBeDead) {
-
- String[] cmds = {"", "busybox ", "toolbox "};
-
- for (int i = 0; i < cmds.length; i++) {
-
- Process proc;
-
- try {
- proc = getRuntime().exec(cmds[i] + "killall " + signal + " " + fileProcBin.getName
- ());
- int exitValue = proc.waitFor();
- if (exitValue == 0)
- break;
-
- } catch (IOException ioe) {
- }
- try {
- proc = getRuntime().exec(cmds[i] + "killall " + signal + " " + fileProcBin.getCanonicalPath());
- int exitValue = proc.waitFor();
- if (exitValue == 0)
- break;
-
- } catch (IOException ioe) {
- }
- }
-
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // ignored
- }
-
- }
-
- if (killAttempts > 4)
- throw new Exception("Cannot kill: " + fileProcBin.getAbsolutePath());
- }
-
- return procId;
- }
-
- public static boolean killProcess(String pidString, String signal) throws Exception {
-
- String[] cmds = {"", "toolbox ", "busybox "};
-
- for (int i = 0; i < cmds.length; i++) {
- try {
- Process proc = getRuntime().exec(cmds[i] + "kill " + signal + " " + pidString);
- int exitVal = proc.waitFor();
- List lineErrors = IOUtils.readLines(proc.getErrorStream());
- List lineInputs = IOUtils.readLines(proc.getInputStream());
-
- if (exitVal != 0) {
- Log.d("Orbot.killProcess", "exit=" + exitVal);
- for (String line : lineErrors)
- Log.d("Orbot.killProcess", line);
-
- for (String line : lineInputs)
- Log.d("Orbot.killProcess", line);
-
- } else {
- //it worked, let's exit
- return true;
- }
-
-
- } catch (IOException ioe) {
- Log.e("Orbot.killprcess", "error killing process: " + pidString, ioe);
- }
- }
-
- return false;
- }
-}
+package org.orbotproject.android.service.vpn;
+
+import android.util.Log;
+
+import org.apache.commons.io.IOUtils;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.List;
+
+import static java.lang.Runtime.getRuntime;
+
+public class VpnUtils {
+
+ public static int findProcessId(String command) throws IOException {
+
+ String[] cmds = {"ps -ef", "ps -A", "toolbox ps"};
+
+ for (int i = 0; i < cmds.length; i++) {
+ Process procPs = getRuntime().exec(cmds[i]);
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
+
+ String line;
+ while ((line = reader.readLine()) != null) {
+ if (!line.contains("PID") && line.contains(command)) {
+ String[] lineParts = line.split("\\s+");
+ try {
+ return Integer.parseInt(lineParts[1]); //for most devices it is the second
+ } catch (NumberFormatException e) {
+ return Integer.parseInt(lineParts[0]); //but for samsungs it is the first
+ } finally {
+ try {
+ procPs.destroy();
+ } catch (Exception e) {
+ }
+ }
+ }
+ }
+ }
+
+ return -1;
+ }
+
+ public static void killProcess(File fileProcBin) throws Exception {
+ killProcess(fileProcBin, "-9"); // this is -KILL
+ }
+
+ public static int killProcess(File fileProcBin, String signal) throws Exception {
+
+ int procId = -1;
+ int killAttempts = 0;
+
+ while ((procId = findProcessId(fileProcBin.getName())) != -1) {
+ killAttempts++;
+ String pidString = String.valueOf(procId);
+ boolean itBeDead = killProcess(pidString, signal);
+
+ if (!itBeDead) {
+
+ String[] cmds = {"", "busybox ", "toolbox "};
+
+ for (int i = 0; i < cmds.length; i++) {
+
+ Process proc;
+
+ try {
+ proc = getRuntime().exec(cmds[i] + "killall " + signal + " " + fileProcBin.getName
+ ());
+ int exitValue = proc.waitFor();
+ if (exitValue == 0)
+ break;
+
+ } catch (IOException ioe) {
+ }
+ try {
+ proc = getRuntime().exec(cmds[i] + "killall " + signal + " " + fileProcBin.getCanonicalPath());
+ int exitValue = proc.waitFor();
+ if (exitValue == 0)
+ break;
+
+ } catch (IOException ioe) {
+ }
+ }
+
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // ignored
+ }
+
+ }
+
+ if (killAttempts > 4)
+ throw new Exception("Cannot kill: " + fileProcBin.getAbsolutePath());
+ }
+
+ return procId;
+ }
+
+ public static boolean killProcess(String pidString, String signal) throws Exception {
+
+ String[] cmds = {"", "toolbox ", "busybox "};
+
+ for (int i = 0; i < cmds.length; i++) {
+ try {
+ Process proc = getRuntime().exec(cmds[i] + "kill " + signal + " " + pidString);
+ int exitVal = proc.waitFor();
+ List lineErrors = IOUtils.readLines(proc.getErrorStream());
+ List lineInputs = IOUtils.readLines(proc.getInputStream());
+
+ if (exitVal != 0) {
+ Log.d("Orbot.killProcess", "exit=" + exitVal);
+ for (String line : lineErrors)
+ Log.d("Orbot.killProcess", line);
+
+ for (String line : lineInputs)
+ Log.d("Orbot.killProcess", line);
+
+ } else {
+ //it worked, let's exit
+ return true;
+ }
+
+
+ } catch (IOException ioe) {
+ Log.e("Orbot.killprcess", "error killing process: " + pidString, ioe);
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/wrapper/LocaleHelper.java b/orbotmanager/src/main/java/org/orbotproject/android/service/wrapper/LocaleHelper.java
similarity index 93%
rename from orbotmanager/src/main/java/org/torproject/android/service/wrapper/LocaleHelper.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/wrapper/LocaleHelper.java
index 25248a72..b591438e 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/wrapper/LocaleHelper.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/wrapper/LocaleHelper.java
@@ -1,11 +1,11 @@
-package org.torproject.android.service.wrapper;
+package org.orbotproject.android.service.wrapper;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
-import org.torproject.android.service.util.Prefs;
+import org.orbotproject.android.service.util.Prefs;
import java.util.Locale;
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/wrapper/localHelperMethod.java b/orbotmanager/src/main/java/org/orbotproject/android/service/wrapper/localHelperMethod.java
similarity index 91%
rename from orbotmanager/src/main/java/org/torproject/android/service/wrapper/localHelperMethod.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/wrapper/localHelperMethod.java
index 063a8161..2a788bb4 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/wrapper/localHelperMethod.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/wrapper/localHelperMethod.java
@@ -1,4 +1,4 @@
-package org.torproject.android.service.wrapper;
+package org.orbotproject.android.service.wrapper;
import java.util.Calendar;
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/wrapper/logRowModel.java b/orbotmanager/src/main/java/org/orbotproject/android/service/wrapper/logRowModel.java
similarity index 86%
rename from orbotmanager/src/main/java/org/torproject/android/service/wrapper/logRowModel.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/wrapper/logRowModel.java
index 3c748669..5bc2fe4e 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/wrapper/logRowModel.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/wrapper/logRowModel.java
@@ -1,4 +1,4 @@
-package org.torproject.android.service.wrapper;
+package org.orbotproject.android.service.wrapper;
public class logRowModel {
/*Private Variables*/
diff --git a/orbotmanager/src/main/java/org/torproject/android/service/wrapper/orbotLocalConstants.java b/orbotmanager/src/main/java/org/orbotproject/android/service/wrapper/orbotLocalConstants.java
similarity index 91%
rename from orbotmanager/src/main/java/org/torproject/android/service/wrapper/orbotLocalConstants.java
rename to orbotmanager/src/main/java/org/orbotproject/android/service/wrapper/orbotLocalConstants.java
index a6ef8b67..f642f614 100644
--- a/orbotmanager/src/main/java/org/torproject/android/service/wrapper/orbotLocalConstants.java
+++ b/orbotmanager/src/main/java/org/orbotproject/android/service/wrapper/orbotLocalConstants.java
@@ -1,4 +1,4 @@
-package org.torproject.android.service.wrapper;
+package org.orbotproject.android.service.wrapper;
import android.content.Context;
import android.content.Intent;