From 35a0dafb838d216411e7a84f38859367feb4e88c Mon Sep 17 00:00:00 2001 From: zzz Date: Mon, 18 Jan 2010 15:42:50 +0000 Subject: [PATCH] * Reseed: Support SSL and proxies --- .../i2p/router/networkdb/reseed/Reseeder.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java b/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java index 2e93cb3e0..8d739cfde 100644 --- a/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java +++ b/router/java/src/net/i2p/router/networkdb/reseed/Reseeder.java @@ -17,6 +17,7 @@ import net.i2p.router.RouterContext; import net.i2p.util.EepGet; import net.i2p.util.I2PAppThread; import net.i2p.util.Log; +import net.i2p.util.SSLEepGet; /** * Moved from ReseedHandler in routerconsole. See ReseedChecker for additional comments. @@ -38,6 +39,8 @@ public class Reseeder { private static final String PROP_INPROGRESS = "net.i2p.router.web.ReseedHandler.reseedInProgress"; private static final String PROP_ERROR = "net.i2p.router.web.ReseedHandler.errorMessage"; private static final String PROP_STATUS = "net.i2p.router.web.ReseedHandler.statusMessage"; + public static final String PROP_PROXY_HOST = "router.reseedProxyHost"; + public static final String PROP_PROXY_PORT = "router.reseedProxyPort"; public Reseeder(RouterContext ctx) { _context = ctx; @@ -63,6 +66,8 @@ public class Reseeder { /** Todo: translate the messages sent via PROP_STATUS */ public class ReseedRunner implements Runnable, EepGet.StatusListener { private boolean _isRunning; + private String _proxyHost; + private int _proxyPort; public ReseedRunner() { _isRunning = false; @@ -71,6 +76,8 @@ public class Reseeder { public boolean isRunning() { return _isRunning; } public void run() { _isRunning = true; + _proxyHost = _context.getProperty(PROP_PROXY_HOST); + _proxyPort = _context.getProperty(PROP_PROXY_PORT, -1); System.out.println("Reseed start"); reseed(false); System.out.println("Reseed complete"); @@ -237,9 +244,15 @@ public class Reseeder { private byte[] readURL(URL url) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(4*1024); - // Do a non-proxied eepget into our ByteArrayOutputStream with 0 retries - EepGet get = new EepGet( I2PAppContext.getGlobalContext(), false, null, -1, 0, 0, MAX_RESEED_RESPONSE_SIZE, - null, baos, url.toString(), false, null, null); + EepGet get; + if (url.toString().startsWith("https")) { + get = new SSLEepGet(I2PAppContext.getGlobalContext(), baos, url.toString()); + } else { + // Do a (probably) non-proxied eepget into our ByteArrayOutputStream with 0 retries + boolean shouldProxy = _proxyHost != null && _proxyHost.length() > 0 && _proxyPort > 0; + get = new EepGet(I2PAppContext.getGlobalContext(), shouldProxy, _proxyHost, _proxyPort, 0, 0, MAX_RESEED_RESPONSE_SIZE, + null, baos, url.toString(), false, null, null); + } get.addStatusListener(ReseedRunner.this); if (get.fetch()) return baos.toByteArray(); else return null; }