forked from I2P_Developers/i2p.i2p
* i2psnark:
- Improved magnet link parsing, use tr parameter if present
This commit is contained in:
@ -643,11 +643,15 @@ public class SnarkManager implements Snark.CompleteListener {
|
||||
*
|
||||
* @param name hex or b32 name from the magnet link
|
||||
* @param ih 20 byte info hash
|
||||
* @param trackerURL may be null
|
||||
* @param udpateStatus should we add this magnet to the config file,
|
||||
* to save it across restarts, in case we don't get
|
||||
* the metadata before shutdown?
|
||||
* @throws RuntimeException via Snark.fatal()
|
||||
* @since 0.8.4
|
||||
*/
|
||||
public void addMagnet(String name, byte[] ih, boolean updateStatus) {
|
||||
Snark torrent = new Snark(_util, name, ih, this,
|
||||
public void addMagnet(String name, byte[] ih, String trackerURL, boolean updateStatus) {
|
||||
Snark torrent = new Snark(_util, name, ih, trackerURL, this,
|
||||
_peerCoordinatorSet, _connectionAcceptor,
|
||||
false, getDataDir().getPath());
|
||||
|
||||
@ -1151,6 +1155,10 @@ public class SnarkManager implements Snark.CompleteListener {
|
||||
saveTorrentStatus(meta, storage.getBitField(), null); // no file priorities
|
||||
String name = (new File(getDataDir(), storage.getBaseName() + ".torrent")).getAbsolutePath();
|
||||
try {
|
||||
// put the announce URL in the file
|
||||
String announce = snark.getTrackerURL();
|
||||
if (announce != null)
|
||||
meta = meta.reannounce(announce);
|
||||
synchronized (_snarks) {
|
||||
locked_writeMetaInfo(meta, name);
|
||||
// put it in the list under the new name
|
||||
@ -1183,9 +1191,9 @@ public class SnarkManager implements Snark.CompleteListener {
|
||||
String b64 = k.substring(PROP_META_MAGNET_PREFIX.length());
|
||||
b64 = b64.replace('$', '=');
|
||||
byte[] ih = Base64.decode(b64);
|
||||
// ignore value
|
||||
// ignore value - TODO put tracker URL in value
|
||||
if (ih != null && ih.length == 20)
|
||||
addMagnet("Magnet: " + I2PSnarkUtil.toHex(ih), ih, false);
|
||||
addMagnet("Magnet: " + I2PSnarkUtil.toHex(ih), ih, null, false);
|
||||
// else remove from config?
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user