From a15768c58afdd52549420c000a1452ae835b90c1 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sun, 19 Dec 2021 02:33:12 +0100 Subject: ui,tunnel: add HTTP proxy setting to Go backend Only make the HTTP proxy settings visible on supported Android versions, i.e. Android 10 (AKA Android Q) and later. Signed-off-by: Mikael Magnusson --- tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tunnel/src/main/java/com/wireguard/android') 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 429cb1f1..242f81d8 100644 --- a/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java +++ b/tunnel/src/main/java/com/wireguard/android/backend/GoBackend.java @@ -7,6 +7,7 @@ package com.wireguard.android.backend; import android.content.Context; import android.content.Intent; +import android.net.ProxyInfo; import android.os.Build; import android.os.ParcelFileDescriptor; import android.system.OsConstants; @@ -24,6 +25,7 @@ import com.wireguard.crypto.KeyFormatException; import com.wireguard.util.NonNullForAll; import java.net.InetAddress; +import java.net.URL; import java.time.Instant; import java.util.Collections; import java.util.Set; @@ -318,6 +320,10 @@ public final class GoBackend implements Backend { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) service.setUnderlyingNetworks(null); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + config.getInterface().getHttpProxy().ifPresent(pi -> builder.setHttpProxy(pi.getProxyInfo())); + } + builder.setBlocking(true); try (final ParcelFileDescriptor tun = builder.establish()) { if (tun == null) -- cgit v1.2.3