diff options
author | Mat Booth | 2022-01-05 10:44:39 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2022-01-11 18:54:42 +0000 |
commit | df185ade5923925a6c118ba017dffa8929df53e0 (patch) | |
tree | 61478c9394cd37f828844dce2a4710ef32e5974c | |
parent | 49af00b2d7faeeb83319378ee7dd589e9d5e0a4a (diff) | |
download | eclipse.platform.team-df185ade5923925a6c118ba017dffa8929df53e0.tar.gz eclipse.platform.team-df185ade5923925a6c118ba017dffa8929df53e0.tar.xz eclipse.platform.team-df185ade5923925a6c118ba017dffa8929df53e0.zip |
Bug 578053 - Gnome proxy support does not work with default gsettingsY20220120-0600Y20220119-0600Y20220118-0600Y20220117-0600Y20220116-0600Y20220115-0600Y20220114-0600Y20220113-0900Y20220113-0600Y20220112-0630Y20220112-0600I20220120-1800I20220120-0720I20220120-0220I20220119-1800I20220119-1440I20220119-1320I20220119-0540I20220118-1800I20220117-1800I20220116-1800I20220115-1800I20220114-1800I20220113-1800I20220112-1800I20220112-0210I20220111-2130I20220111-1910I20220111-1800
Fixes some problems with proxy configuration from gsettings:
* Avoid querying deprecated/unused keys:
org.gnome.system.proxy/use-same-proxy
org.gnome.system.proxy.http/enabled
* Honour enablement of all proxy types by always checking the presence
of host name and valid port number
* Avoid populating manual "no proxy" list when the system proxy mode is
not set to manual
Signed-off-by: Mat Booth <mat.booth@gmail.com>
Change-Id: Iccb7ad5f04b27479e97028e50541479ee97dfe9f
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.team/+/189301
Tested-by: Platform Bot <platform-bot@eclipse.org>
Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
3 files changed, 47 insertions, 36 deletions
diff --git a/bundles/org.eclipse.core.net.linux/META-INF/MANIFEST.MF b/bundles/org.eclipse.core.net.linux/META-INF/MANIFEST.MF index 749024a1a..1daa675a7 100644 --- a/bundles/org.eclipse.core.net.linux/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.core.net.linux/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-Name: %fragmentName Bundle-Vendor: %providerName Bundle-Localization: fragment Bundle-SymbolicName: org.eclipse.core.net.linux;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 1.0.100.qualifier Fragment-Host: org.eclipse.core.net;bundle-version="1.1.0" Eclipse-PlatformFilter: (osgi.os=linux) Bundle-RequiredExecutionEnvironment: JavaSE-11 diff --git a/bundles/org.eclipse.core.net.linux/pom.xml b/bundles/org.eclipse.core.net.linux/pom.xml index 29baca1c6..394295db6 100644 --- a/bundles/org.eclipse.core.net.linux/pom.xml +++ b/bundles/org.eclipse.core.net.linux/pom.xml @@ -20,7 +20,7 @@ </parent> <groupId>org.eclipse.core</groupId> <artifactId>org.eclipse.core.net.linux</artifactId> - <version>1.0.0-SNAPSHOT</version> + <version>1.0.100-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> <properties> diff --git a/bundles/org.eclipse.core.net.linux/src/org/eclipse/core/net/ProxyProvider.java b/bundles/org.eclipse.core.net.linux/src/org/eclipse/core/net/ProxyProvider.java index e9e499270..c2993586c 100644 --- a/bundles/org.eclipse.core.net.linux/src/org/eclipse/core/net/ProxyProvider.java +++ b/bundles/org.eclipse.core.net.linux/src/org/eclipse/core/net/ProxyProvider.java @@ -300,35 +300,8 @@ public class ProxyProvider extends AbstractProxyProvider { initializeSettings(); } - ProxyData proxyData = new ProxyData(protocol); - boolean useSame = fLibGio.g_settings_get_boolean(proxySettings, "use-same-proxy"); //$NON-NLS-1$ - - if (protocol.equalsIgnoreCase("http") || useSame) { //$NON-NLS-1$ - boolean useProxy = fLibGio.g_settings_get_boolean(httpProxySettings, "enabled"); //$NON-NLS-1$ - if (!useProxy) { - return null; - } - Pointer host = fLibGio.g_settings_get_string(httpProxySettings, "host"); //$NON-NLS-1$ - proxyData.setHost(host.getString(0)); - fLibGio.g_free(host); - - int port = fLibGio.g_settings_get_int(httpProxySettings, "port"); //$NON-NLS-1$ - proxyData.setPort(port); - - boolean reqAuth = fLibGio.g_settings_get_boolean(httpProxySettings, "use-authentication"); //$NON-NLS-1$ - if (reqAuth) { - Pointer user = fLibGio.g_settings_get_string(httpProxySettings, "authentication-user"); //$NON-NLS-1$ - proxyData.setUserid(user.getString(0)); - fLibGio.g_free(user); - - Pointer password = fLibGio.g_settings_get_string(httpProxySettings, "authentication-password"); //$NON-NLS-1$ - proxyData.setPassword(password.getString(0)); - fLibGio.g_free(password); - } - return proxyData; - } - // Everything else applies only if the system proxy mode is manual + // Auto-configuration is not supported Pointer mode = fLibGio.g_settings_get_string(proxySettings, "mode"); //$NON-NLS-1$ if (!mode.getString(0).equalsIgnoreCase("manual")) { //$NON-NLS-1$ fLibGio.g_free(mode); @@ -339,23 +312,52 @@ public class ProxyProvider extends AbstractProxyProvider { Pointer host; int port; - if (protocol.equalsIgnoreCase("https")) { //$NON-NLS-1$ + switch (protocol.toLowerCase()) { + case "http": //$NON-NLS-1$ + host = fLibGio.g_settings_get_string(httpProxySettings, "host"); //$NON-NLS-1$ + port = fLibGio.g_settings_get_int(httpProxySettings, "port"); //$NON-NLS-1$ + break; + case "https": //$NON-NLS-1$ host = fLibGio.g_settings_get_string(httpsProxySettings, "host"); //$NON-NLS-1$ port = fLibGio.g_settings_get_int(httpsProxySettings, "port"); //$NON-NLS-1$ - } else if (protocol.equalsIgnoreCase("socks")) { //$NON-NLS-1$ - host = fLibGio.g_settings_get_string(socksProxySettings, "host"); //$NON-NLS-1$ - port = fLibGio.g_settings_get_int(socksProxySettings, "port"); //$NON-NLS-1$ - } else if (protocol.equalsIgnoreCase("ftp")) { //$NON-NLS-1$ + break; + case "ftp": //$NON-NLS-1$ host = fLibGio.g_settings_get_string(ftpProxySettings, "host"); //$NON-NLS-1$ port = fLibGio.g_settings_get_int(ftpProxySettings, "port"); //$NON-NLS-1$ - } else { + break; + case "socks": //$NON-NLS-1$ + host = fLibGio.g_settings_get_string(socksProxySettings, "host"); //$NON-NLS-1$ + port = fLibGio.g_settings_get_int(socksProxySettings, "port"); //$NON-NLS-1$ + break; + default: + // Unknown/invalid proxy type return null; } + ProxyData proxyData = new ProxyData(protocol); proxyData.setHost(host.getString(0)); fLibGio.g_free(host); proxyData.setPort(port); + // Each proxy type is enabled only if the "host" key is non-empty and its "port" key is non-0 + if (proxyData.getHost() == null || proxyData.getPort() == 0) { + return null; + } + + if (protocol.equalsIgnoreCase("http")) { //$NON-NLS-1$ + // Authentication applies only to http proxies + boolean reqAuth = fLibGio.g_settings_get_boolean(httpProxySettings, "use-authentication"); //$NON-NLS-1$ + if (reqAuth) { + Pointer user = fLibGio.g_settings_get_string(httpProxySettings, "authentication-user"); //$NON-NLS-1$ + proxyData.setUserid(user.getString(0)); + fLibGio.g_free(user); + + Pointer password = fLibGio.g_settings_get_string(httpProxySettings, "authentication-password"); //$NON-NLS-1$ + proxyData.setPassword(password.getString(0)); + fLibGio.g_free(password); + } + } + return proxyData; } @@ -364,6 +366,15 @@ public class ProxyProvider extends AbstractProxyProvider { initializeSettings(); } + // Everything else applies only if the system proxy mode is manual + // Auto-configuration is not supported + Pointer mode = fLibGio.g_settings_get_string(proxySettings, "mode"); //$NON-NLS-1$ + if (!mode.getString(0).equalsIgnoreCase("manual")) { //$NON-NLS-1$ + fLibGio.g_free(mode); + return null; + } + fLibGio.g_free(mode); + PointerByReference npHostsArray = fLibGio.g_settings_get_strv(proxySettings, "ignore-hosts"); //$NON-NLS-1$ String[] npHosts = npHostsArray.getPointer().getStringArray(0); |