forked from I2P_Developers/i2p.i2p
cleanups
This commit is contained in:
@@ -30,7 +30,8 @@ abstract class ExtensionHandler {
|
|||||||
public static final int ID_METADATA = 1;
|
public static final int ID_METADATA = 1;
|
||||||
public static final String TYPE_METADATA = "ut_metadata";
|
public static final String TYPE_METADATA = "ut_metadata";
|
||||||
public static final int ID_PEX = 2;
|
public static final int ID_PEX = 2;
|
||||||
public static final String TYPE_PEX = "ut_pex";
|
/** not ut_pex since the compact format is different */
|
||||||
|
public static final String TYPE_PEX = "i2p_pex";
|
||||||
/** Pieces * SHA1 Hash length, + 25% extra for file names, benconding overhead, etc */
|
/** Pieces * SHA1 Hash length, + 25% extra for file names, benconding overhead, etc */
|
||||||
private static final int MAX_METADATA_SIZE = Storage.MAX_PIECES * 20 * 5 / 4;
|
private static final int MAX_METADATA_SIZE = Storage.MAX_PIECES * 20 * 5 / 4;
|
||||||
private static final int PARALLEL_REQUESTS = 3;
|
private static final int PARALLEL_REQUESTS = 3;
|
||||||
|
@@ -72,7 +72,7 @@ public class I2PSnarkUtil {
|
|||||||
public static final int DEFAULT_MAX_UP_BW = 8; //KBps
|
public static final int DEFAULT_MAX_UP_BW = 8; //KBps
|
||||||
public static final int MAX_CONNECTIONS = 16; // per torrent
|
public static final int MAX_CONNECTIONS = 16; // per torrent
|
||||||
private static final String PROP_MAX_BW = "i2cp.outboundBytesPerSecond";
|
private static final String PROP_MAX_BW = "i2cp.outboundBytesPerSecond";
|
||||||
private static final boolean ENABLE_DHT = true;
|
//private static final boolean ENABLE_DHT = true;
|
||||||
|
|
||||||
public I2PSnarkUtil(I2PAppContext ctx) {
|
public I2PSnarkUtil(I2PAppContext ctx) {
|
||||||
_context = ctx;
|
_context = ctx;
|
||||||
|
@@ -79,6 +79,8 @@ public class Peer implements Comparable
|
|||||||
static final long OPTION_EXTENSION = 0x0000000000100000l;
|
static final long OPTION_EXTENSION = 0x0000000000100000l;
|
||||||
static final long OPTION_FAST = 0x0000000000000004l;
|
static final long OPTION_FAST = 0x0000000000000004l;
|
||||||
static final long OPTION_DHT = 0x0000000000000001l;
|
static final long OPTION_DHT = 0x0000000000000001l;
|
||||||
|
/** we use a different bit since the compact format is different */
|
||||||
|
static final long OPTION_I2P_DHT = 0x0000000040000000l;
|
||||||
static final long OPTION_AZMP = 0x1000000000000000l;
|
static final long OPTION_AZMP = 0x1000000000000000l;
|
||||||
private long options;
|
private long options;
|
||||||
|
|
||||||
@@ -269,7 +271,7 @@ public class Peer implements Comparable
|
|||||||
out.sendExtension(0, ExtensionHandler.getHandshake(metasize));
|
out.sendExtension(0, ExtensionHandler.getHandshake(metasize));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((options & OPTION_DHT) != 0 && util.getDHT() != null) {
|
if ((options & OPTION_I2P_DHT) != 0 && util.getDHT() != null) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("Peer supports DHT, sending PORT message");
|
_log.debug("Peer supports DHT, sending PORT message");
|
||||||
int port = util.getDHT().getPort();
|
int port = util.getDHT().getPort();
|
||||||
@@ -327,8 +329,11 @@ public class Peer implements Comparable
|
|||||||
dout.write(19);
|
dout.write(19);
|
||||||
dout.write("BitTorrent protocol".getBytes("UTF-8"));
|
dout.write("BitTorrent protocol".getBytes("UTF-8"));
|
||||||
// Handshake write - options
|
// Handshake write - options
|
||||||
// FIXME not if DHT disabled
|
long myOptions = OPTION_EXTENSION;
|
||||||
dout.writeLong(OPTION_EXTENSION | OPTION_DHT);
|
// FIXME get util here somehow
|
||||||
|
//if (util.getDHT() != null)
|
||||||
|
// myOptions |= OPTION_I2P_DHT;
|
||||||
|
dout.writeLong(myOptions);
|
||||||
// Handshake write - metainfo hash
|
// Handshake write - metainfo hash
|
||||||
dout.write(infohash);
|
dout.write(infohash);
|
||||||
// Handshake write - peer id
|
// Handshake write - peer id
|
||||||
|
@@ -750,8 +750,7 @@ public class SnarkManager implements Snark.CompleteListener {
|
|||||||
* Must be a filesystem-safe name.
|
* Must be a filesystem-safe name.
|
||||||
* @since 0.8.4
|
* @since 0.8.4
|
||||||
*/
|
*/
|
||||||
private void locked_writeMetaInfo(MetaInfo metainfo, String filename) throws IOException {
|
private static void locked_writeMetaInfo(MetaInfo metainfo, String filename) throws IOException {
|
||||||
// prevent interference by DirMonitor
|
|
||||||
File file = new File(filename);
|
File file = new File(filename);
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
throw new IOException("Cannot overwrite an existing .torrent file: " + file.getPath());
|
throw new IOException("Cannot overwrite an existing .torrent file: " + file.getPath());
|
||||||
@@ -1313,7 +1312,6 @@ public class SnarkManager implements Snark.CompleteListener {
|
|||||||
if ( (snark != null) && (!snark.isStopped()) )
|
if ( (snark != null) && (!snark.isStopped()) )
|
||||||
snark.stopTorrent();
|
snark.stopTorrent();
|
||||||
}
|
}
|
||||||
//save magnets
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
package org.klomp.snark.dht;
|
package org.klomp.snark.dht;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 zzz (zzz@mail.i2p)
|
|
||||||
* GPLv2
|
* GPLv2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user