From 54c88e18e8d76e6d14251e8690ae509b8572c8e9 Mon Sep 17 00:00:00 2001 From: s3b- Date: Wed, 11 Mar 2020 10:23:57 +0100 Subject: [PATCH] fixed issue #74 --- .../markusbernhardt/proxy/ProxySearch.java | 4 ++-- .../proxy/jna/win/WTypes2.java | 2 +- .../proxy/jna/win/WinHttpHelpers.java | 2 +- .../firefox/FirefoxProxySearchStrategy.java | 11 ++++----- .../browser/firefox/FirefoxSettingParser.java | 4 +--- .../browser/ie/IEProxySearchStrategy.java | 3 +-- .../gnome/GnomeDConfProxySearchStrategy.java | 24 +++++++++---------- .../gnome/GnomeProxySearchStrategy.java | 19 +++++++-------- .../desktop/kde/KdeProxySearchStrategy.java | 13 +++++----- .../search/desktop/kde/KdeSettingsParser.java | 3 +-- .../desktop/osx/OsxProxySearchStrategy.java | 7 +++--- .../win/CommonWindowsSearchStrategy.java | 5 ++-- .../desktop/win/WinProxySearchStrategy.java | 2 +- .../search/env/EnvProxySearchStrategy.java | 8 +++---- .../search/java/JavaProxySearchStrategy.java | 4 ++-- .../search/wpad/WpadProxySearchStrategy.java | 4 ++-- .../wpad/WpadProxySearchStrategyWithDHPC.java | 4 ++-- .../proxy/selector/pac/PacScriptMethods.java | 10 ++++---- .../selector/pac/UrlPacScriptSource.java | 6 ++--- .../proxy/util/PlatformUtil.java | 10 ++++---- .../markusbernhardt/proxy/util/ProxyUtil.java | 2 +- 21 files changed, 67 insertions(+), 80 deletions(-) diff --git a/src/main/java/com/github/markusbernhardt/proxy/ProxySearch.java b/src/main/java/com/github/markusbernhardt/proxy/ProxySearch.java index 610a473..12c40fd 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/ProxySearch.java +++ b/src/main/java/com/github/markusbernhardt/proxy/ProxySearch.java @@ -119,7 +119,7 @@ public static ProxySearch getDefaultProxySearch() { s.addStrategy(Strategy.OS_DEFAULT); s.addStrategy(Strategy.ENV_VAR); } - Logger.log(ProxySearch.class, LogLevel.TRACE, "Using default search priority: {0}", s); + Logger.log(ProxySearch.class, LogLevel.TRACE, "Using default search priority: {}", s); return s; } @@ -230,7 +230,7 @@ public ProxySelector getProxySelector() { "No proxy found for " + strat.getName() + ". Trying next one."); } } catch (ProxyException e) { - Logger.log(getClass(), LogLevel.DEBUG, "Strategy {0} failed trying next one.", e); + Logger.log(getClass(), LogLevel.DEBUG, "Strategy {} failed trying next one.", e); // Ignore and try next strategy. } } diff --git a/src/main/java/com/github/markusbernhardt/proxy/jna/win/WTypes2.java b/src/main/java/com/github/markusbernhardt/proxy/jna/win/WTypes2.java index 87cdd29..556deb4 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/jna/win/WTypes2.java +++ b/src/main/java/com/github/markusbernhardt/proxy/jna/win/WTypes2.java @@ -91,7 +91,7 @@ protected void finalize() throws Throwable { // happen. If it really does happen, there isn't much we // can do about it other than logging it. Logger.log(getClass(), Logger.LogLevel.ERROR, - "Windows function GlobalFree failed while freeing memory for {0} object", + "Windows function GlobalFree failed while freeing memory for {} object", getClass().getSimpleName()); } } diff --git a/src/main/java/com/github/markusbernhardt/proxy/jna/win/WinHttpHelpers.java b/src/main/java/com/github/markusbernhardt/proxy/jna/win/WinHttpHelpers.java index fd4f79f..671dee0 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/jna/win/WinHttpHelpers.java +++ b/src/main/java/com/github/markusbernhardt/proxy/jna/win/WinHttpHelpers.java @@ -44,7 +44,7 @@ public static String detectAutoProxyConfigUrl(WinDef.DWORD dwAutoDetectFlags) { // Something more serious is wrong. There isn't much we can do // about it but at least we would like to log it. Logger.log(WinHttpHelpers.class, Logger.LogLevel.ERROR, - "Windows function WinHttpDetectAutoProxyConfigUrl returned error : {0}", ex.getMessage()); + "Windows function WinHttpDetectAutoProxyConfigUrl returned error : {}", ex.getMessage()); return null; } if (result) { diff --git a/src/main/java/com/github/markusbernhardt/proxy/search/browser/firefox/FirefoxProxySearchStrategy.java b/src/main/java/com/github/markusbernhardt/proxy/search/browser/firefox/FirefoxProxySearchStrategy.java index ac79aff..7856803 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/search/browser/firefox/FirefoxProxySearchStrategy.java +++ b/src/main/java/com/github/markusbernhardt/proxy/search/browser/firefox/FirefoxProxySearchStrategy.java @@ -3,7 +3,6 @@ import java.io.IOException; import java.net.ProxySelector; import java.util.Properties; - import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.search.desktop.DesktopProxySearchStrategy; import com.github.markusbernhardt.proxy.search.wpad.WpadProxySearchStrategy; @@ -122,7 +121,7 @@ public ProxySelector getProxySelector() throws ProxyException { break; case 2: // PAC Script String pacScriptUrl = settings.getProperty("network.proxy.autoconfig_url", ""); - Logger.log(getClass(), LogLevel.TRACE, "Firefox uses script (PAC) {0}", pacScriptUrl); + Logger.log(getClass(), LogLevel.TRACE, "Firefox uses script (PAC) {}", pacScriptUrl); result = ProxyUtil.buildPacSelectorForUrl(pacScriptUrl); break; case 3: // Backward compatibility to netscape. @@ -140,7 +139,7 @@ public ProxySelector getProxySelector() throws ProxyException { // Wrap in white list filter. String noProxyList = settings.getProperty("network.proxy.no_proxies_on", null); if (result != null && noProxyList != null && noProxyList.trim().length() > 0) { - Logger.log(getClass(), LogLevel.TRACE, "Firefox uses proxy bypass list for: {0}", noProxyList); + Logger.log(getClass(), LogLevel.TRACE, "Firefox uses proxy bypass list for: {}", noProxyList); result = new ProxyBypassListSelector(noProxyList, result); } @@ -250,7 +249,7 @@ private void installSocksProxy(ProtocolDispatchSelector ps, Properties settings) String proxyHost = settings.getProperty("network.proxy.socks", null); int proxyPort = Integer.parseInt(settings.getProperty("network.proxy.socks_port", "0")); if (proxyHost != null && proxyPort != 0) { - Logger.log(getClass(), LogLevel.TRACE, "Firefox socks proxy is {0}:{1}", proxyHost, proxyPort); + Logger.log(getClass(), LogLevel.TRACE, "Firefox socks proxy is {}:{}", proxyHost, proxyPort); ps.setSelector("socks", new FixedSocksSelector(proxyHost, proxyPort)); } } @@ -265,7 +264,7 @@ private void installSecureProxy(ProtocolDispatchSelector ps, Properties settings String proxyHost = settings.getProperty("network.proxy.ssl", null); int proxyPort = Integer.parseInt(settings.getProperty("network.proxy.ssl_port", "0")); if (proxyHost != null && proxyPort != 0) { - Logger.log(getClass(), LogLevel.TRACE, "Firefox secure proxy is {0}:{1}", proxyHost, proxyPort); + Logger.log(getClass(), LogLevel.TRACE, "Firefox secure proxy is {}:{}", proxyHost, proxyPort); ps.setSelector("https", new FixedProxySelector(proxyHost, proxyPort)); ps.setSelector("sftp", new FixedProxySelector(proxyHost, proxyPort)); } @@ -290,7 +289,7 @@ private void installSelectorForProtocol(ProtocolDispatchSelector ps, Properties String proxyHost = settings.getProperty("network.proxy." + protocol, null); int proxyPort = Integer.parseInt(settings.getProperty("network.proxy." + protocol + "_port", "0")); if (proxyHost != null && proxyPort != 0) { - Logger.log(getClass(), LogLevel.TRACE, "Firefox " + protocol + " proxy is {0}:{1}", proxyHost, proxyPort); + Logger.log(getClass(), LogLevel.TRACE, "Firefox " + protocol + " proxy is {}:{}", proxyHost, proxyPort); ps.setSelector(protocol, new FixedProxySelector(proxyHost, proxyPort)); } } diff --git a/src/main/java/com/github/markusbernhardt/proxy/search/browser/firefox/FirefoxSettingParser.java b/src/main/java/com/github/markusbernhardt/proxy/search/browser/firefox/FirefoxSettingParser.java index 5bef76b..1c96d33 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/search/browser/firefox/FirefoxSettingParser.java +++ b/src/main/java/com/github/markusbernhardt/proxy/search/browser/firefox/FirefoxSettingParser.java @@ -7,10 +7,8 @@ import java.io.InputStreamReader; import java.util.Map.Entry; import java.util.Properties; - import org.ini4j.Ini; import org.ini4j.Profile.Section; - import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; @@ -60,7 +58,7 @@ public Properties parseSettings(FirefoxProfileSource source) throws IOException } } if (profileFolder != null) { - Logger.log(getClass(), LogLevel.DEBUG, "Firefox settings folder is {0}", profileFolder); + Logger.log(getClass(), LogLevel.DEBUG, "Firefox settings folder is {}", profileFolder); } else { Logger.log(getClass(), LogLevel.DEBUG, "Firefox settings folder not found!"); } diff --git a/src/main/java/com/github/markusbernhardt/proxy/search/browser/ie/IEProxySearchStrategy.java b/src/main/java/com/github/markusbernhardt/proxy/search/browser/ie/IEProxySearchStrategy.java index 64fa07f..aadc21d 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/search/browser/ie/IEProxySearchStrategy.java +++ b/src/main/java/com/github/markusbernhardt/proxy/search/browser/ie/IEProxySearchStrategy.java @@ -2,7 +2,6 @@ import java.net.ProxySelector; import java.util.Properties; - import com.github.markusbernhardt.proxy.jna.win.WinHttp; import com.github.markusbernhardt.proxy.jna.win.WinHttpCurrentUserIEProxyConfig; import com.github.markusbernhardt.proxy.jna.win.WinHttpHelpers; @@ -133,7 +132,7 @@ private ProxySelector createFixedProxySelector(IEProxyConfig ieProxyConfig) thro if (proxyString == null) { return null; } - Logger.log(getClass(), LogLevel.TRACE, "IE uses manual settings: {0} with bypass list: {1}", proxyString, + Logger.log(getClass(), LogLevel.TRACE, "IE uses manual settings: {} with bypass list: {}", proxyString, bypassList); Properties p = parseProxyList(proxyString); diff --git a/src/main/java/com/github/markusbernhardt/proxy/search/desktop/gnome/GnomeDConfProxySearchStrategy.java b/src/main/java/com/github/markusbernhardt/proxy/search/desktop/gnome/GnomeDConfProxySearchStrategy.java index 109f65f..1fe35ea 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/search/desktop/gnome/GnomeDConfProxySearchStrategy.java +++ b/src/main/java/com/github/markusbernhardt/proxy/search/desktop/gnome/GnomeDConfProxySearchStrategy.java @@ -1,21 +1,19 @@ package com.github.markusbernhardt.proxy.search.desktop.gnome; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; import java.net.ProxySelector; import java.util.Properties; - import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.selector.direct.NoProxySelector; import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector; import com.github.markusbernhardt.proxy.selector.misc.ProtocolDispatchSelector; import com.github.markusbernhardt.proxy.selector.whitelist.ProxyBypassListSelector; import com.github.markusbernhardt.proxy.util.Logger; +import com.github.markusbernhardt.proxy.util.Logger.LogLevel; import com.github.markusbernhardt.proxy.util.ProxyException; import com.github.markusbernhardt.proxy.util.ProxyUtil; -import com.github.markusbernhardt.proxy.util.Logger.LogLevel; - -import java.io.BufferedReader; -import java.io.InputStreamReader; /***************************************************************************** * Loads the Gnome proxy settings from the Gnome GConf settings. @@ -94,7 +92,7 @@ public ProxySelector getProxySelector() throws ProxyException { Properties settings = readSettings(); String type = settings.getProperty("org.gnome.system.proxy mode"); - Logger.log(getClass(), LogLevel.TRACE, "Mode is :{0}", type); + Logger.log(getClass(), LogLevel.TRACE, "Mode is :{}", type); ProxySelector result = null; if (type == null) { String useProxy = settings.getProperty("org.gnome.system.proxy.http enabled"); @@ -114,14 +112,14 @@ public ProxySelector getProxySelector() throws ProxyException { } if ("auto".equals(type)) { String pacScriptUrl = settings.getProperty("org.gnome.system.proxy autoconfig-url", ""); - Logger.log(getClass(), LogLevel.TRACE, "Gnome uses autodetect script {0}", pacScriptUrl); + Logger.log(getClass(), LogLevel.TRACE, "Gnome uses autodetect script {}", pacScriptUrl); result = ProxyUtil.buildPacSelectorForUrl(pacScriptUrl); } // Wrap into white-list filter? String noProxyList = settings.getProperty("org.gnome.system.proxy ignore-hosts", null); if (result != null && noProxyList != null && noProxyList.trim().length() > 0) { - Logger.log(getClass(), LogLevel.TRACE, "Gnome uses proxy bypass list: {0}", noProxyList); + Logger.log(getClass(), LogLevel.TRACE, "Gnome uses proxy bypass list: {}", noProxyList); result = new ProxyBypassListSelector(noProxyList, result); } @@ -222,7 +220,7 @@ private void installHttpSelector(Properties settings, ProtocolDispatchSelector p String proxyHost = settings.getProperty("org.gnome.system.proxy.http host", null); int proxyPort = Integer.parseInt(settings.getProperty("org.gnome.system.proxy.http port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { - Logger.log(getClass(), LogLevel.TRACE, "Gnome http proxy is {0}:{1}", proxyHost, proxyPort); + Logger.log(getClass(), LogLevel.TRACE, "Gnome http proxy is {}:{}", proxyHost, proxyPort); ps.setSelector("http", new FixedProxySelector(proxyHost.trim(), proxyPort)); } } @@ -241,7 +239,7 @@ private void installSocksSelector(Properties settings, ProtocolDispatchSelector String proxyHost = settings.getProperty("org.gnome.system.proxy.socks host", null); int proxyPort = Integer.parseInt(settings.getProperty("org.gnome.system.proxy.socks port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { - Logger.log(getClass(), LogLevel.TRACE, "Gnome socks proxy is {0}:{1}", proxyHost, proxyPort); + Logger.log(getClass(), LogLevel.TRACE, "Gnome socks proxy is {}:{}", proxyHost, proxyPort); ps.setSelector("socks", new FixedProxySelector(proxyHost.trim(), proxyPort)); } } @@ -256,7 +254,7 @@ private void installFtpSelector(Properties settings, ProtocolDispatchSelector ps String proxyHost = settings.getProperty("org.gnome.system.proxy.ftp host", null); int proxyPort = Integer.parseInt(settings.getProperty("org.gnome.system.proxy.ftp port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { - Logger.log(getClass(), LogLevel.TRACE, "Gnome ftp proxy is {0}:{1}", proxyHost, proxyPort); + Logger.log(getClass(), LogLevel.TRACE, "Gnome ftp proxy is {}:{}", proxyHost, proxyPort); ps.setSelector("ftp", new FixedProxySelector(proxyHost.trim(), proxyPort)); } } @@ -271,7 +269,7 @@ private void installSecureSelector(Properties settings, ProtocolDispatchSelector String proxyHost = settings.getProperty("org.gnome.system.proxy.https host", null); int proxyPort = Integer.parseInt(settings.getProperty("org.gnome.system.proxy.https port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { - Logger.log(getClass(), LogLevel.TRACE, "Gnome secure proxy is {0}:{1}", proxyHost, proxyPort); + Logger.log(getClass(), LogLevel.TRACE, "Gnome secure proxy is {}:{}", proxyHost, proxyPort); ps.setSelector("https", new FixedProxySelector(proxyHost.trim(), proxyPort)); ps.setSelector("sftp", new FixedProxySelector(proxyHost.trim(), proxyPort)); } @@ -307,7 +305,7 @@ private Properties parseSettings(Properties settings) throws IOException { value = value.replaceAll("\\[|\\]| ", ""); } - Logger.log(getClass(), LogLevel.TRACE, "prop is: {0}|{1}", entry, value); + Logger.log(getClass(), LogLevel.TRACE, "prop is: {}|{}", entry, value); settings.setProperty(entry, value); } try { diff --git a/src/main/java/com/github/markusbernhardt/proxy/search/desktop/gnome/GnomeProxySearchStrategy.java b/src/main/java/com/github/markusbernhardt/proxy/search/desktop/gnome/GnomeProxySearchStrategy.java index e5d953b..83a1126 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/search/desktop/gnome/GnomeProxySearchStrategy.java +++ b/src/main/java/com/github/markusbernhardt/proxy/search/desktop/gnome/GnomeProxySearchStrategy.java @@ -4,17 +4,14 @@ import java.io.IOException; import java.net.ProxySelector; import java.util.Properties; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; - import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; - import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.selector.direct.NoProxySelector; import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector; @@ -22,10 +19,10 @@ import com.github.markusbernhardt.proxy.selector.whitelist.ProxyBypassListSelector; import com.github.markusbernhardt.proxy.util.EmptyXMLResolver; import com.github.markusbernhardt.proxy.util.Logger; +import com.github.markusbernhardt.proxy.util.Logger.LogLevel; import com.github.markusbernhardt.proxy.util.PlatformUtil; import com.github.markusbernhardt.proxy.util.ProxyException; import com.github.markusbernhardt.proxy.util.ProxyUtil; -import com.github.markusbernhardt.proxy.util.Logger.LogLevel; /***************************************************************************** * Loads the Gnome proxy settings from the Gnome GConf settings. @@ -119,14 +116,14 @@ public ProxySelector getProxySelector() throws ProxyException { } if ("auto".equals(type)) { String pacScriptUrl = settings.getProperty("/system/proxy/autoconfig_url", ""); - Logger.log(getClass(), LogLevel.TRACE, "Gnome uses autodetect script {0}", pacScriptUrl); + Logger.log(getClass(), LogLevel.TRACE, "Gnome uses autodetect script {}", pacScriptUrl); result = ProxyUtil.buildPacSelectorForUrl(pacScriptUrl); } // Wrap into white-list filter? String noProxyList = settings.getProperty("/system/http_proxy/ignore_hosts", null); if (result != null && noProxyList != null && noProxyList.trim().length() > 0) { - Logger.log(getClass(), LogLevel.TRACE, "Gnome uses proxy bypass list: {0}", noProxyList); + Logger.log(getClass(), LogLevel.TRACE, "Gnome uses proxy bypass list: {}", noProxyList); result = new ProxyBypassListSelector(noProxyList, result); } @@ -189,7 +186,7 @@ private File findSettingsFile(String context) { File settingsFile = new File(userDir, ".gconf" + File.separator + path.toString() + "%gconf.xml"); if (!settingsFile.exists()) { - Logger.log(getClass(), LogLevel.WARNING, "Gnome settings: {0} not found.", settingsFile); + Logger.log(getClass(), LogLevel.WARNING, "Gnome settings: {} not found.", settingsFile); return null; } return settingsFile; @@ -259,7 +256,7 @@ private void installHttpSelector(Properties settings, ProtocolDispatchSelector p String proxyHost = settings.getProperty("/system/http_proxy/host", null); int proxyPort = Integer.parseInt(settings.getProperty("/system/http_proxy/port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { - Logger.log(getClass(), LogLevel.TRACE, "Gnome http proxy is {0}:{1}", proxyHost, proxyPort); + Logger.log(getClass(), LogLevel.TRACE, "Gnome http proxy is {}:{}", proxyHost, proxyPort); ps.setSelector("http", new FixedProxySelector(proxyHost.trim(), proxyPort)); } } @@ -278,7 +275,7 @@ private void installSocksSelector(Properties settings, ProtocolDispatchSelector String proxyHost = settings.getProperty("/system/proxy/socks_host", null); int proxyPort = Integer.parseInt(settings.getProperty("/system/proxy/socks_port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { - Logger.log(getClass(), LogLevel.TRACE, "Gnome socks proxy is {0}:{1}", proxyHost, proxyPort); + Logger.log(getClass(), LogLevel.TRACE, "Gnome socks proxy is {}:{}", proxyHost, proxyPort); ps.setSelector("socks", new FixedProxySelector(proxyHost.trim(), proxyPort)); } } @@ -293,7 +290,7 @@ private void installFtpSelector(Properties settings, ProtocolDispatchSelector ps String proxyHost = settings.getProperty("/system/proxy/ftp_host", null); int proxyPort = Integer.parseInt(settings.getProperty("/system/proxy/ftp_port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { - Logger.log(getClass(), LogLevel.TRACE, "Gnome ftp proxy is {0}:{1}", proxyHost, proxyPort); + Logger.log(getClass(), LogLevel.TRACE, "Gnome ftp proxy is {}:{}", proxyHost, proxyPort); ps.setSelector("ftp", new FixedProxySelector(proxyHost.trim(), proxyPort)); } } @@ -308,7 +305,7 @@ private void installSecureSelector(Properties settings, ProtocolDispatchSelector String proxyHost = settings.getProperty("/system/proxy/secure_host", null); int proxyPort = Integer.parseInt(settings.getProperty("/system/proxy/secure_port", "0").trim()); if (proxyHost != null && proxyHost.length() > 0 && proxyPort > 0) { - Logger.log(getClass(), LogLevel.TRACE, "Gnome secure proxy is {0}:{1}", proxyHost, proxyPort); + Logger.log(getClass(), LogLevel.TRACE, "Gnome secure proxy is {}:{}", proxyHost, proxyPort); ps.setSelector("https", new FixedProxySelector(proxyHost.trim(), proxyPort)); ps.setSelector("sftp", new FixedProxySelector(proxyHost.trim(), proxyPort)); } diff --git a/src/main/java/com/github/markusbernhardt/proxy/search/desktop/kde/KdeProxySearchStrategy.java b/src/main/java/com/github/markusbernhardt/proxy/search/desktop/kde/KdeProxySearchStrategy.java index 27fadef..07735d4 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/search/desktop/kde/KdeProxySearchStrategy.java +++ b/src/main/java/com/github/markusbernhardt/proxy/search/desktop/kde/KdeProxySearchStrategy.java @@ -3,7 +3,6 @@ import java.io.IOException; import java.net.ProxySelector; import java.util.Properties; - import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.search.env.EnvProxySearchStrategy; import com.github.markusbernhardt.proxy.search.wpad.WpadProxySearchStrategy; @@ -106,7 +105,7 @@ public ProxySelector getProxySelector() throws ProxyException { break; case 2: // PAC Script String pacScriptUrl = settings.getProperty("Proxy Config Script", ""); - Logger.log(getClass(), LogLevel.TRACE, "Kde uses autodetect script {0}", pacScriptUrl); + Logger.log(getClass(), LogLevel.TRACE, "Kde uses autodetect script {}", pacScriptUrl); result = ProxyUtil.buildPacSelectorForUrl(pacScriptUrl); break; case 3: // WPAD @@ -178,7 +177,7 @@ private ProxySelector setupFixedProxySelector(Properties settings) { String proxyVar = settings.getProperty("httpProxy", null); FixedProxySelector httpPS = ProxyUtil.parseProxySettings(proxyVar); if (httpPS == null) { - Logger.log(getClass(), LogLevel.TRACE, "Kde http proxy is {0}", proxyVar); + Logger.log(getClass(), LogLevel.TRACE, "Kde http proxy is {}", proxyVar); return null; } @@ -188,14 +187,14 @@ private ProxySelector setupFixedProxySelector(Properties settings) { proxyVar = settings.getProperty("httpsProxy", null); FixedProxySelector httpsPS = ProxyUtil.parseProxySettings(proxyVar); if (httpsPS != null) { - Logger.log(getClass(), LogLevel.TRACE, "Kde https proxy is {0}", proxyVar); + Logger.log(getClass(), LogLevel.TRACE, "Kde https proxy is {}", proxyVar); ps.setSelector("https", httpsPS); } proxyVar = settings.getProperty("ftpProxy", null); FixedProxySelector ftpPS = ProxyUtil.parseProxySettings(proxyVar); if (ftpPS != null) { - Logger.log(getClass(), LogLevel.TRACE, "Kde ftp proxy is {0}", proxyVar); + Logger.log(getClass(), LogLevel.TRACE, "Kde ftp proxy is {}", proxyVar); ps.setSelector("ftp", ftpPS); } @@ -204,10 +203,10 @@ private ProxySelector setupFixedProxySelector(Properties settings) { if (noProxyList != null && noProxyList.trim().length() > 0) { boolean reverse = "true".equals(settings.getProperty("ReversedException", "false")); if (reverse) { - Logger.log(getClass(), LogLevel.TRACE, "Kde proxy blacklist is {0}", noProxyList); + Logger.log(getClass(), LogLevel.TRACE, "Kde proxy blacklist is {}", noProxyList); return new UseProxyWhiteListSelector(noProxyList, ps); } else { - Logger.log(getClass(), LogLevel.TRACE, "Kde proxy whitelist is {0}", noProxyList); + Logger.log(getClass(), LogLevel.TRACE, "Kde proxy whitelist is {}", noProxyList); return new ProxyBypassListSelector(noProxyList, ps); } } diff --git a/src/main/java/com/github/markusbernhardt/proxy/search/desktop/kde/KdeSettingsParser.java b/src/main/java/com/github/markusbernhardt/proxy/search/desktop/kde/KdeSettingsParser.java index db19715..45dacf1 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/search/desktop/kde/KdeSettingsParser.java +++ b/src/main/java/com/github/markusbernhardt/proxy/search/desktop/kde/KdeSettingsParser.java @@ -6,7 +6,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.Properties; - import com.github.markusbernhardt.proxy.util.Logger; import com.github.markusbernhardt.proxy.util.Logger.LogLevel; import com.github.markusbernhardt.proxy.util.PlatformUtil; @@ -128,7 +127,7 @@ private File findSettingsFile() { ************************************************************************/ private File findSettingsFile(File settingsFile) { - Logger.log(getClass(), LogLevel.TRACE, "Searching Kde settings in {0}", settingsFile); + Logger.log(getClass(), LogLevel.TRACE, "Searching Kde settings in {}", settingsFile); if (!settingsFile.exists()) { Logger.log(getClass(), LogLevel.DEBUG, "Settings not found"); return null; diff --git a/src/main/java/com/github/markusbernhardt/proxy/search/desktop/osx/OsxProxySearchStrategy.java b/src/main/java/com/github/markusbernhardt/proxy/search/desktop/osx/OsxProxySearchStrategy.java index aaf97c7..ef593dc 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/search/desktop/osx/OsxProxySearchStrategy.java +++ b/src/main/java/com/github/markusbernhardt/proxy/search/desktop/osx/OsxProxySearchStrategy.java @@ -9,7 +9,6 @@ import java.util.Arrays; import java.util.Enumeration; import java.util.List; - import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.search.browser.ie.IELocalByPassFilter; import com.github.markusbernhardt.proxy.search.wpad.WpadProxySearchStrategy; @@ -262,7 +261,7 @@ private ProxySelector installSimpleHostFilter(Dict proxySettings, ProxySelector private ProxySelector installExceptionList(Dict proxySettings, ProxySelector result) { List proxyExceptions = (List) proxySettings.get("ExceptionsList"); if (proxyExceptions != null && proxyExceptions.size() > 0) { - Logger.log(getClass(), LogLevel.TRACE, "OSX uses proxy bypass list: {0}", proxyExceptions); + Logger.log(getClass(), LogLevel.TRACE, "OSX uses proxy bypass list: {}", proxyExceptions); String noProxyList = toCommaSeparatedString(proxyExceptions); result = new ProxyBypassListSelector(noProxyList, result); } @@ -342,7 +341,7 @@ private void installSocksProxy(Dict proxySettings, ProtocolDispatchSelector ps) String proxyHost = (String) proxySettings.get("SOCKSProxy"); int proxyPort = (Integer) proxySettings.get("SOCKSPort"); ps.setSelector("socks", new FixedSocksSelector(proxyHost, proxyPort)); - Logger.log(getClass(), LogLevel.TRACE, "OSX socks proxy is {0}:{1}", proxyHost, proxyPort); + Logger.log(getClass(), LogLevel.TRACE, "OSX socks proxy is {}:{}", proxyHost, proxyPort); } } @@ -365,7 +364,7 @@ private void installSelectorForProtocol(Dict proxySettings, ProtocolDispatchSele int proxyPort = (Integer) proxySettings.get(prefix + "Port"); FixedProxySelector fp = new FixedProxySelector(proxyHost, proxyPort); ps.setSelector(protocol.toLowerCase(), fp); - Logger.log(getClass(), LogLevel.TRACE, "OSX uses for {0} the proxy {1}:{2}", protocol, proxyHost, + Logger.log(getClass(), LogLevel.TRACE, "OSX uses for {} the proxy {}:{}", protocol, proxyHost, proxyPort); } } diff --git a/src/main/java/com/github/markusbernhardt/proxy/search/desktop/win/CommonWindowsSearchStrategy.java b/src/main/java/com/github/markusbernhardt/proxy/search/desktop/win/CommonWindowsSearchStrategy.java index 1cff11d..540d679 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/search/desktop/win/CommonWindowsSearchStrategy.java +++ b/src/main/java/com/github/markusbernhardt/proxy/search/desktop/win/CommonWindowsSearchStrategy.java @@ -6,7 +6,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Properties; - import com.github.markusbernhardt.proxy.ProxySearchStrategy; import com.github.markusbernhardt.proxy.search.browser.ie.IELocalByPassFilter; import com.github.markusbernhardt.proxy.selector.fixed.FixedProxySelector; @@ -118,7 +117,7 @@ protected Properties parseProxyList(String proxyString) throws ProxyException { proxyString = proxyString.replace(';', '\n'); p.load(new ByteArrayInputStream(proxyString.getBytes("ISO-8859-1"))); } catch (IOException e) { - Logger.log(getClass(), LogLevel.ERROR, "Error reading IE settings as properties: {0}", e); + Logger.log(getClass(), LogLevel.ERROR, "Error reading IE settings as properties: {}", e); throw new ProxyException(e); } @@ -151,7 +150,7 @@ protected ProtocolDispatchSelector buildProtocolDispatchSelector(Properties prop try { port = Integer.parseInt(hostAndPort[1]); } catch (NumberFormatException e) { - Logger.log(CommonWindowsSearchStrategy.class, Logger.LogLevel.WARNING, "Cannot parse SOCKS proxy port {0}", hostAndPort[1]); + Logger.log(CommonWindowsSearchStrategy.class, Logger.LogLevel.WARNING, "Cannot parse SOCKS proxy port {}", hostAndPort[1]); } } ps.setFallbackSelector(new FixedSocksSelector(host, port)); diff --git a/src/main/java/com/github/markusbernhardt/proxy/search/desktop/win/WinProxySearchStrategy.java b/src/main/java/com/github/markusbernhardt/proxy/search/desktop/win/WinProxySearchStrategy.java index 621cc1d..fdf3021 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/search/desktop/win/WinProxySearchStrategy.java +++ b/src/main/java/com/github/markusbernhardt/proxy/search/desktop/win/WinProxySearchStrategy.java @@ -92,7 +92,7 @@ private ProxySelector createFixedProxySelector(WinProxyConfig winProxyConfig) th if (proxyString == null) { return null; } - Logger.log(getClass(), LogLevel.TRACE, "Windows uses manual settings: {0} with bypass list: {1}", proxyString, + Logger.log(getClass(), LogLevel.TRACE, "Windows uses manual settings: {} with bypass list: {}", proxyString, bypassList); Properties p = parseProxyList(proxyString); diff --git a/src/main/java/com/github/markusbernhardt/proxy/search/env/EnvProxySearchStrategy.java b/src/main/java/com/github/markusbernhardt/proxy/search/env/EnvProxySearchStrategy.java index fdbb702..4aacb2f 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/search/env/EnvProxySearchStrategy.java +++ b/src/main/java/com/github/markusbernhardt/proxy/search/env/EnvProxySearchStrategy.java @@ -112,24 +112,24 @@ public ProxySelector getProxySelector() { return null; } - Logger.log(getClass(), LogLevel.TRACE, "Http Proxy is {0}", this.httpProxy); + Logger.log(getClass(), LogLevel.TRACE, "Http Proxy is {}", this.httpProxy); ProtocolDispatchSelector ps = new ProtocolDispatchSelector(); ps.setSelector("http", httpPS); ProxySelector httpsPS = ProxyUtil.parseProxySettings(this.httpsProxy); - Logger.log(getClass(), LogLevel.TRACE, "Https Proxy is {0}", httpsPS == null ? this.httpsProxy : httpsPS); + Logger.log(getClass(), LogLevel.TRACE, "Https Proxy is {}", httpsPS == null ? this.httpsProxy : httpsPS); ps.setSelector("https", httpsPS != null ? httpsPS : httpPS); ProxySelector ftpPS = ProxyUtil.parseProxySettings(this.ftpProxy); if (ftpPS != null) { - Logger.log(getClass(), LogLevel.TRACE, "Ftp Proxy is {0}", this.ftpProxy); + Logger.log(getClass(), LogLevel.TRACE, "Ftp Proxy is {}", this.ftpProxy); ps.setSelector("ftp", ftpPS); } // Wrap with white list support ProxySelector result = ps; if (this.noProxy != null && this.noProxy.trim().length() > 0) { - Logger.log(getClass(), LogLevel.TRACE, "Using proxy bypass list: {0}", this.noProxy); + Logger.log(getClass(), LogLevel.TRACE, "Using proxy bypass list: {}", this.noProxy); result = new ProxyBypassListSelector(this.noProxy, ps); } diff --git a/src/main/java/com/github/markusbernhardt/proxy/search/java/JavaProxySearchStrategy.java b/src/main/java/com/github/markusbernhardt/proxy/search/java/JavaProxySearchStrategy.java index 939b39b..62b8da0 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/search/java/JavaProxySearchStrategy.java +++ b/src/main/java/com/github/markusbernhardt/proxy/search/java/JavaProxySearchStrategy.java @@ -103,7 +103,7 @@ private boolean setupSocktProxy(ProtocolDispatchSelector ps) { } String port = System.getProperty("socksProxyPort", "1080"); - Logger.log(getClass(), LogLevel.TRACE, "Socks proxy {0}:{1} found", host, port); + Logger.log(getClass(), LogLevel.TRACE, "Socks proxy {}:{} found", host, port); ps.setFallbackSelector(new FixedSocksSelector(host, Integer.parseInt(port))); return true; } @@ -130,7 +130,7 @@ private void setupProxyForProtocol(ProtocolDispatchSelector ps, String protocol, whiteList = System.getProperty("http.nonProxyHosts", "").replace('|', ','); } - Logger.log(getClass(), LogLevel.TRACE, protocol.toUpperCase() + " proxy {0}:{1} found using whitelist: {2}", host, + Logger.log(getClass(), LogLevel.TRACE, protocol.toUpperCase() + " proxy {}:{} found using whitelist: {}", host, port, whiteList); ProxySelector protocolSelector = new FixedProxySelector(host, Integer.parseInt(port)); diff --git a/src/main/java/com/github/markusbernhardt/proxy/search/wpad/WpadProxySearchStrategy.java b/src/main/java/com/github/markusbernhardt/proxy/search/wpad/WpadProxySearchStrategy.java index 964eff2..5d32e07 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/search/wpad/WpadProxySearchStrategy.java +++ b/src/main/java/com/github/markusbernhardt/proxy/search/wpad/WpadProxySearchStrategy.java @@ -74,7 +74,7 @@ public ProxySelector getProxySelector() throws ProxyException { if (pacScriptUrl == null) { return null; } - Logger.log(getClass(), LogLevel.TRACE, "PAC script url found: {0}", pacScriptUrl); + Logger.log(getClass(), LogLevel.TRACE, "PAC script url found: {}", pacScriptUrl); return ProxyUtil.buildPacSelectorForUrl(pacScriptUrl); } catch (IOException e) { Logger.log(getClass(), LogLevel.ERROR, "Error during WPAD search.", e); @@ -151,7 +151,7 @@ private String detectScriptUrlPerDNS() throws IOException { // Try to connect to URL try { URL lookupURL = new URL(stringBuilder.toString()); - Logger.log(getClass(), LogLevel.TRACE, "Trying url: {0}", lookupURL); + Logger.log(getClass(), LogLevel.TRACE, "Trying url: {}", lookupURL); HttpURLConnection con = (HttpURLConnection) lookupURL.openConnection(Proxy.NO_PROXY); con.setInstanceFollowRedirects(true); diff --git a/src/main/java/com/github/markusbernhardt/proxy/search/wpad/WpadProxySearchStrategyWithDHPC.java b/src/main/java/com/github/markusbernhardt/proxy/search/wpad/WpadProxySearchStrategyWithDHPC.java index 04fbd30..f5a1f15 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/search/wpad/WpadProxySearchStrategyWithDHPC.java +++ b/src/main/java/com/github/markusbernhardt/proxy/search/wpad/WpadProxySearchStrategyWithDHPC.java @@ -68,7 +68,7 @@ public ProxySelector getProxySelector() throws ProxyException { if (pacScriptUrl == null) { return null; } - Logger.log(getClass(), LogLevel.TRACE, "PAC script url found: {0}", pacScriptUrl); + Logger.log(getClass(), LogLevel.TRACE, "PAC script url found: {}", pacScriptUrl); return ProxyUtil.buildPacSelectorForUrl(pacScriptUrl); } catch (IOException e) { Logger.log(getClass(), LogLevel.ERROR, "Error during WPAD search.", e); @@ -136,7 +136,7 @@ private String detectScriptUrlPerDNS() throws IOException { // Try to connect to URL try { URL lookupURL = new URL("http://wpad." + fqdn + "/wpad.dat"); - Logger.log(getClass(), LogLevel.TRACE, "Trying url: {0}", lookupURL); + Logger.log(getClass(), LogLevel.TRACE, "Trying url: {}", lookupURL); HttpURLConnection con = (HttpURLConnection) lookupURL.openConnection(Proxy.NO_PROXY); con.setInstanceFollowRedirects(true); diff --git a/src/main/java/com/github/markusbernhardt/proxy/selector/pac/PacScriptMethods.java b/src/main/java/com/github/markusbernhardt/proxy/selector/pac/PacScriptMethods.java index e7760b1..7750e16 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/selector/pac/PacScriptMethods.java +++ b/src/main/java/com/github/markusbernhardt/proxy/selector/pac/PacScriptMethods.java @@ -107,7 +107,7 @@ public boolean isResolvable(String host) { InetAddress.getByName(host).getHostAddress(); return true; } catch (UnknownHostException ex) { - Logger.log(JavaxPacScriptParser.class, LogLevel.DEBUG, "Hostname not resolveable {0}.", host); + Logger.log(JavaxPacScriptParser.class, LogLevel.DEBUG, "Hostname not resolveable {}.", host); } return false; } @@ -178,7 +178,7 @@ public String dnsResolve(String host) { InetAddress ina = InetAddress.getByName(host); return ina.getHostAddress(); } catch (UnknownHostException e) { - Logger.log(JavaxPacScriptParser.class, LogLevel.DEBUG, "DNS name not resolvable {0}.", host); + Logger.log(JavaxPacScriptParser.class, LogLevel.DEBUG, "DNS name not resolvable {}.", host); } return ""; } @@ -220,7 +220,7 @@ private String getLocalAddressOfType(Class cl) { while (addresses.hasMoreElements()) { InetAddress adr = addresses.nextElement(); if (cl.isInstance(adr)) { - Logger.log(JavaxPacScriptParser.class, LogLevel.TRACE, "Local address resolved to {0}", adr); + Logger.log(JavaxPacScriptParser.class, LogLevel.TRACE, "Local address resolved to {}", adr); return adr.getHostAddress(); } } @@ -653,7 +653,7 @@ public String dnsResolveEx(String host) { result.append("; "); } } catch (UnknownHostException e) { - Logger.log(JavaxPacScriptParser.class, LogLevel.DEBUG, "DNS name not resolvable {0}.", host); + Logger.log(JavaxPacScriptParser.class, LogLevel.DEBUG, "DNS name not resolvable {}.", host); } return result.toString(); } @@ -703,7 +703,7 @@ public int compare(byte[] b1, byte[] b2) { } return result.toString(); } catch (Exception e) { - Logger.log(JavaxPacScriptParser.class, LogLevel.DEBUG, "Cannot sort invalid IP list: {0}.", ipAddressList); + Logger.log(JavaxPacScriptParser.class, LogLevel.DEBUG, "Cannot sort invalid IP list: {}.", ipAddressList); return ""; } } diff --git a/src/main/java/com/github/markusbernhardt/proxy/selector/pac/UrlPacScriptSource.java b/src/main/java/com/github/markusbernhardt/proxy/selector/pac/UrlPacScriptSource.java index 2092cd1..4d63912 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/selector/pac/UrlPacScriptSource.java +++ b/src/main/java/com/github/markusbernhardt/proxy/selector/pac/UrlPacScriptSource.java @@ -67,7 +67,7 @@ public synchronized String getScriptContent() throws IOException { this.scriptContent = downloadPacContent(this.scriptUrl); } } catch (IOException e) { - Logger.log(getClass(), LogLevel.ERROR, "Loading script failed from: {0} with error {1}", this.scriptUrl, + Logger.log(getClass(), LogLevel.ERROR, "Loading script failed from: {} with error {}", this.scriptUrl, e); this.scriptContent = ""; throw e; @@ -229,7 +229,7 @@ protected int getTimeOut(String overrideProperty, int defaultValue) { try { timeout = Integer.parseInt(prop.trim()); } catch (NumberFormatException e) { - Logger.log(getClass(), LogLevel.DEBUG, "Invalid override property : {0}={1}", overrideProperty, prop); + Logger.log(getClass(), LogLevel.DEBUG, "Invalid override property : {}={}", overrideProperty, prop); // In this case use the default value. } } @@ -286,7 +286,7 @@ public boolean isScriptValid() { } return true; } catch (IOException e) { - Logger.log(getClass(), LogLevel.DEBUG, "File reading error: {0}", e); + Logger.log(getClass(), LogLevel.DEBUG, "File reading error: {}", e); return false; } } diff --git a/src/main/java/com/github/markusbernhardt/proxy/util/PlatformUtil.java b/src/main/java/com/github/markusbernhardt/proxy/util/PlatformUtil.java index 7f8df66..df615f1 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/util/PlatformUtil.java +++ b/src/main/java/com/github/markusbernhardt/proxy/util/PlatformUtil.java @@ -33,22 +33,22 @@ public enum Browser { public static Platform getCurrentPlattform() { String osName = System.getProperty("os.name"); - Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detecting platform. Name is: {0}", osName); + Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detecting platform. Name is: {}", osName); if (osName.toLowerCase().contains("windows")) { - Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Windows platform: {0}", osName); + Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Windows platform: {}", osName); return Platform.WIN; } if (osName.toLowerCase().contains("linux")) { - Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Linux platform: {0}", osName); + Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Linux platform: {}", osName); return Platform.LINUX; } if (osName.startsWith("Mac OS")) { - Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Mac OS platform: {0}", osName); + Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Mac OS platform: {}", osName); return Platform.MAC_OS; } if (osName.startsWith("SunOS")) { - Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Solaris platform: {0}", osName); + Logger.log(PlatformUtil.class, LogLevel.TRACE, "Detected Solaris platform: {}", osName); return Platform.SOLARIS; } diff --git a/src/main/java/com/github/markusbernhardt/proxy/util/ProxyUtil.java b/src/main/java/com/github/markusbernhardt/proxy/util/ProxyUtil.java index 9fe88ee..e5b1706 100644 --- a/src/main/java/com/github/markusbernhardt/proxy/util/ProxyUtil.java +++ b/src/main/java/com/github/markusbernhardt/proxy/util/ProxyUtil.java @@ -53,7 +53,7 @@ public static FixedProxySelector parseProxySettings(String proxyVar) { } return new FixedProxySelector(host.trim(), port); } catch (MalformedURLException e) { - Logger.log(ProxyUtil.class, Logger.LogLevel.WARNING, "Cannot parse Proxy Settings {0}", proxyVar); + Logger.log(ProxyUtil.class, Logger.LogLevel.WARNING, "Cannot parse Proxy Settings {}", proxyVar); return null; } }