summaryrefslogtreecommitdiffhomepage
path: root/tunnel/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'tunnel/src/main')
-rw-r--r--tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java35
-rw-r--r--tunnel/src/main/proto/libwg.proto5
2 files changed, 36 insertions, 4 deletions
diff --git a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java
index 596bea7d..6afdfd95 100644
--- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java
+++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java
@@ -59,6 +59,9 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.Inet4Address;
import java.net.Inet6Address;
@@ -287,12 +290,38 @@ public final class GoBackend implements Backend {
return getState(tunnel);
}
- private int startHttpProxy(Uri pacFileUrl) {
+ private static String downloadPacFile(Network network, Uri pacFileUrl) {
+ HttpURLConnection urlConnection = null;
+ StringBuffer buf = new StringBuffer();
+ try {
+ URL url = new URL(pacFileUrl.toString());
+ urlConnection = (HttpURLConnection) network.openConnection(url);
+
+ InputStream in = urlConnection.getInputStream();
+ InputStreamReader isw = new InputStreamReader(in);
+
+ int data = isw.read();
+ while (data != -1) {
+ char current = (char) data;
+ data = isw.read();
+ buf.append(current);
+ }
+ } catch (Exception e) {
+ } finally {
+ if (urlConnection != null) {
+ urlConnection.disconnect();
+ }
+ }
+
+ return buf.toString();
+ }
+
+ private int startHttpProxy(String pacFile) {
LibwgGrpc.LibwgStub asyncStub = LibwgGrpc.newStub(channel);
LibwgGrpc.LibwgBlockingStub stub = LibwgGrpc.newBlockingStub(channel);
StartHttpProxyRequest.Builder reqBuilder = StartHttpProxyRequest.newBuilder();
- if (pacFileUrl != null && pacFileUrl != Uri.EMPTY) {
- reqBuilder.setPacFileUrl(pacFileUrl.toString());
+ if (pacFile != null && pacFile != "") {
+ reqBuilder.setPacFileContent(pacFile);
}
Thread streamer = new Thread(new Runnable() {
diff --git a/tunnel/src/main/proto/libwg.proto b/tunnel/src/main/proto/libwg.proto
index da6f6da4..c87eb9ef 100644
--- a/tunnel/src/main/proto/libwg.proto
+++ b/tunnel/src/main/proto/libwg.proto
@@ -50,7 +50,10 @@ message VersionResponse {
}
message StartHttpProxyRequest {
- string pacFileUrl = 1;
+ oneof pacFile {
+ string pacFileUrl = 1;
+ string pacFileContent = 2;
+ }
}
message StartHttpProxyResponse {