Changeset ab3dbd5


Ignore:
Timestamp:
May 9, 2016 11:32:56 AM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
2d08889
Parents:
6b578df
Message:

I2PSnark: Limit cases when we display tracker errors;
include host name of tracker when we do

File:
1 edited

Legend:

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

    r6b578df rab3dbd5  
    586586                    // Probably not fatal (if it doesn't last to long...)
    587587                    if (_log.shouldLog(Log.WARN))
    588                         _log.warn
    589                       ("WARNING: Could not contact tracker at '"
    590                        + tr.announce + "': " + ioe);
     588                        _log.warn("Could not contact tracker at '" + tr.announce + "': " + ioe);
    591589                    tr.trackerProblems = ioe.getMessage();
    592590                    // don't show secondary tracker problems to the user
    593                     if (tr.isPrimary)
     591                    // ... and only if we don't have any peers at all. Otherwise, PEX/DHT will save us.
     592                    if (tr.isPrimary && coordinator.getPeers() <= 0 &&
     593                        (!completed || _util.getDHT() == null || _util.getDHT().size() <= 0))
    594594                      snark.setTrackerProblems(tr.trackerProblems);
    595595                    String tplc = tr.trackerProblems.toLowerCase(Locale.US);
     
    781781  }
    782782 
     783  /**
     784   *
     785   *  Note: IOException message text gets displayed in the UI
     786   *
     787   */
    783788  private TrackerInfo doRequest(TCTracker tr, String infoHash,
    784789                                String peerID, long uploaded,
     
    822827    byte[] fetched = _util.get(s, true, fast ? -1 : 0, small ? 128 : 1024, small ? 1024 : 32*1024);
    823828    if (fetched == null)
    824         throw new IOException("Error fetching");
     829        throw new IOException("No response from " + tr.host);
    825830    if (fetched.length == 0)
    826         throw new IOException("No data");
     831        throw new IOException("No data from " + tr.host);
    827832    // The HTML check only works if we didn't exceed the maxium fetch size specified in get(),
    828833    // otherwise we already threw an IOE.
    829834    if (fetched[0] == '<')
    830         throw new IOException(ERROR_GOT_HTML);
     835        throw new IOException(ERROR_GOT_HTML + " from " + tr.host);
    831836   
    832837        InputStream in = new ByteArrayInputStream(fetched);
     
    835840                                           snark.getInfoHash(), snark.getMetaInfo(), _util);
    836841        if (_log.shouldLog(Log.INFO))
    837             _log.info("TrackerClient response: " + info);
     842            _log.info("TrackerClient " + tr.host + " response: " + info);
    838843
    839844        String failure = info.getFailureReason();
    840845        if (failure != null)
    841           throw new IOException(failure);
     846            throw new IOException("Tracker " + tr.host + " responded with: " + failure);
    842847
    843848        tr.interval = Math.max(MIN_TRACKER_ANNOUNCE_INTERVAL, info.getInterval() * 1000l);
     
    926931  {
    927932      final String announce;
     933      final String host;
    928934      final boolean isPrimary;
    929935      long interval;
     
    939945      {
    940946          announce = a;
     947          String s = a.substring(7);
     948          host = s.substring(0, s.indexOf("/"));
    941949          isPrimary = p;
    942950          interval = INITIAL_SLEEP;
Note: See TracChangeset for help on using the changeset viewer.