[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [orbot/master] Issue #370: Added testing code to directly use meek_lite as proxy to talk to MOAT's meek endpoint. Nonfunctional.



commit d9861e90b793af71a1ec9b6938650961b3e3b6db
Author: Benjamin Erhart <berhart@xxxxxxxxxxxxxxxxxxx>
Date:   Tue Aug 25 16:48:47 2020 +0200

    Issue #370: Added testing code to directly use meek_lite as proxy to talk to MOAT's meek endpoint. Nonfunctional.
---
 app/build.gradle                                   |  3 ++
 .../android/ui/onboarding/MoatActivity.java        | 53 +++++++++++++++++++++-
 .../android/ui/onboarding/ProxiedHurlStack.java    | 32 +++++++++++++
 3 files changed, 87 insertions(+), 1 deletion(-)

diff --git a/app/build.gradle b/app/build.gradle
index 52ffaa64..55d331c1 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -128,6 +128,9 @@ dependencies {
     androidTestImplementation "tools.fastlane:screengrab:1.2.0"
     implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
     implementation 'com.android.volley:volley:1.1.1'
+    implementation 'info.pluggabletransports.aptds:apt-dispatch-library:1.0.9'
+    implementation 'info.pluggabletransports.aptds:apt-meek-obfs4-legacy:1.0.9'
+    implementation 'info.pluggabletransports.aptds:goptbundle:1.0.0'
 }
 
 // Map for the version code that gives each ABI a value.
diff --git a/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java b/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java
index 588c6952..44c86c2c 100644
--- a/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java
@@ -9,6 +9,7 @@ import android.content.Intent;
 import android.content.IntentFilter;
 import android.graphics.BitmapFactory;
 import android.os.Bundle;
+import android.os.Handler;
 import android.text.TextUtils;
 import android.util.Base64;
 import android.util.Log;
@@ -46,6 +47,15 @@ import org.torproject.android.service.TorServiceConstants;
 import org.torproject.android.service.util.Prefs;
 import org.torproject.android.ui.dialog.MoatErrorDialogFragment;
 
+import java.util.ArrayList;
+import java.util.Properties;
+
+import goptbundle.Goptbundle;
+import info.pluggabletransports.dispatch.DispatchConstants;
+import info.pluggabletransports.dispatch.Dispatcher;
+import info.pluggabletransports.dispatch.Transport;
+import info.pluggabletransports.dispatch.transports.legacy.MeekTransport;
+
 /**
  Implements the MOAT protocol: Fetches OBFS4 bridges via Meek Azure.
 
@@ -170,7 +180,48 @@ public class MoatActivity extends AppCompatActivity implements View.OnClickListe
     protected void onResume() {
         super.onResume();
 
-        sendIntentToService(TorServiceConstants.ACTION_STATUS);
+        new MeekTransport().register();
+
+        Properties options = new Properties();
+        options.put(MeekTransport.OPTION_URL, "https://onion.azureedge.net/";);
+        options.put(MeekTransport.OPTION_FRONT, "ajax.aspnetcdn.com");
+
+        Transport transport = Dispatcher.get().getTransport(this, DispatchConstants.PT_TRANSPORTS_MEEK, options);
+
+        if (transport != null) {
+            new Thread(() -> {
+                Goptbundle.setenv(DispatchConstants.TOR_PT_LOG_LEVEL, "DEBUG");
+                Goptbundle.setenv(DispatchConstants.TOR_PT_CLIENT_TRANSPORTS, DispatchConstants.PT_TRANSPORTS_MEEK);
+                Goptbundle.setenv(DispatchConstants.TOR_PT_MANAGED_TRANSPORT_VER, "1");
+                Goptbundle.setenv(DispatchConstants.TOR_PT_EXIT_ON_STDIN_CLOSE, "0");
+                Goptbundle.load(getDir("pt-state", Context.MODE_PRIVATE).getAbsolutePath());
+            }).start();
+
+            ArrayList<String> args = new ArrayList<>();
+
+            for (Object key : options.keySet()) {
+                String k = (String) key;
+
+                args.add(String.format("%s=%s", k, options.getProperty(k)));
+            }
+
+            StringBuilder sb = new StringBuilder();
+
+            for (String arg : args) {
+                sb.append(arg).append(";");
+            }
+
+            ProxiedHurlStack phs = new ProxiedHurlStack("127.0.0.1", 47352,
+                    sb.toString(), "\0");
+
+            mQueue = Volley.newRequestQueue(MoatActivity.this, phs);
+
+            if (mCaptcha == null) {
+                new Handler().postDelayed(this::fetchCaptcha, 1000);
+            }
+        }
+
+//        sendIntentToService(TorServiceConstants.ACTION_STATUS);
     }
 
     @Override
diff --git a/app/src/main/java/org/torproject/android/ui/onboarding/ProxiedHurlStack.java b/app/src/main/java/org/torproject/android/ui/onboarding/ProxiedHurlStack.java
index e3bdb86a..06352b58 100644
--- a/app/src/main/java/org/torproject/android/ui/onboarding/ProxiedHurlStack.java
+++ b/app/src/main/java/org/torproject/android/ui/onboarding/ProxiedHurlStack.java
@@ -2,11 +2,15 @@
 /* See LICENSE for licensing information */
 package org.torproject.android.ui.onboarding;
 
+import android.util.Log;
+
 import com.android.volley.toolbox.HurlStack;
 
 import java.io.IOException;
+import java.net.Authenticator;
 import java.net.HttpURLConnection;
 import java.net.InetSocketAddress;
+import java.net.PasswordAuthentication;
 import java.net.Proxy;
 import java.net.URL;
 
@@ -15,12 +19,25 @@ public class ProxiedHurlStack extends HurlStack {
 
     private final String mHost;
     private final int mPort;
+    private final String mUsername;
+    private final String mPassword;
 
     public ProxiedHurlStack(String host, int port) {
         super();
 
         mHost = host;
         mPort = port;
+        mUsername = null;
+        mPassword = null;
+    }
+
+    public ProxiedHurlStack(String host, int port, String username, String password) {
+        super();
+
+        mHost = host;
+        mPort = port;
+        mUsername = username;
+        mPassword = password;
     }
 
     @Override
@@ -28,6 +45,21 @@ public class ProxiedHurlStack extends HurlStack {
         Proxy proxy = new Proxy(Proxy.Type.SOCKS,
                 InetSocketAddress.createUnresolved(mHost, mPort));
 
+        if (mUsername != null && mPassword != null) {
+            Log.d(getClass().getSimpleName(), String.format("mHost=%s, mPort=%d, mUsername=%s, mPassword=%s", mHost, mPort, mUsername, mPassword));
+
+            Authenticator authenticator = new Authenticator() {
+                @Override
+                protected PasswordAuthentication getPasswordAuthentication() {
+                    Log.d(getClass().getSimpleName(), "getPasswordAuthentication!");
+
+                    return new PasswordAuthentication(mUsername, mPassword.toCharArray());
+                }
+            };
+
+            Authenticator.setDefault(authenticator);
+        }
+
         return (HttpURLConnection) url.openConnection(proxy);
     }
 }



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits