forked from I2P_Developers/i2p.i2p
i2psnark:
- Recognize Vuze tracker rejections - Don't retry rejected announces unless seeding - Better UI handling of announces with ports or full destination
This commit is contained in:
@ -129,6 +129,9 @@ public class SnarkManager implements CompleteListener {
|
||||
/**
|
||||
* "name", "announceURL=websiteURL" pairs
|
||||
* '=' in announceURL must be escaped as ,
|
||||
*
|
||||
* Please use host name, not b32 or full dest, in announce URL. Ensure in default hosts.txt.
|
||||
* Please use host name, not b32 or full dest, in website URL. Ensure in default hosts.txt.
|
||||
*/
|
||||
private static final String DEFAULT_TRACKERS[] = {
|
||||
// "Postman", "http://YRgrgTLGnbTq2aZOZDJQ~o6Uk5k6TK-OZtx0St9pb0G-5EGYURZioxqYG8AQt~LgyyI~NCj6aYWpPO-150RcEvsfgXLR~CxkkZcVpgt6pns8SRc3Bi-QSAkXpJtloapRGcQfzTtwllokbdC-aMGpeDOjYLd8b5V9Im8wdCHYy7LRFxhEtGb~RL55DA8aYOgEXcTpr6RPPywbV~Qf3q5UK55el6Kex-6VCxreUnPEe4hmTAbqZNR7Fm0hpCiHKGoToRcygafpFqDw5frLXToYiqs9d4liyVB-BcOb0ihORbo0nS3CLmAwZGvdAP8BZ7cIYE3Z9IU9D1G8JCMxWarfKX1pix~6pIA-sp1gKlL1HhYhPMxwyxvuSqx34o3BqU7vdTYwWiLpGM~zU1~j9rHL7x60pVuYaXcFQDR4-QVy26b6Pt6BlAZoFmHhPcAuWfu-SFhjyZYsqzmEmHeYdAwa~HojSbofg0TMUgESRXMw6YThK1KXWeeJVeztGTz25sL8AAAA.i2p/announce.php=http://tracker.postman.i2p/"
|
||||
|
@ -72,6 +72,7 @@ public class TrackerClient implements Runnable {
|
||||
private static final String STOPPED_EVENT = "stopped";
|
||||
private static final String NOT_REGISTERED = "torrent not registered"; //bytemonsoon
|
||||
private static final String NOT_REGISTERED_2 = "torrent not found"; // diftracker
|
||||
private static final String NOT_REGISTERED_3 = "torrent unauthorised"; // vuze
|
||||
/** this is our equivalent to router.utorrent.com for bootstrap */
|
||||
private static final String DEFAULT_BACKUP_TRACKER = "http://tracker.welterde.i2p/a";
|
||||
|
||||
@ -577,14 +578,19 @@ public class TrackerClient implements Runnable {
|
||||
if (tr.isPrimary)
|
||||
snark.setTrackerProblems(tr.trackerProblems);
|
||||
String tplc = tr.trackerProblems.toLowerCase(Locale.US);
|
||||
if (tplc.startsWith(NOT_REGISTERED) || tplc.startsWith(NOT_REGISTERED_2)) {
|
||||
if (tplc.startsWith(NOT_REGISTERED) || tplc.startsWith(NOT_REGISTERED_2) ||
|
||||
tplc.startsWith(NOT_REGISTERED_3)) {
|
||||
// Give a guy some time to register it if using opentrackers too
|
||||
//if (trckrs.size() == 1) {
|
||||
// stop = true;
|
||||
// snark.stopTorrent();
|
||||
//} else { // hopefully each on the opentrackers list is really open
|
||||
if (tr.registerFails++ > MAX_REGISTER_FAILS ||
|
||||
!completed || // no use retrying if we aren't seeding
|
||||
(!tr.isPrimary && tr.registerFails > MAX_REGISTER_FAILS / 2))
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Not longer announcing to " + tr.announce + " : " +
|
||||
tr.trackerProblems + " after " + tr.registerFails + " failures");
|
||||
tr.stop = true;
|
||||
//
|
||||
}
|
||||
|
@ -25,8 +25,10 @@ import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import net.i2p.data.Base32;
|
||||
import net.i2p.data.Base64;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
import org.klomp.snark.I2PSnarkUtil;
|
||||
@ -1717,8 +1719,10 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
}
|
||||
|
||||
/**
|
||||
* Start of anchor only, caller must add anchor text or img and close anchor
|
||||
* @return string or null
|
||||
* Generate link to details page if we know it supports it.
|
||||
* Start of anchor only, caller must add anchor text or img and close anchor.
|
||||
*
|
||||
* @return string or null if unknown tracker
|
||||
* @since 0.8.4
|
||||
*/
|
||||
private String getTrackerLinkUrl(String announce, byte[] infohash) {
|
||||
@ -1745,8 +1749,8 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
}
|
||||
|
||||
/**
|
||||
* Full anchor with img
|
||||
* @return string or null
|
||||
* Full link to details page with img
|
||||
* @return string or null if details page unsupported
|
||||
* @since 0.8.4
|
||||
*/
|
||||
private String getTrackerLink(String announce, byte[] infohash) {
|
||||
@ -1762,7 +1766,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
}
|
||||
|
||||
/**
|
||||
* Full anchor with shortened URL as anchor text
|
||||
* Full anchor to home page or details page with shortened host name as anchor text
|
||||
* @return string, non-null
|
||||
* @since 0.9.5
|
||||
*/
|
||||
@ -1771,14 +1775,37 @@ public class I2PSnarkServlet extends BasicServlet {
|
||||
String trackerLinkUrl = getTrackerLinkUrl(announce, infohash);
|
||||
if (announce.startsWith("http://"))
|
||||
announce = announce.substring(7);
|
||||
// strip path
|
||||
int slsh = announce.indexOf('/');
|
||||
if (slsh > 0)
|
||||
announce = announce.substring(0, slsh);
|
||||
if (trackerLinkUrl != null)
|
||||
if (trackerLinkUrl != null) {
|
||||
buf.append(trackerLinkUrl);
|
||||
else
|
||||
// TODO encode
|
||||
buf.append("<a href=\"http://").append(urlEncode(announce)).append("/\">");
|
||||
} else {
|
||||
// browsers don't like a full b64 dest, so convert it to b32
|
||||
String host = announce;
|
||||
if (host.length() >= 516) {
|
||||
int colon = announce.indexOf(':');
|
||||
String port = "";
|
||||
if (colon > 0) {
|
||||
port = host.substring(colon);
|
||||
host = host.substring(0, colon);
|
||||
}
|
||||
if (host.endsWith(".i2p"))
|
||||
host = host.substring(0, host.length() - 4);
|
||||
byte[] b = Base64.decode(host);
|
||||
if (b != null) {
|
||||
Hash h = _context.sha().calculateHash(b);
|
||||
// should we add the port back or strip it?
|
||||
host = Base32.encode(h.getData()) + ".b32.i2p" + port;
|
||||
}
|
||||
}
|
||||
buf.append("<a href=\"http://").append(urlEncode(host)).append("/\">");
|
||||
}
|
||||
// strip port
|
||||
int colon = announce.indexOf(':');
|
||||
if (colon > 0)
|
||||
announce = announce.substring(0, colon);
|
||||
if (announce.length() > 67)
|
||||
announce = DataHelper.escapeHTML(announce.substring(0, 40)) + "…" +
|
||||
DataHelper.escapeHTML(announce.substring(announce.length() - 8));
|
||||
|
Reference in New Issue
Block a user