Changeset 4bd27ea


Ignore:
Timestamp:
Oct 6, 2013 4:02:33 PM (7 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
82b1eb7
Parents:
d0f6be31
Message:
  • 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
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/update/ConsoleUpdateManager.java

    rd0f6be31 r4bd27ea  
    11051105                    String ver = up.getVersionString();
    11061106                    int type = up.getContentType();
    1107                     if (ver == null || VersionComparator.comp(RouterVersion.VERSION, ver) <= 0)
     1107                    if (ver == null || VersionComparator.comp(RouterVersion.VERSION, ver) >= 0)
    11081108                        err = "Old version " + ver;
    11091109                    else if (type != SU3File.CONTENT_ROUTER)
  • apps/routerconsole/java/src/net/i2p/router/update/UpdateRunner.java

    rd0f6be31 r4bd27ea  
    151151        if (_method == HTTP) {
    152152            shouldProxy = _context.getProperty(ConfigUpdateHandler.PROP_SHOULD_PROXY, ConfigUpdateHandler.DEFAULT_SHOULD_PROXY);
    153             proxyHost = _context.getProperty(ConfigUpdateHandler.PROP_PROXY_HOST, ConfigUpdateHandler.DEFAULT_PROXY_HOST);
    154             proxyPort = ConfigUpdateHandler.proxyPort(_context);
     153            if (shouldProxy) {
     154                proxyHost = _context.getProperty(ConfigUpdateHandler.PROP_PROXY_HOST, ConfigUpdateHandler.DEFAULT_PROXY_HOST);
     155                proxyPort = ConfigUpdateHandler.proxyPort(_context);
     156            } else {
     157                // TODO, wrong method, fail
     158                proxyHost = null;
     159                proxyPort = 0;
     160            }
    155161        } else if (_method == HTTP_CLEARNET) {
    156162            shouldProxy = false;
     
    192198
    193199            // Check the first 56 bytes for the version
    194             // PartialEepGet works with clearnet but not with SSL
     200            // FIXME PartialEepGet works with clearnet but not with SSL
     201            _newVersion = null;
    195202            if (!isSSL) {
    196203                _isPartial = true;
     
    266273        }
    267274
     275        // FIXME if we didn't do a partial, we don't know
     276        if (_newVersion == null)
     277            _newVersion = "unknown";
    268278        File tmp = new File(_updateFile);
    269279        if (_mgr.notifyComplete(this, _newVersion, tmp))
  • core/java/src/net/i2p/util/EepGet.java

    rd0f6be31 r4bd27ea  
    10561056                if ("http".equals(url.getProtocol())) {
    10571057                    String host = url.getHost();
     1058                    if (host.toLowerCase(Locale.US).endsWith(".i2p"))
     1059                        throw new MalformedURLException("I2P addresses must be proxied");
    10581060                    int port = url.getPort();
    10591061                    if (port == -1)
     
    10611063                    _proxy = new Socket(host, port);
    10621064                } else {
    1063                     throw new IOException("URL is not supported:" + _actualURL);
     1065                    throw new MalformedURLException("URL is not supported:" + _actualURL);
    10641066                }
    10651067            // an MUE is an IOE
     
    10901092        URL url = new URL(_actualURL);
    10911093        String host = url.getHost();
     1094        if (host == null || host.length() <= 0)
     1095            throw new MalformedURLException("Bad URL, no host");
    10921096        int port = url.getPort();
    10931097        String path = url.getPath();
  • core/java/src/net/i2p/util/PartialEepGet.java

    rd0f6be31 r4bd27ea  
    44import java.io.IOException;
    55import java.io.OutputStream;
     6import java.net.MalformedURLException;
    67import java.net.URL;
    78
     
    3334                         OutputStream outputStream,  String url, long size) {
    3435        // we're using this constructor:
    35         // 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) {
    36         super(ctx, true, proxyHost, proxyPort, 0, size, size, null, outputStream, url, true, null, null);
     36        // public EepGet(I2PAppContext ctx, boolean shouldProxy, String proxyHost, int proxyPort, int numRetries,
     37        //               long minSize, long maxSize, String outputFile, OutputStream outputStream, String url, boolean allowCaching, String etag, String postData) {
     38        super(ctx, proxyHost != null && proxyPort > 0, proxyHost, proxyPort, 0,
     39              size, size, null, outputStream, url, true, null, null);
    3740        _fetchSize = size;
    3841    }
     
    107110        URL url = new URL(_actualURL);
    108111        String host = url.getHost();
     112        if (host == null || host.length() <= 0)
     113            throw new MalformedURLException("Bad URL, no host");
    109114        int port = url.getPort();
    110115        String path = url.getPath();
  • core/java/src/net/i2p/util/SSLEepGet.java

    rd0f6be31 r4bd27ea  
    4747import java.io.PipedInputStream;
    4848import java.io.PipedOutputStream;
     49import java.net.MalformedURLException;
    4950import java.net.URL;
    5051import java.security.KeyStore;
     
    493494            if ("https".equals(url.getProtocol())) {
    494495                host = url.getHost();
     496                if (host.toLowerCase(Locale.US).endsWith(".i2p"))
     497                    throw new MalformedURLException("I2P addresses unsupported");
    495498                port = url.getPort();
    496499                if (port == -1)
     
    501504                    _proxy = SSLSocketFactory.getDefault().createSocket(host, port);
    502505            } else {
    503                 throw new IOException("Only https supported: " + _actualURL);
     506                throw new MalformedURLException("Only https supported: " + _actualURL);
    504507            }
    505508        // an MUE is an IOE
Note: See TracChangeset for help on using the changeset viewer.