2005-12-15 jrandom

* Added multitorrent support to I2PSnark, accessible currently by running
      "i2psnark.jar --config i2psnark.config" (which may or may not exist).
      It then joins the swarm for any torrents in ./i2psnark/*.torrent, saving
      their data in that directory as well.  Removing the .torrent file stops
      participation, and it is currently set to seed indefinitely.  Completion
      is logged to the logger and standard output, with further UI interaction
      left to the (work in progress) web UI.
This commit is contained in:
jrandom
2005-12-15 08:58:30 +00:00
committed by zzz
parent 369b6930e5
commit b37bb9372e
11 changed files with 545 additions and 49 deletions

View File

@@ -64,6 +64,13 @@ public class TrackerClient extends Thread
stop = false;
}
public void start() {
stop = false;
super.start();
}
public boolean halted() { return stop; }
/**
* Interrupts this Thread to stop it.
*/
@@ -100,9 +107,16 @@ public class TrackerClient extends Thread
TrackerInfo info = doRequest(announce, infoHash, peerID,
uploaded, downloaded, left,
STARTED_EVENT);
Iterator it = info.getPeers().iterator();
while (it.hasNext())
coordinator.addPeer((Peer)it.next());
if (!completed) {
Iterator it = info.getPeers().iterator();
while (it.hasNext()) {
Peer cur = (Peer)it.next();
coordinator.addPeer(cur);
int delay = 3000;
int c = ((int)cur.getPeerID().getAddress().calculateHash().toBase64().charAt(0)) % 10;
try { Thread.sleep(delay * c); } catch (InterruptedException ie) {}
}
}
started = true;
}
catch (IOException ioe)
@@ -168,9 +182,18 @@ public class TrackerClient extends Thread
uploaded, downloaded, left,
event);
Iterator it = info.getPeers().iterator();
while (it.hasNext())
coordinator.addPeer((Peer)it.next());
if ( (left > 0) && (!completed) ) {
// we only want to talk to new people if we need things
// from them (duh)
Iterator it = info.getPeers().iterator();
while (it.hasNext()) {
Peer cur = (Peer)it.next();
coordinator.addPeer(cur);
int delay = 3000;
int c = ((int)cur.getPeerID().getAddress().calculateHash().toBase64().charAt(0)) % 10;
try { Thread.sleep(delay * c); } catch (InterruptedException ie) {}
}
}
}
catch (IOException ioe)
{