Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this pluggin not fully implement transmission rpc-spec #1

Open
dm9pZCAq opened this issue Dec 29, 2021 · 0 comments
Open

this pluggin not fully implement transmission rpc-spec #1

dm9pZCAq opened this issue Dec 29, 2021 · 0 comments

Comments

@dm9pZCAq
Copy link

here is spec: https://github.com/transmission/transmission/blob/2.8x/extras/rpc-spec.txt#L281-L308

and here is commented code which followed spec

/****
private Object torrentGet_trackerStats(Snark download) {
List tracker_stats = new ArrayList();
List<TrackerPeerSource> trackerPeerSources = core_download.getTrackerPeerSources();
if (trackerPeerSources == null) {
return tracker_stats;
}
for (TrackerPeerSource tps : trackerPeerSources) {
String statusString = tps.getStatusString();
if (statusString == null) {
statusString = "";
}
Map<String, Object> map = new HashMap<String, Object>( 64 );
// how many downloads this tracker knows of (-1 means it does not know)
map.put("downloadCount", -1); // TODO
// whether or not we've ever sent this tracker an announcement
map.put("hasAnnounced", tps.getPeers() >= 0); // TODO
// whether or not we've ever scraped to this tracker
map.put("hasScraped", false); // todo: bool);
String name = "";
try {
name = tps.getName();
} catch (Exception e) {
// NPE at com.aelitis.azureus.plugins.extseed.ExternalSeedPlugin$5.getName(ExternalSeedPlugin.java:561
}
// human-readable string identifying the tracker
map.put("host", name); // TODO
// the full announce URL
map.put("announce", name); // TODO
// the full scrape URL
map.put("scrape", name); // TODO
// Transmission uses one tracker per tier,
// and the others are kept as backups
map.put("isBackup", false); // TODO
// is the tracker announcing, waiting, queued, etc
int status = tps.getStatus();
int state;
if (status == tps.ST_AVAILABLE || status == tps.ST_ONLINE) {
state = TR_TRACKER_WAITING;
} else if (status == tps.ST_UPDATING) {
state = TR_TRACKER_ACTIVE;
} else if (status == tps.ST_QUEUED) {
state = TR_TRACKER_QUEUED;
} else {
state = TR_TRACKER_INACTIVE;
}
map.put("announceState", state);
// is the tracker scraping, waiting, queued, etc
map.put("scrapeState", state);
// number of peers the tracker told us about last time.
// if "lastAnnounceSucceeded" is false, this field is undefined
map.put("lastAnnouncePeerCount", tps.getPeers());
// human-readable string with the result of the last announce.
// if "hasAnnounced" is false, this field is undefined
if (statusString != null) {
map.put("lastAnnounceResult", statusString);
}
// when the last announce was sent to the tracker.
// if "hasAnnounced" is false, this field is undefined
map.put("lastAnnounceStartTime", 0); // TODO: time_t);
// whether or not the last announce was a success.
// if "hasAnnounced" is false, this field is undefined
map.put("lastAnnounceSucceeded", tps.getPeers() >= 0);
// whether or not the last announce timed out.
map.put("lastAnnounceTimedOut", false); // TODO
// when the last announce was completed.
.. if "hasAnnounced" is false, this field is undefined
map.put("lastAnnounceTime", 0); // TODO: time_t);
// human-readable string with the result of the last scrape.
// if "hasScraped" is false, this field is undefined
if (statusString != null) {
map.put("lastScrapeResult", statusString);
}
// when the last scrape was sent to the tracker.
// if "hasScraped" is false, this field is undefined/
map.put("lastScrapeStartTime", 0); // TODO: time_t);
// whether or not the last scrape was a success.
// if "hasAnnounced" is false, this field is undefined
map.put("lastScrapeSucceeded", tps.getPeers() >= 0);
// whether or not the last scrape timed out.
map.put("lastScrapeTimedOut", false); // TODO: bool);
// when the last scrape was completed.
// if "hasScraped" is false, this field is undefined
map.put("lastScrapeTime", 0); // TODO: time_t);
// number of leechers this tracker knows of (-1 means it does not know)
map.put("leecherCount", tps.getLeecherCount());
// when the next periodic announce message will be sent out.
// if announceState isn't TR_TRACKER_WAITING, this field is undefined
map.put("nextAnnounceTime", 0); // TODO: time_t);
// when the next periodic scrape message will be sent out.
// if scrapeState isn't TR_TRACKER_WAITING, this field is undefined
map.put("nextScrapeTime", 0); // TODO: time_t);
// number of seeders this tracker knows of (-1 means it does not know)
map.put("seederCount", tps.getSeedCount());
// which tier this tracker is in
map.put("tier", 0); // TODO: int);
// used to match to a tr_tracker_info
map.put("id", tps.hashCode());
tracker_stats.add(map);
}
return tracker_stats;
}
****/

but here is used another function

} else if (field.equals("trackerStats")) {
// RPC v7
//value = torrentGet_trackerStats(core_download);
// just do the same as 'trackers' for now
String agent = request.getHeader("User-Agent");
boolean hack = agent != null && agent.contains("httpok"); // Torrnado
value = torrentGet_trackers(download, hack);

// just do the same as 'trackers' for now

why?


and due to this rpc returns incomplete response

{
 'trackerStats': [{'announce': '...',
                   'id': 687183153,
                   'scrape': '',
                   'tier': 0}],
}

which causes issues like this rndusr/stig/pull/215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant