Skip to content
Snippets Groups Projects
0001-Bug-41361-Add-conjure-support.patch 3.61 KiB
Newer Older
From edf4337158df11da3b6ef6d30050e2441cfeafeb Mon Sep 17 00:00:00 2001
From: Cecylia Bocovich <cohosh@torproject.org>
Date: Thu, 13 Oct 2022 10:20:59 -0400
Subject: [PATCH] Bug 41361: Add conjure support

---
 android/build.gradle                           |  3 +++
 .../thali/toronionproxy/TorConfigBuilder.java  | 18 ++++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/android/build.gradle b/android/build.gradle
index 2392731..b1aca0a 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -96,6 +96,9 @@ task copyPluggableTransports(type: Copy) {
     rename { filename ->
         filename.replace 'snowflake-client', 'libSnowflake.so'
     }
+    rename { filename ->
+        filename.replace 'conjure-client', 'libConjure.so'
+    }
 }
 
 gradle.projectsEvaluated {
diff --git a/universal/src/main/java/com/msopentech/thali/toronionproxy/TorConfigBuilder.java b/universal/src/main/java/com/msopentech/thali/toronionproxy/TorConfigBuilder.java
index cc10783..c7e20c0 100644
--- a/universal/src/main/java/com/msopentech/thali/toronionproxy/TorConfigBuilder.java
+++ b/universal/src/main/java/com/msopentech/thali/toronionproxy/TorConfigBuilder.java
@@ -109,8 +109,8 @@ public final class TorConfigBuilder {
         return this;
     }
 
-    public TorConfigBuilder configurePluggableTransportsFromSettings(File pluggableTransportObfs, File pluggableTransportSnow) throws IOException {
-        if (pluggableTransportObfs == null  || pluggableTransportSnow == null) {
+    public TorConfigBuilder configurePluggableTransportsFromSettings(File pluggableTransportObfs, File pluggableTransportSnow, File pluggableTransportConjure) throws IOException {
+        if (pluggableTransportObfs == null  || pluggableTransportSnow == null || pluggableTransportConjure == null) {
             return this;
         }
 
@@ -124,6 +124,11 @@ public final class TorConfigBuilder {
                     .getCanonicalPath());
         }
 
+        if (!pluggableTransportConjure.exists()) {
+            throw new IOException("Conjure binary does not exist: " + pluggableTransportConjure
+                    .getCanonicalPath());
+        }
+
         if (!pluggableTransportObfs.canExecute()) {
             throw new IOException("Obfs4proxy binary is not executable: " + pluggableTransportObfs
                     .getCanonicalPath());
@@ -134,8 +139,12 @@ public final class TorConfigBuilder {
                     .getCanonicalPath());
         }
 
+        if (!pluggableTransportConjure.canExecute()) {
+            throw new IOException("Conjure binary is not executable: " + pluggableTransportConjure
+                    .getCanonicalPath());
+        }
 
-        transportPlugin(pluggableTransportObfs.getCanonicalPath(), pluggableTransportSnow.getCanonicalPath());
+        transportPlugin(pluggableTransportObfs.getCanonicalPath(), pluggableTransportSnow.getCanonicalPath(), pluggableTransportConjure.getCanonicalPath());
         return this;
     }
 
@@ -502,9 +511,10 @@ public final class TorConfigBuilder {
         return transPort(settings.transPort());
     }
 
-    public TorConfigBuilder transportPlugin(String obfsPath, String snowPath) {
+    public TorConfigBuilder transportPlugin(String obfsPath, String snowPath, String conjurePath) {
         buffer.append("ClientTransportPlugin meek_lite,obfs3,obfs4 exec ").append(obfsPath).append('\n');
         buffer.append("ClientTransportPlugin snowflake exec ").append(snowPath).append('\n');
+        buffer.append("ClientTransportPlugin conjure exec ").append(conjurePath).append(" -registerURL https://registration.refraction.network/api\n");
         return this;
     }
 
-- 
2.37.2