From 2721445cee042de1ece410c2d7cc417d828444ed Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sun, 10 May 2015 12:27:51 -0400 Subject: [PATCH] more work on proxies --- app/src/processing/app/Preferences.java | 53 ++++++++++++++++++------- build/shared/lib/defaults.txt | 25 ++++++------ 2 files changed, 51 insertions(+), 27 deletions(-) diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 679edd711..8d1394cb3 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -141,29 +141,54 @@ public class Preferences { PApplet.useNativeSelect = Preferences.getBoolean("chooser.files.native"); //$NON-NLS-1$ - // So that the system proxy setting are used by default + // Use the system proxy settings by default // https://github.com/processing/processing/issues/2643 System.setProperty("java.net.useSystemProxies", "true"); - // Set http proxy for folks that require it. + // Set HTTP, HTTPS, and SOCKS proxies for individuals + // who want/need to override the system setting // http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html - String proxyHost = get("proxy.host"); - String proxyPort = get("proxy.port"); - if (proxyHost != null && proxyHost.length() != 0 && - proxyPort != null && proxyPort.length() != 0) { - System.setProperty("http.proxyHost", proxyHost); - System.setProperty("http.proxyPort", proxyPort); - } + // Less readable version with the Oracle style sheet: + // http://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html + handleProxy("http", "http.proxyHost", "http.proxyPort"); + handleProxy("https", "https.proxyHost", "https.proxyPort"); + handleProxy("socks", "socksProxyHost", "socksProxyPort"); - // Set socks proxy for folks that require it. - // http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html - String socksProxyHost = get("socksProxy.host"); - String socksProxyPort = get("socksProxy.port"); + /* + String httpProxyHost = get("proxy.http.host"); + String httpProxyPort = get("proxy.http.port"); + if (httpProxyHost != null && httpProxyHost.length() != 0 && + httpProxyPort != null && httpProxyPort.length() != 0) { + System.setProperty("http.proxyHost", httpProxyHost); + System.setProperty("http.proxyPort", httpProxyPort); + } + String httpsProxyHost = get("proxy.https.host"); + String httpsProxyPort = get("proxy.https.port"); + if (httpsProxyHost != null && httpsProxyHost.length() != 0 && + httpsProxyPort != null && httpsProxyPort.length() != 0) { + System.setProperty("https.proxyHost", httpsProxyHost); + System.setProperty("https.proxyPort", httpsProxyPort); + } + String socksProxyHost = get("proxy.socks.host"); + String socksProxyPort = get("proxy.socks.port"); if (socksProxyHost != null && socksProxyHost.length() != 0 && - socksProxyPort != null && socksProxyPort.length() != 0) { + socksProxyPort != null && socksProxyPort.length() != 0) { System.setProperty("socksProxyHost", socksProxyHost); System.setProperty("socksProxyPort", socksProxyPort); } + */ + } + + + static void handleProxy(String protocol, String hostProp, String portProp) { + String proxyHost = get("proxy." + protocol + ".host"); + String proxyPort = get("proxy." + protocol + ".port"); + if (proxyHost != null && proxyHost.length() != 0 && + proxyPort != null && proxyPort.length() != 0) { + System.setProperty(hostProp, proxyHost); + System.setProperty(portProp, proxyPort); + } + } diff --git a/build/shared/lib/defaults.txt b/build/shared/lib/defaults.txt index 5c58c69c7..015201a03 100644 --- a/build/shared/lib/defaults.txt +++ b/build/shared/lib/defaults.txt @@ -319,21 +319,20 @@ run.present.stop.color = #cccccc # use this by default to hide the menu bar and dock on osx #run.present.exclusive.macosx = true -# HTTP PROXY +# PROXIES # Set a proxy server for folks that require it. This will allow the update # checker and the contrib manager to run properly in those environments. -#proxy.host=proxy.example.com -#proxy.port=8080 -proxy.host= -proxy.port= - -# SOCKS PROXY -# Set a proxy server for folks that require it. This will allow the update -# checker and the contrib manager to run properly in those environments. -#socksProxy.host=proxy.example.com -#socksProxy.port=9150 -socksProxy.host= -socksProxy.port= +# This changed from proxy.host and proxy.port to proxy.http.host and +# proxy.http.port in 3.0a8. In addition, https and socks were added. +proxy.http.host= +proxy.http.port= +proxy.https.host= +proxy.https.port= +proxy.socks.host= +proxy.socks.port= +# Example of usage (replace 'http' with 'https' or 'socks' as needed) +#proxy.http.host=proxy.example.com +#proxy.http.port=8080 # PDE X pdex.autoSave.autoSaveByDefault=true