]> source.dussan.org Git - gitblit.git/commitdiff
Add support for configurable HTTP proxy host/port in PluginManager.java 235/head
authorDariusz Bywalec <dariusz.bywalec@trapezegroup.pl>
Tue, 2 Dec 2014 16:11:50 +0000 (17:11 +0100)
committerDariusz Bywalec <dariusz.bywalec@trapezegroup.pl>
Tue, 2 Dec 2014 16:30:14 +0000 (17:30 +0100)
Formerly by default the PluginMaganer would support no proxy setting.
For servers behind firewall and HTTP proxy this would prevent installation of gitblit plugins.

src/main/distrib/data/defaults.properties
src/main/java/com/gitblit/manager/PluginManager.java

index aa69331ac859a49c57491d79794b7791ca146107..093dd8573f8252255d4b28d368e9eb457596b810 100644 (file)
@@ -572,6 +572,16 @@ plugins.folder = ${baseFolder}/plugins
 # SINCE 1.5.0
 plugins.registry = http://plugins.gitblit.com/plugins.json
 
+# The HTTP proxy host for plugin manager.
+#
+# SINCE 1.7.0
+plugins.httpProxyHost = 
+
+# The HTTP proxy port for plugin manager.
+#
+# SINCE 1.7.0
+plugins.httpProxyPort = 
+
 # Number of threads used to handle miscellaneous tasks in the background.
 #
 # SINCE 1.6.0
index 3e7bc1ff7da0c32340ea4f5d0fb31417e9d38e5e..a43cbdc84cad6a2e2665f33f2a8d7e241597d330 100644 (file)
@@ -22,6 +22,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
 import java.net.Proxy;
 import java.net.URL;
 import java.net.URLConnection;
@@ -586,7 +587,14 @@ public class PluginManager implements IPluginManager, PluginStateListener {
        }
 
        protected Proxy getProxy(URL url) {
-               return java.net.Proxy.NO_PROXY;
+               String proxyHost = runtimeManager.getSettings().getString(Keys.plugins.httpProxyHost, "");
+               String proxyPort = runtimeManager.getSettings().getString(Keys.plugins.httpProxyPort, "");
+               
+               if (!StringUtils.isEmpty(proxyHost)  && !StringUtils.isEmpty(proxyPort)) {
+                       return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, Integer.parseInt(proxyPort)));
+               } else {
+                       return java.net.Proxy.NO_PROXY;
+               }
        }
 
        protected String getProxyAuthorization(URL url) {