Changeset 59504de


Ignore:
Timestamp:
Aug 27, 2014 5:06:44 PM (6 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
0a01700
Parents:
8ee660c2
Message:

i2psnark:

  • Recognize Vuze tracker rejections
  • Don't retry rejected announces unless seeding
  • Better UI handling of announces with ports or full destination
Location:
apps/i2psnark/java/src/org/klomp/snark
Files:
3 edited

Legend:

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

    r8ee660c2 r59504de  
    130130     *  "name", "announceURL=websiteURL" pairs
    131131     *  '=' in announceURL must be escaped as &#44;
     132     *
     133     *  Please use host name, not b32 or full dest, in announce URL. Ensure in default hosts.txt.
     134     *  Please use host name, not b32 or full dest, in website URL. Ensure in default hosts.txt.
    132135     */
    133136    private static final String DEFAULT_TRACKERS[] = {
  • apps/i2psnark/java/src/org/klomp/snark/TrackerClient.java

    r8ee660c2 r59504de  
    7373  private static final String NOT_REGISTERED  = "torrent not registered"; //bytemonsoon
    7474  private static final String NOT_REGISTERED_2  = "torrent not found";    // diftracker
     75  private static final String NOT_REGISTERED_3  = "torrent unauthorised"; // vuze
    7576  /** this is our equivalent to router.utorrent.com for bootstrap */
    7677  private static final String DEFAULT_BACKUP_TRACKER = "http://tracker.welterde.i2p/a";
     
    578579                      snark.setTrackerProblems(tr.trackerProblems);
    579580                    String tplc = tr.trackerProblems.toLowerCase(Locale.US);
    580                     if (tplc.startsWith(NOT_REGISTERED) || tplc.startsWith(NOT_REGISTERED_2)) {
     581                    if (tplc.startsWith(NOT_REGISTERED) || tplc.startsWith(NOT_REGISTERED_2) ||
     582                        tplc.startsWith(NOT_REGISTERED_3)) {
    581583                      // Give a guy some time to register it if using opentrackers too
    582584                      //if (trckrs.size() == 1) {
     
    585587                      //} else { // hopefully each on the opentrackers list is really open
    586588                        if (tr.registerFails++ > MAX_REGISTER_FAILS ||
     589                            !completed ||              // no use retrying if we aren't seeding
    587590                            (!tr.isPrimary && tr.registerFails > MAX_REGISTER_FAILS / 2))
     591                          if (_log.shouldLog(Log.WARN))
     592                              _log.warn("Not longer announcing to " + tr.announce + " : " +
     593                                        tr.trackerProblems + " after " + tr.registerFails + " failures");
    588594                          tr.stop = true;
    589595                      //
  • apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java

    r8ee660c2 r59504de  
    2626import javax.servlet.http.HttpServletResponse;
    2727
     28import net.i2p.data.Base32;
    2829import net.i2p.data.Base64;
    2930import net.i2p.data.DataHelper;
     31import net.i2p.data.Hash;
    3032import net.i2p.util.Log;
    3133
     
    17181720
    17191721    /**
    1720      *  Start of anchor only, caller must add anchor text or img and close anchor
    1721      *  @return string or null
     1722     *  Generate link to details page if we know it supports it.
     1723     *  Start of anchor only, caller must add anchor text or img and close anchor.
     1724     *
     1725     *  @return string or null if unknown tracker
    17221726     *  @since 0.8.4
    17231727     */
     
    17461750
    17471751    /**
    1748      *  Full anchor with img
    1749      *  @return string or null
     1752     *  Full link to details page with img
     1753     *  @return string or null if details page unsupported
    17501754     *  @since 0.8.4
    17511755     */
     
    17631767
    17641768    /**
    1765      *  Full anchor with shortened URL as anchor text
     1769     *  Full anchor to home page or details page with shortened host name as anchor text
    17661770     *  @return string, non-null
    17671771     *  @since 0.9.5
     
    17721776        if (announce.startsWith("http://"))
    17731777            announce = announce.substring(7);
     1778        // strip path
    17741779        int slsh = announce.indexOf('/');
    17751780        if (slsh > 0)
    17761781            announce = announce.substring(0, slsh);
    1777         if (trackerLinkUrl != null)
     1782        if (trackerLinkUrl != null) {
    17781783            buf.append(trackerLinkUrl);
    1779         else
    1780             // TODO encode
    1781             buf.append("<a href=\"http://").append(urlEncode(announce)).append("/\">");
     1784        } else {
     1785            // browsers don't like a full b64 dest, so convert it to b32
     1786            String host = announce;
     1787            if (host.length() >= 516) {
     1788                int colon = announce.indexOf(':');
     1789                String port = "";
     1790                if (colon > 0) {
     1791                    port = host.substring(colon);
     1792                    host = host.substring(0, colon);
     1793                }
     1794                if (host.endsWith(".i2p"))
     1795                    host = host.substring(0, host.length() - 4);
     1796                byte[] b = Base64.decode(host);
     1797                if (b != null) {
     1798                    Hash h = _context.sha().calculateHash(b);
     1799                    // should we add the port back or strip it?
     1800                    host = Base32.encode(h.getData()) + ".b32.i2p" + port;
     1801                }
     1802            }
     1803            buf.append("<a href=\"http://").append(urlEncode(host)).append("/\">");
     1804        }
     1805        // strip port
     1806        int colon = announce.indexOf(':');
     1807        if (colon > 0)
     1808            announce = announce.substring(0, colon);
    17821809        if (announce.length() > 67)
    17831810            announce = DataHelper.escapeHTML(announce.substring(0, 40)) + "&hellip;" +
Note: See TracChangeset for help on using the changeset viewer.