/*
- * Copyright (C) 2012-2018 Tobias Brunner
+ * Copyright (C) 2012-2025 Tobias Brunner
* Copyright (C) 2012 Giuliano Grassi
* Copyright (C) 2012 Ralf Sager
*
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
+import android.net.ProxyInfo;
import android.net.VpnService;
import android.os.Build;
import android.os.Bundle;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.SortedSet;
private final List<InetAddress> mDnsServers = new ArrayList<>();
private int mMtu;
private boolean mIPv4Seen, mIPv6Seen, mDnsServersConfigured;
+ private ProxyInfo mProxyServer;
public BuilderCache(VpnProfile profile)
{
}
}
+ if (profile.getProxyHost() != null)
+ {
+ int port = profile.getProxyPort() != null ? profile.getProxyPort() : Constants.PROXY_PORT_DEFAULT;
+ List<String> exclusions = new ArrayList<>();
+ if (profile.getProxyExclusions() != null)
+ {
+ Collections.addAll(exclusions, profile.getProxyExclusions().split("\\s+"));
+ }
+ mProxyServer = ProxyInfo.buildDirectProxy(profile.getProxyHost(), port, exclusions);
+ }
+
/* set a default MTU, will be set by the daemon for regular interfaces */
Integer mtu = profile.getMTU();
mMtu = mtu == null ? Constants.MTU_MAX : mtu;
}
}
- public void applyData(VpnService.Builder builder)
+ public void applyData(Builder builder)
{
for (IPRange address : mAddresses)
{
break;
}
}
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && mProxyServer != null)
+ {
+ builder.setHttpProxy(mProxyServer);
+ }
builder.setMtu(mMtu);
}
/*
- * Copyright (C) 2016-2020 Tobias Brunner
+ * Copyright (C) 2016-2025 Tobias Brunner
*
* Copyright (C) secunet Security Networks AG
*
public static final int NAT_KEEPALIVE_MAX = 120;
public static final int NAT_KEEPALIVE_MIN = 10;
+ /**
+ * Default port for proxy servers
+ */
+ public static final int PROXY_PORT_DEFAULT = 8080;
+
/**
* Preference key for default VPN profile
*/