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:
@ -1055,12 +1055,14 @@ public class EepGet {
|
||||
URL url = new URL(_actualURL);
|
||||
if ("http".equals(url.getProtocol())) {
|
||||
String host = url.getHost();
|
||||
if (host.toLowerCase(Locale.US).endsWith(".i2p"))
|
||||
throw new MalformedURLException("I2P addresses must be proxied");
|
||||
int port = url.getPort();
|
||||
if (port == -1)
|
||||
port = 80;
|
||||
_proxy = new Socket(host, port);
|
||||
} else {
|
||||
throw new IOException("URL is not supported:" + _actualURL);
|
||||
throw new MalformedURLException("URL is not supported:" + _actualURL);
|
||||
}
|
||||
// an MUE is an IOE
|
||||
//} catch (MalformedURLException mue) {
|
||||
@ -1089,6 +1091,8 @@ public class EepGet {
|
||||
post = true;
|
||||
URL url = new URL(_actualURL);
|
||||
String host = url.getHost();
|
||||
if (host == null || host.length() <= 0)
|
||||
throw new MalformedURLException("Bad URL, no host");
|
||||
int port = url.getPort();
|
||||
String path = url.getPath();
|
||||
String query = url.getQuery();
|
||||
|
@ -3,6 +3,7 @@ package net.i2p.util;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
@ -32,8 +33,10 @@ public class PartialEepGet extends EepGet {
|
||||
public PartialEepGet(I2PAppContext ctx, String proxyHost, int proxyPort,
|
||||
OutputStream outputStream, String url, long size) {
|
||||
// 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) {
|
||||
super(ctx, true, proxyHost, proxyPort, 0, size, size, null, outputStream, url, true, null, null);
|
||||
// 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) {
|
||||
super(ctx, proxyHost != null && proxyPort > 0, proxyHost, proxyPort, 0,
|
||||
size, size, null, outputStream, url, true, null, null);
|
||||
_fetchSize = size;
|
||||
}
|
||||
|
||||
@ -106,6 +109,8 @@ public class PartialEepGet extends EepGet {
|
||||
StringBuilder buf = new StringBuilder(2048);
|
||||
URL url = new URL(_actualURL);
|
||||
String host = url.getHost();
|
||||
if (host == null || host.length() <= 0)
|
||||
throw new MalformedURLException("Bad URL, no host");
|
||||
int port = url.getPort();
|
||||
String path = url.getPath();
|
||||
String query = url.getQuery();
|
||||
|
@ -46,6 +46,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PipedInputStream;
|
||||
import java.io.PipedOutputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.security.KeyStore;
|
||||
import java.security.GeneralSecurityException;
|
||||
@ -492,6 +493,8 @@ public class SSLEepGet extends EepGet {
|
||||
int port = 0;
|
||||
if ("https".equals(url.getProtocol())) {
|
||||
host = url.getHost();
|
||||
if (host.toLowerCase(Locale.US).endsWith(".i2p"))
|
||||
throw new MalformedURLException("I2P addresses unsupported");
|
||||
port = url.getPort();
|
||||
if (port == -1)
|
||||
port = 443;
|
||||
@ -500,7 +503,7 @@ public class SSLEepGet extends EepGet {
|
||||
else
|
||||
_proxy = SSLSocketFactory.getDefault().createSocket(host, port);
|
||||
} else {
|
||||
throw new IOException("Only https supported: " + _actualURL);
|
||||
throw new MalformedURLException("Only https supported: " + _actualURL);
|
||||
}
|
||||
// an MUE is an IOE
|
||||
//} catch (MalformedURLException mue) {
|
||||
|
Reference in New Issue
Block a user