forked from I2P_Developers/i2p.i2p
* Update:
- Reset found version in update loop so we don't fetch from the next host too. - Prevent NPE on version after SSL fetch - Fix su3 version check * EepGet: - Fix non-proxied PartialEepGet - Prevent non-proxied eepget for an I2P host - Fail if no hostname in URL
This commit is contained in:
@ -1104,7 +1104,7 @@ public class ConsoleUpdateManager implements UpdateManager {
|
|||||||
if (up.verifyAndMigrate(temp)) {
|
if (up.verifyAndMigrate(temp)) {
|
||||||
String ver = up.getVersionString();
|
String ver = up.getVersionString();
|
||||||
int type = up.getContentType();
|
int type = up.getContentType();
|
||||||
if (ver == null || VersionComparator.comp(RouterVersion.VERSION, ver) <= 0)
|
if (ver == null || VersionComparator.comp(RouterVersion.VERSION, ver) >= 0)
|
||||||
err = "Old version " + ver;
|
err = "Old version " + ver;
|
||||||
else if (type != SU3File.CONTENT_ROUTER)
|
else if (type != SU3File.CONTENT_ROUTER)
|
||||||
err = "Bad su3 content type " + type;
|
err = "Bad su3 content type " + type;
|
||||||
|
@ -150,8 +150,14 @@ class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusList
|
|||||||
boolean isSSL = false;
|
boolean isSSL = false;
|
||||||
if (_method == HTTP) {
|
if (_method == HTTP) {
|
||||||
shouldProxy = _context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY);
|
shouldProxy = _context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY);
|
||||||
proxyHost = _context.getProperty(ConfigUpdateHandler.PROP_PROXY_HOST, ConfigUpdateHandler.DEFAULT_PROXY_HOST);
|
if (shouldProxy) {
|
||||||
proxyPort = ConfigUpdateHandler.proxyPort(_context);
|
proxyHost = _context.getProperty(ConfigUpdateHandler.PROP_PROXY_HOST, ConfigUpdateHandler.DEFAULT_PROXY_HOST);
|
||||||
|
proxyPort = ConfigUpdateHandler.proxyPort(_context);
|
||||||
|
} else {
|
||||||
|
// TODO, wrong method, fail
|
||||||
|
proxyHost = null;
|
||||||
|
proxyPort = 0;
|
||||||
|
}
|
||||||
} else if (_method == HTTP_CLEARNET) {
|
} else if (_method == HTTP_CLEARNET) {
|
||||||
shouldProxy = false;
|
shouldProxy = false;
|
||||||
proxyHost = null;
|
proxyHost = null;
|
||||||
@ -191,7 +197,8 @@ class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusList
|
|||||||
_log.debug("Selected update URL: " + updateURL);
|
_log.debug("Selected update URL: " + updateURL);
|
||||||
|
|
||||||
// Check the first 56 bytes for the version
|
// Check the first 56 bytes for the version
|
||||||
// PartialEepGet works with clearnet but not with SSL
|
// FIXME PartialEepGet works with clearnet but not with SSL
|
||||||
|
_newVersion = null;
|
||||||
if (!isSSL) {
|
if (!isSSL) {
|
||||||
_isPartial = true;
|
_isPartial = true;
|
||||||
_baos.reset();
|
_baos.reset();
|
||||||
@ -265,6 +272,9 @@ class UpdateRunner extends I2PAppThread implements UpdateTask, EepGet.StatusList
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME if we didn't do a partial, we don't know
|
||||||
|
if (_newVersion == null)
|
||||||
|
_newVersion = "unknown";
|
||||||
File tmp = new File(_updateFile);
|
File tmp = new File(_updateFile);
|
||||||
if (_mgr.notifyComplete(this, _newVersion, tmp))
|
if (_mgr.notifyComplete(this, _newVersion, tmp))
|
||||||
this.done = true;
|
this.done = true;
|
||||||
|
@ -1055,12 +1055,14 @@ public class EepGet {
|
|||||||
URL url = new URL(_actualURL);
|
URL url = new URL(_actualURL);
|
||||||
if ("http".equals(url.getProtocol())) {
|
if ("http".equals(url.getProtocol())) {
|
||||||
String host = url.getHost();
|
String host = url.getHost();
|
||||||
|
if (host.toLowerCase(Locale.US).endsWith(".i2p"))
|
||||||
|
throw new MalformedURLException("I2P addresses must be proxied");
|
||||||
int port = url.getPort();
|
int port = url.getPort();
|
||||||
if (port == -1)
|
if (port == -1)
|
||||||
port = 80;
|
port = 80;
|
||||||
_proxy = new Socket(host, port);
|
_proxy = new Socket(host, port);
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("URL is not supported:" + _actualURL);
|
throw new MalformedURLException("URL is not supported:" + _actualURL);
|
||||||
}
|
}
|
||||||
// an MUE is an IOE
|
// an MUE is an IOE
|
||||||
//} catch (MalformedURLException mue) {
|
//} catch (MalformedURLException mue) {
|
||||||
@ -1089,6 +1091,8 @@ public class EepGet {
|
|||||||
post = true;
|
post = true;
|
||||||
URL url = new URL(_actualURL);
|
URL url = new URL(_actualURL);
|
||||||
String host = url.getHost();
|
String host = url.getHost();
|
||||||
|
if (host == null || host.length() <= 0)
|
||||||
|
throw new MalformedURLException("Bad URL, no host");
|
||||||
int port = url.getPort();
|
int port = url.getPort();
|
||||||
String path = url.getPath();
|
String path = url.getPath();
|
||||||
String query = url.getQuery();
|
String query = url.getQuery();
|
||||||
|
@ -3,6 +3,7 @@ package net.i2p.util;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
@ -32,8 +33,10 @@ public class PartialEepGet extends EepGet {
|
|||||||
public PartialEepGet(I2PAppContext ctx, String proxyHost, int proxyPort,
|
public PartialEepGet(I2PAppContext ctx, String proxyHost, int proxyPort,
|
||||||
OutputStream outputStream, String url, long size) {
|
OutputStream outputStream, String url, long size) {
|
||||||
// we're using this constructor:
|
// we're using this constructor:
|
||||||
// public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries, long minSize, long maxSize, String outputFile, OutputStream outputStream, String url, boolean allowCaching, String etag, String postData) {
|
// public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries,
|
||||||
super(ctx, true, proxyHost, proxyPort, 0, size, size, null, outputStream, url, true, null, null);
|
// long minSize, long maxSize, String outputFile, OutputStream outputStream, String url, boolean allowCaching, String etag, String postData) {
|
||||||
|
super(ctx, proxyHost != null && proxyPort > 0, proxyHost, proxyPort, 0,
|
||||||
|
size, size, null, outputStream, url, true, null, null);
|
||||||
_fetchSize = size;
|
_fetchSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,6 +109,8 @@ public class PartialEepGet extends EepGet {
|
|||||||
StringBuilder buf = new StringBuilder(2048);
|
StringBuilder buf = new StringBuilder(2048);
|
||||||
URL url = new URL(_actualURL);
|
URL url = new URL(_actualURL);
|
||||||
String host = url.getHost();
|
String host = url.getHost();
|
||||||
|
if (host == null || host.length() <= 0)
|
||||||
|
throw new MalformedURLException("Bad URL, no host");
|
||||||
int port = url.getPort();
|
int port = url.getPort();
|
||||||
String path = url.getPath();
|
String path = url.getPath();
|
||||||
String query = url.getQuery();
|
String query = url.getQuery();
|
||||||
|
@ -46,6 +46,7 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PipedInputStream;
|
import java.io.PipedInputStream;
|
||||||
import java.io.PipedOutputStream;
|
import java.io.PipedOutputStream;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
@ -492,6 +493,8 @@ public class SSLEepGet extends EepGet {
|
|||||||
int port = 0;
|
int port = 0;
|
||||||
if ("https".equals(url.getProtocol())) {
|
if ("https".equals(url.getProtocol())) {
|
||||||
host = url.getHost();
|
host = url.getHost();
|
||||||
|
if (host.toLowerCase(Locale.US).endsWith(".i2p"))
|
||||||
|
throw new MalformedURLException("I2P addresses unsupported");
|
||||||
port = url.getPort();
|
port = url.getPort();
|
||||||
if (port == -1)
|
if (port == -1)
|
||||||
port = 443;
|
port = 443;
|
||||||
@ -500,7 +503,7 @@ public class SSLEepGet extends EepGet {
|
|||||||
else
|
else
|
||||||
_proxy = SSLSocketFactory.getDefault().createSocket(host, port);
|
_proxy = SSLSocketFactory.getDefault().createSocket(host, port);
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("Only https supported: " + _actualURL);
|
throw new MalformedURLException("Only https supported: " + _actualURL);
|
||||||
}
|
}
|
||||||
// an MUE is an IOE
|
// an MUE is an IOE
|
||||||
//} catch (MalformedURLException mue) {
|
//} catch (MalformedURLException mue) {
|
||||||
|
Reference in New Issue
Block a user