commit 74b9d2f57859031be38d168335f6397ca366fa7d Author: n8fr8 nathan@guardianproject.info Date: Mon Apr 5 15:33:04 2021 -0400
add configuration file for domain fronting --- .../android/ui/onboarding/MoatActivity.java | 10 +++-- orbotservice/src/main/assets/fronts | 4 ++ .../torproject/android/service/OrbotService.java | 43 +++++++++++++++++++++- 3 files changed, 52 insertions(+), 5 deletions(-)
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 756a9f5c..2bb0807e 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 @@ -36,6 +36,7 @@ import com.android.volley.DefaultRetryPolicy; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.Response; +import com.android.volley.toolbox.HurlStack; import com.android.volley.toolbox.JsonObjectRequest; import com.android.volley.toolbox.Volley;
@@ -151,6 +152,8 @@ public class MoatActivity extends AppCompatActivity implements View.OnClickListe
LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, new IntentFilter(TorServiceConstants.ACTION_STATUS)); + + OrbotService.loadCdnFronts(this); }
@Override @@ -184,9 +187,10 @@ public class MoatActivity extends AppCompatActivity implements View.OnClickListe IPtProxy.startObfs4Proxy("DEBUG", false, false);
ProxiedHurlStack phs = new ProxiedHurlStack("127.0.0.1", (int) IPtProxy.MeekSocksPort, - "url=https://onion.azureedge.net/;front=ajax.aspnetcdn.com", "\0"); + "url=" + OrbotService.getCdnFront(this,"moat-url") + + ";front=" + OrbotService.getCdnFront(this,"moat-front"), "\0");
- mQueue = Volley.newRequestQueue(MoatActivity.this, phs); + mQueue = Volley.newRequestQueue(this, phs);
if (mCaptcha == null) { new Handler(Looper.getMainLooper()).postDelayed(this::fetchCaptcha, 1000); @@ -416,7 +420,7 @@ public class MoatActivity extends AppCompatActivity implements View.OnClickListe
Log.d(MoatActivity.class.getSimpleName(), "Set up Volley queue. host=" + host + ", port=" + port);
- mQueue = Volley.newRequestQueue(this, new ProxiedHurlStack(host, port)); + // mQueue = Volley.newRequestQueue(this, new ProxiedHurlStack(host, port));
sendIntentToService(TorServiceConstants.CMD_SIGNAL_HUP);
diff --git a/orbotservice/src/main/assets/fronts b/orbotservice/src/main/assets/fronts new file mode 100644 index 00000000..57b500ec --- /dev/null +++ b/orbotservice/src/main/assets/fronts @@ -0,0 +1,4 @@ +snowflake https://d2kt284300pde7.cloudfront.net/ +moat-cdn https://d50gd378qj74g.cloudfront.net/ +moat-url https://moat.torproject.org.global.prod.fastly.net/ +moat-front cdn.sstatic.net \ No newline at end of file diff --git a/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java b/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java index 884e07dd..126f9e9a 100644 --- a/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java +++ b/orbotservice/src/main/java/org/torproject/android/service/OrbotService.java @@ -65,6 +65,8 @@ import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.net.Socket; +import java.net.URL; +import java.net.URLConnection; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -351,10 +353,45 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb return bridgeList.contains("snowflake"); }
+ private static HashMap<String,String> 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 = null; + while ((line = reader.readLine())!=null) + { + String[] front = line.split(" "); + + //add some code to test the connection here + + mFronts.put(front[0],front[1]); + + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public static String getCdnFront (Context context, String service) + { + + return mFronts.get(service); + } + + private void startSnowflakeClient() { //this is using the current, default Tor snowflake infrastructure - IPtProxy.startSnowflake("stun:stun.l.google.com:19302", "https://snowflake-broker.azureedge.net/", - "ajax.aspnetcdn.com", null, true, false, true, 3); + String front = getCdnFront(this,"snowflake"); + IPtProxy.startSnowflake("stun:stun.l.google.com:19302", front, + null, null, true, false, true, 3); }
/* @@ -502,6 +539,8 @@ public class OrbotService extends VpnService implements TorServiceConstants, Orb
mVpnManager = new OrbotVpnManager(this);
+ loadCdnFronts(this); + } catch (Exception e) { //what error here Log.e(OrbotConstants.TAG, "Error installing Orbot binaries", e);
tor-commits@lists.torproject.org