Reseed: Add support for reseeding via outproxy or Orchid (ticket #1841)

InternalSocket: Add support for some methods needed for reseed to work
This commit is contained in:
zzz
2017-11-21 01:29:31 +00:00
parent 07a83bf310
commit 8c7898de1e
7 changed files with 154 additions and 49 deletions

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 5;
public final static long BUILD = 6;
/** for example "-test" */
public final static String EXTRA = "";

View File

@ -32,6 +32,7 @@ import net.i2p.util.EepGet;
import net.i2p.util.FileUtil;
import net.i2p.util.I2PAppThread;
import net.i2p.util.Log;
import net.i2p.util.PortMapper;
import net.i2p.util.SecureDirectory;
import net.i2p.util.SecureFileOutputStream;
import net.i2p.util.SSLEepGet;
@ -299,15 +300,25 @@ public class Reseeder {
_proxyPort = -1;
}
_shouldProxyHTTP = _proxyHost != null && _proxyHost.length() > 0 && _proxyPort > 0;
if (_context.getBooleanProperty(PROP_SPROXY_ENABLE)) {
_sproxyHost = _context.getProperty(PROP_SPROXY_HOST);
_sproxyPort = _context.getProperty(PROP_SPROXY_PORT, -1);
boolean shouldProxySSL = _context.getBooleanProperty(PROP_SPROXY_ENABLE);
SSLEepGet.ProxyType sproxyType;
if (shouldProxySSL) {
sproxyType = getProxyType();
if (sproxyType == SSLEepGet.ProxyType.INTERNAL) {
_sproxyHost = "localhost";
_sproxyPort = _context.portMapper().getPort(PortMapper.SVC_HTTP_PROXY, 4444);
} else {
_sproxyHost = _context.getProperty(PROP_SPROXY_HOST);
_sproxyPort = _context.getProperty(PROP_SPROXY_PORT, -1);
}
} else {
sproxyType = SSLEepGet.ProxyType.NONE;
_sproxyHost = null;
_sproxyPort = -1;
}
_shouldProxySSL = _sproxyHost != null && _sproxyHost.length() > 0 && _sproxyPort > 0;
_sproxyType = _shouldProxySSL ? getProxyType() : SSLEepGet.ProxyType.NONE;
_shouldProxySSL = shouldProxySSL && _sproxyHost != null && _sproxyHost.length() > 0 && _sproxyPort > 0;
_sproxyType = _shouldProxySSL ? sproxyType : SSLEepGet.ProxyType.NONE;
}
/*
@ -353,14 +364,15 @@ public class Reseeder {
_checker.setStatus("");
} else {
if (total == 0) {
System.out.println("Reseed failed " + getDisplayString(_url) + ", check network connection");
System.out.println("Reseed failed " + getDisplayString(_url) + "- check network connection");
System.out.println("Ensure that nothing blocks outbound HTTP or HTTPS, check the logs, " +
"and if nothing helps, read the FAQ about reseeding manually.");
if (_url == null || "https".equals(_url.getScheme())) {
if (_sproxyHost != null && _sproxyPort > 0)
System.out.println("Check HTTPS proxy setting - host: " + _sproxyHost + " port: " + _sproxyPort);
System.out.println("Check current proxy setting! Type: " + getDisplayString(_sproxyType) +
" Host: " + _sproxyHost + " Port: " + _sproxyPort);
else
System.out.println("Consider enabling an HTTPS proxy on the reseed configuration page");
System.out.println("Consider enabling a proxy for https on the reseed configuration page");
} else {
if (_proxyHost != null && _proxyPort > 0)
System.out.println("Check HTTP proxy setting - host: " + _proxyHost + " port: " + _proxyPort);
@ -1130,20 +1142,7 @@ public class Reseeder {
boolean ssl = url.startsWith("https://");
if (ssl && _shouldProxySSL) {
buf.append(" (using ");
switch(_sproxyType) {
case HTTP:
buf.append("HTTPS");
break;
case SOCKS4:
buf.append("SOCKS 4/4a");
break;
case SOCKS5:
buf.append("SOCKS 5");
break;
default:
buf.append(_sproxyType.toString());
break;
}
buf.append(getDisplayString(_sproxyType));
buf.append(" proxy ");
if (_sproxyHost.contains(":"))
buf.append('[').append(_sproxyHost).append(']');
@ -1162,6 +1161,27 @@ public class Reseeder {
}
return buf.toString();
}
/**
* Display string for what we're fetching.
* Untranslated, for logs only.
*
* @since 0.9.33
*/
private String getDisplayString(SSLEepGet.ProxyType type) {
switch(type) {
case HTTP:
return "HTTPS";
case SOCKS4:
return "SOCKS 4/4a";
case SOCKS5:
return "SOCKS 5";
case INTERNAL:
return "I2P Outproxy";
default:
return type.toString();
}
}
}
private static final String BUNDLE_NAME = "net.i2p.router.web.messages";