Changeset 38762937


Ignore:
Timestamp:
Aug 27, 2014 6:21:58 PM (6 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
588ab86
Parents:
0a01700
Message:

i2psnark: Don't retry announce if we get back HTML

File:
1 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/TrackerClient.java

    r0a01700 r38762937  
    7474  private static final String NOT_REGISTERED_2  = "torrent not found";    // diftracker
    7575  private static final String NOT_REGISTERED_3  = "torrent unauthorised"; // vuze
     76  private static final String ERROR_GOT_HTML  = "received html";             // fake return
    7677  /** this is our equivalent to router.utorrent.com for bootstrap */
    7778  private static final String DEFAULT_BACKUP_TRACKER = "http://tracker.welterde.i2p/a";
     
    580581                    String tplc = tr.trackerProblems.toLowerCase(Locale.US);
    581582                    if (tplc.startsWith(NOT_REGISTERED) || tplc.startsWith(NOT_REGISTERED_2) ||
    582                         tplc.startsWith(NOT_REGISTERED_3)) {
     583                        tplc.startsWith(NOT_REGISTERED_3) || tplc.startsWith(ERROR_GOT_HTML)) {
    583584                      // Give a guy some time to register it if using opentrackers too
    584585                      //if (trckrs.size() == 1) {
     
    588589                        if (tr.registerFails++ > MAX_REGISTER_FAILS ||
    589590                            !completed ||              // no use retrying if we aren't seeding
     591                            tplc.startsWith(ERROR_GOT_HTML) ||   // fake msg from doRequest()
    590592                            (!tr.isPrimary && tr.registerFails > MAX_REGISTER_FAILS / 2))
    591593                          if (_log.shouldLog(Log.WARN))
     
    804806    // Don't wait for a response to stopped when shutting down
    805807    boolean fast = _fastUnannounce && event.equals(STOPPED_EVENT);
    806     byte[] fetched = _util.get(s, true, fast ? -1 : 0, small ? 128 : 1024, small ? 1024 : 8*1024);
    807     if (fetched == null) {
    808         throw new IOException("Error fetching " + s);
    809     }
     808    byte[] fetched = _util.get(s, true, fast ? -1 : 0, small ? 128 : 1024, small ? 1024 : 32*1024);
     809    if (fetched == null)
     810        throw new IOException("Error fetching");
     811    if (fetched.length == 0)
     812        throw new IOException("No data");
     813    // The HTML check only works if we didn't exceed the maxium fetch size specified in get(),
     814    // otherwise we already threw an IOE.
     815    if (fetched[0] == '<')
     816        throw new IOException(ERROR_GOT_HTML);
    810817   
    811818        InputStream in = new ByteArrayInputStream(fetched);
Note: See TracChangeset for help on using the changeset viewer.