forked from I2P_Developers/i2p.i2p
* Reseed, peermanager, transport, ntcp, udp, tunnel, tunnel pool
- Findbugs - Replace "ghetto" mark/reset - Remove dead code in TrivialPreprocessor - More efficient UDP peer sort - finals
This commit is contained in:
@ -100,7 +100,7 @@ public class ConfigNetHelper extends HelperBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getTcpAutoIPChecked(int mode) {
|
public String getTcpAutoIPChecked(int mode) {
|
||||||
boolean enabled = TransportManager.enableNTCP(_context);
|
boolean enabled = TransportManager.isNTCPEnabled(_context);
|
||||||
String hostname = _context.getProperty(PROP_I2NP_NTCP_HOSTNAME);
|
String hostname = _context.getProperty(PROP_I2NP_NTCP_HOSTNAME);
|
||||||
boolean specified = hostname != null && hostname.length() > 0;
|
boolean specified = hostname != null && hostname.length() > 0;
|
||||||
String auto = _context.getProperty(PROP_I2NP_NTCP_AUTO_IP, "false");
|
String auto = _context.getProperty(PROP_I2NP_NTCP_AUTO_IP, "false");
|
||||||
|
@ -3,6 +3,7 @@ package net.i2p.router.networkdb.reseed;
|
|||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -278,7 +279,7 @@ public class Reseeder {
|
|||||||
if (fetched % 60 == 0)
|
if (fetched % 60 == 0)
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,20 +299,20 @@ public class Reseeder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Since we don't return a value, we should always throw an exception if something fails. */
|
/* Since we don't return a value, we should always throw an exception if something fails. */
|
||||||
private void fetchSeed(String seedURL, String peer) throws Exception {
|
private void fetchSeed(String seedURL, String peer) throws IOException {
|
||||||
URL url = new URL(seedURL + (seedURL.endsWith("/") ? "" : "/") + "routerInfo-" + peer + ".dat");
|
URL url = new URL(seedURL + (seedURL.endsWith("/") ? "" : "/") + "routerInfo-" + peer + ".dat");
|
||||||
|
|
||||||
byte data[] = readURL(url);
|
byte data[] = readURL(url);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
// Logging deprecated here since attemptFailed() provides better info
|
// Logging deprecated here since attemptFailed() provides better info
|
||||||
_log.debug("Failed fetching seed: " + url.toString());
|
_log.debug("Failed fetching seed: " + url.toString());
|
||||||
throw new Exception ("Failed fetching seed.");
|
throw new IOException("Failed fetching seed.");
|
||||||
}
|
}
|
||||||
//System.out.println("read: " + (data != null ? data.length : -1));
|
//System.out.println("read: " + (data != null ? data.length : -1));
|
||||||
writeSeed(peer, data);
|
writeSeed(peer, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] readURL(URL url) throws Exception {
|
private byte[] readURL(URL url) throws IOException {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(4*1024);
|
ByteArrayOutputStream baos = new ByteArrayOutputStream(4*1024);
|
||||||
|
|
||||||
EepGet get;
|
EepGet get;
|
||||||
@ -338,15 +339,21 @@ public class Reseeder {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeSeed(String name, byte data[]) throws Exception {
|
private void writeSeed(String name, byte data[]) throws IOException {
|
||||||
String dirName = "netDb"; // _context.getProperty("router.networkDatabase.dbDir", "netDb");
|
String dirName = "netDb"; // _context.getProperty("router.networkDatabase.dbDir", "netDb");
|
||||||
File netDbDir = new SecureDirectory(_context.getRouterDir(), dirName);
|
File netDbDir = new SecureDirectory(_context.getRouterDir(), dirName);
|
||||||
if (!netDbDir.exists()) {
|
if (!netDbDir.exists()) {
|
||||||
boolean ok = netDbDir.mkdirs();
|
boolean ok = netDbDir.mkdirs();
|
||||||
}
|
}
|
||||||
FileOutputStream fos = new SecureFileOutputStream(new File(netDbDir, "routerInfo-" + name + ".dat"));
|
FileOutputStream fos = null;
|
||||||
|
try {
|
||||||
|
fos = new SecureFileOutputStream(new File(netDbDir, "routerInfo-" + name + ".dat"));
|
||||||
fos.write(data);
|
fos.write(data);
|
||||||
fos.close();
|
} finally {
|
||||||
|
try {
|
||||||
|
if (fos != null) fos.close();
|
||||||
|
} catch (IOException ioe) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -484,14 +484,17 @@ public class PeerProfile {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { return (_peer == null ? 0 : _peer.hashCode()); }
|
public int hashCode() { return (_peer == null ? 0 : _peer.hashCode()); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj == null) return false;
|
if (obj == null ||
|
||||||
if (obj.getClass() != PeerProfile.class) return false;
|
(!(obj instanceof PeerProfile)) ||
|
||||||
if (_peer == null) return false;
|
_peer == null)
|
||||||
|
return false;
|
||||||
PeerProfile prof = (PeerProfile)obj;
|
PeerProfile prof = (PeerProfile)obj;
|
||||||
return _peer.equals(prof.getPeer());
|
return _peer.equals(prof.getPeer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() { return "Profile: " + getPeer().toBase64(); }
|
public String toString() { return "Profile: " + getPeer().toBase64(); }
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package net.i2p.router.peermanager;
|
package net.i2p.router.peermanager;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -270,11 +272,12 @@ class ProfilePersistenceHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadProps(Properties props, File file) {
|
private void loadProps(Properties props, File file) {
|
||||||
|
InputStream fin = null;
|
||||||
try {
|
try {
|
||||||
FileInputStream fin = new FileInputStream(file);
|
fin = new BufferedInputStream(new FileInputStream(file), 1);
|
||||||
|
fin.mark(1);
|
||||||
int c = fin.read();
|
int c = fin.read();
|
||||||
fin.close();
|
fin.reset();
|
||||||
fin = new FileInputStream(file); // ghetto mark+reset
|
|
||||||
if (c == '#') {
|
if (c == '#') {
|
||||||
// uncompressed
|
// uncompressed
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.INFO))
|
||||||
@ -289,6 +292,10 @@ class ProfilePersistenceHelper {
|
|||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Error loading properties from " + file.getName(), ioe);
|
_log.warn("Error loading properties from " + file.getName(), ioe);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (fin != null) fin.close();
|
||||||
|
} catch (IOException e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ public class CommSystemFacadeImpl extends CommSystemFacade {
|
|||||||
* This should really be moved to ntcp/NTCPTransport.java, why is it here?
|
* This should really be moved to ntcp/NTCPTransport.java, why is it here?
|
||||||
*/
|
*/
|
||||||
public static RouterAddress createNTCPAddress(RouterContext ctx) {
|
public static RouterAddress createNTCPAddress(RouterContext ctx) {
|
||||||
if (!TransportManager.enableNTCP(ctx)) return null;
|
if (!TransportManager.isNTCPEnabled(ctx)) return null;
|
||||||
String name = ctx.router().getConfigSetting(PROP_I2NP_NTCP_HOSTNAME);
|
String name = ctx.router().getConfigSetting(PROP_I2NP_NTCP_HOSTNAME);
|
||||||
String port = ctx.router().getConfigSetting(PROP_I2NP_NTCP_PORT);
|
String port = ctx.router().getConfigSetting(PROP_I2NP_NTCP_PORT);
|
||||||
/*
|
/*
|
||||||
|
@ -512,7 +512,7 @@ public abstract class TransportImpl implements Transport {
|
|||||||
public void markUnreachable(Hash peer) {
|
public void markUnreachable(Hash peer) {
|
||||||
long now = _context.clock().now();
|
long now = _context.clock().now();
|
||||||
synchronized (_unreachableEntries) {
|
synchronized (_unreachableEntries) {
|
||||||
_unreachableEntries.put(peer, new Long(now));
|
_unreachableEntries.put(peer, Long.valueOf(now));
|
||||||
}
|
}
|
||||||
markWasUnreachable(peer, true);
|
markWasUnreachable(peer, true);
|
||||||
}
|
}
|
||||||
|
@ -46,10 +46,10 @@ public class TransportManager implements TransportEventListener {
|
|||||||
private RouterContext _context;
|
private RouterContext _context;
|
||||||
private UPnPManager _upnpManager;
|
private UPnPManager _upnpManager;
|
||||||
|
|
||||||
|
/** default true */
|
||||||
public final static String PROP_ENABLE_UDP = "i2np.udp.enable";
|
public final static String PROP_ENABLE_UDP = "i2np.udp.enable";
|
||||||
|
/** default true */
|
||||||
public final static String PROP_ENABLE_NTCP = "i2np.ntcp.enable";
|
public final static String PROP_ENABLE_NTCP = "i2np.ntcp.enable";
|
||||||
public final static String DEFAULT_ENABLE_NTCP = "true";
|
|
||||||
public final static String DEFAULT_ENABLE_UDP = "true";
|
|
||||||
/** default true */
|
/** default true */
|
||||||
public final static String PROP_ENABLE_UPNP = "i2np.upnp.enable";
|
public final static String PROP_ENABLE_UPNP = "i2np.upnp.enable";
|
||||||
|
|
||||||
@ -80,37 +80,33 @@ public class TransportManager implements TransportEventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void configTransports() {
|
private void configTransports() {
|
||||||
String enableUDP = _context.router().getConfigSetting(PROP_ENABLE_UDP);
|
boolean enableUDP = _context.getBooleanPropertyDefaultTrue(PROP_ENABLE_UDP);
|
||||||
if (enableUDP == null)
|
if (enableUDP) {
|
||||||
enableUDP = DEFAULT_ENABLE_UDP;
|
|
||||||
if ("true".equalsIgnoreCase(enableUDP)) {
|
|
||||||
UDPTransport udp = new UDPTransport(_context);
|
UDPTransport udp = new UDPTransport(_context);
|
||||||
addTransport(udp);
|
addTransport(udp);
|
||||||
initializeAddress(udp);
|
initializeAddress(udp);
|
||||||
}
|
}
|
||||||
if (enableNTCP(_context))
|
if (isNTCPEnabled(_context))
|
||||||
addTransport(new NTCPTransport(_context));
|
addTransport(new NTCPTransport(_context));
|
||||||
if (_transports.isEmpty())
|
if (_transports.isEmpty())
|
||||||
_log.log(Log.CRIT, "No transports are enabled");
|
_log.log(Log.CRIT, "No transports are enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean enableNTCP(RouterContext ctx) {
|
public static boolean isNTCPEnabled(RouterContext ctx) {
|
||||||
String enableNTCP = ctx.router().getConfigSetting(PROP_ENABLE_NTCP);
|
return ctx.getBooleanPropertyDefaultTrue(PROP_ENABLE_NTCP);
|
||||||
if (enableNTCP == null)
|
|
||||||
enableNTCP = DEFAULT_ENABLE_NTCP;
|
|
||||||
return "true".equalsIgnoreCase(enableNTCP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeAddress(Transport t) {
|
private void initializeAddress(Transport t) {
|
||||||
String ips = Addresses.getAnyAddress();
|
String ips = Addresses.getAnyAddress();
|
||||||
if (ips == null)
|
if (ips == null)
|
||||||
return;
|
return;
|
||||||
InetAddress ia = null;
|
InetAddress ia;
|
||||||
try {
|
try {
|
||||||
ia = InetAddress.getByName(ips);
|
ia = InetAddress.getByName(ips);
|
||||||
} catch (UnknownHostException e) {return;}
|
} catch (UnknownHostException e) {
|
||||||
if (ia == null)
|
_log.error("UDP failed to bind to local address", e);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
byte[] ip = ia.getAddress();
|
byte[] ip = ia.getAddress();
|
||||||
t.externalAddressReceived(Transport.SOURCE_INTERFACE, ip, 0);
|
t.externalAddressReceived(Transport.SOURCE_INTERFACE, ip, 0);
|
||||||
}
|
}
|
||||||
|
@ -554,7 +554,10 @@ public class UPnP extends ControlPoint implements DeviceChangeListener, EventLis
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** non-blocking */
|
/**
|
||||||
|
* non-blocking
|
||||||
|
* @param ports non-null
|
||||||
|
*/
|
||||||
public void onChangePublicPorts(Set<ForwardPort> ports, ForwardPortCallback cb) {
|
public void onChangePublicPorts(Set<ForwardPort> ports, ForwardPortCallback cb) {
|
||||||
Set<ForwardPort> portsToDumpNow = null;
|
Set<ForwardPort> portsToDumpNow = null;
|
||||||
Set<ForwardPort> portsToForwardNow = null;
|
Set<ForwardPort> portsToForwardNow = null;
|
||||||
@ -568,7 +571,7 @@ public class UPnP extends ControlPoint implements DeviceChangeListener, EventLis
|
|||||||
portsToForward = ports;
|
portsToForward = ports;
|
||||||
portsToForwardNow = ports;
|
portsToForwardNow = ports;
|
||||||
portsToDumpNow = null;
|
portsToDumpNow = null;
|
||||||
} else if(ports == null || ports.isEmpty()) {
|
} else if(ports.isEmpty()) {
|
||||||
portsToDumpNow = portsToForward;
|
portsToDumpNow = portsToForward;
|
||||||
portsToForward = ports;
|
portsToForward = ports;
|
||||||
portsToForwardNow = null;
|
portsToForwardNow = null;
|
||||||
|
@ -87,8 +87,9 @@ public class UPnPManager {
|
|||||||
if (!_isRunning)
|
if (!_isRunning)
|
||||||
return;
|
return;
|
||||||
Set<ForwardPort> forwards = new HashSet(ports.size());
|
Set<ForwardPort> forwards = new HashSet(ports.size());
|
||||||
for (String style : ports.keySet()) {
|
for (Map.Entry<String, Integer> entry : ports.entrySet()) {
|
||||||
int port = ports.get(style).intValue();
|
String style = entry.getKey();
|
||||||
|
int port = entry.getValue().intValue();
|
||||||
int protocol = -1;
|
int protocol = -1;
|
||||||
if ("SSU".equals(style))
|
if ("SSU".equals(style))
|
||||||
protocol = ForwardPort.PROTOCOL_UDP_IPV4;
|
protocol = ForwardPort.PROTOCOL_UDP_IPV4;
|
||||||
@ -136,8 +137,9 @@ public class UPnPManager {
|
|||||||
_log.debug("No external address returned");
|
_log.debug("No external address returned");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ForwardPort fp : statuses.keySet()) {
|
for (Map.Entry<ForwardPort, ForwardPortStatus> entry : statuses.entrySet()) {
|
||||||
ForwardPortStatus fps = statuses.get(fp);
|
ForwardPort fp = entry.getKey();
|
||||||
|
ForwardPortStatus fps = entry.getValue();
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug(fp.name + " " + fp.protocol + " " + fp.portNumber +
|
_log.debug(fp.name + " " + fp.protocol + " " + fp.portNumber +
|
||||||
" status: " + fps.status + " reason: " + fps.reasonString + " ext port: " + fps.externalPort);
|
" status: " + fps.status + " reason: " + fps.reasonString + " ext port: " + fps.externalPort);
|
||||||
|
@ -69,7 +69,7 @@ import net.i2p.util.Log;
|
|||||||
* NOTE: Check info is unused.
|
* NOTE: Check info is unused.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class EstablishState {
|
class EstablishState {
|
||||||
private RouterContext _context;
|
private RouterContext _context;
|
||||||
private Log _log;
|
private Log _log;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ import net.i2p.util.Log;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class EventPumper implements Runnable {
|
class EventPumper implements Runnable {
|
||||||
private RouterContext _context;
|
private RouterContext _context;
|
||||||
private Log _log;
|
private Log _log;
|
||||||
private volatile boolean _alive;
|
private volatile boolean _alive;
|
||||||
|
@ -53,7 +53,7 @@ import net.i2p.util.Log;
|
|||||||
*</pre>
|
*</pre>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class NTCPConnection implements FIFOBandwidthLimiter.CompleteListener {
|
class NTCPConnection implements FIFOBandwidthLimiter.CompleteListener {
|
||||||
private final RouterContext _context;
|
private final RouterContext _context;
|
||||||
private final Log _log;
|
private final Log _log;
|
||||||
private SocketChannel _chan;
|
private SocketChannel _chan;
|
||||||
@ -1088,15 +1088,6 @@ public class NTCPConnection implements FIFOBandwidthLimiter.CompleteListener {
|
|||||||
// enqueueInfoMessage(); // this often?
|
// enqueueInfoMessage(); // this often?
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() { return System.identityHashCode(this); }
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if(obj == null) return false;
|
|
||||||
if(obj.getClass() != NTCPConnection.class) return false;
|
|
||||||
return obj == this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int MAX_HANDLERS = 4;
|
private static final int MAX_HANDLERS = 4;
|
||||||
private final static LinkedBlockingQueue<I2NPMessageHandler> _i2npHandlers = new LinkedBlockingQueue(MAX_HANDLERS);
|
private final static LinkedBlockingQueue<I2NPMessageHandler> _i2npHandlers = new LinkedBlockingQueue(MAX_HANDLERS);
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
* @author zzz
|
* @author zzz
|
||||||
*/
|
*/
|
||||||
public class NTCPSendFinisher {
|
class NTCPSendFinisher {
|
||||||
private static final int MIN_THREADS = 1;
|
private static final int MIN_THREADS = 1;
|
||||||
private static final int MAX_THREADS = 4;
|
private static final int MAX_THREADS = 4;
|
||||||
private final I2PAppContext _context;
|
private final I2PAppContext _context;
|
||||||
@ -31,7 +31,11 @@ public class NTCPSendFinisher {
|
|||||||
private final Log _log;
|
private final Log _log;
|
||||||
private static int _count;
|
private static int _count;
|
||||||
private ThreadPoolExecutor _executor;
|
private ThreadPoolExecutor _executor;
|
||||||
private static int _threads;
|
private static final int THREADS;
|
||||||
|
static {
|
||||||
|
long maxMemory = Runtime.getRuntime().maxMemory();
|
||||||
|
THREADS = (int) Math.max(MIN_THREADS, Math.min(MAX_THREADS, 1 + (maxMemory / (32*1024*1024))));
|
||||||
|
}
|
||||||
|
|
||||||
public NTCPSendFinisher(I2PAppContext context, NTCPTransport transport) {
|
public NTCPSendFinisher(I2PAppContext context, NTCPTransport transport) {
|
||||||
_context = context;
|
_context = context;
|
||||||
@ -42,9 +46,7 @@ public class NTCPSendFinisher {
|
|||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
_count = 0;
|
_count = 0;
|
||||||
long maxMemory = Runtime.getRuntime().maxMemory();
|
_executor = new CustomThreadPoolExecutor(THREADS);
|
||||||
_threads = (int) Math.max(MIN_THREADS, Math.min(MAX_THREADS, 1 + (maxMemory / (32*1024*1024))));
|
|
||||||
_executor = new CustomThreadPoolExecutor(_threads);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
@ -73,7 +75,7 @@ public class NTCPSendFinisher {
|
|||||||
private static class CustomThreadFactory implements ThreadFactory {
|
private static class CustomThreadFactory implements ThreadFactory {
|
||||||
public Thread newThread(Runnable r) {
|
public Thread newThread(Runnable r) {
|
||||||
Thread rv = Executors.defaultThreadFactory().newThread(r);
|
Thread rv = Executors.defaultThreadFactory().newThread(r);
|
||||||
rv.setName("NTCPSendFinisher " + (++_count) + '/' + _threads);
|
rv.setName("NTCPSendFinisher " + (++_count) + '/' + THREADS);
|
||||||
rv.setDaemon(true);
|
rv.setDaemon(true);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package net.i2p.router.transport.udp;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
@ -120,7 +121,7 @@ class ACKSender implements Runnable {
|
|||||||
try {
|
try {
|
||||||
// bulk operations may throw an exception
|
// bulk operations may throw an exception
|
||||||
_peersToACK.addAll(notYet);
|
_peersToACK.addAll(notYet);
|
||||||
} catch (Exception e) {}
|
} catch (NoSuchElementException nsee) {}
|
||||||
notYet.clear();
|
notYet.clear();
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -641,7 +641,7 @@ class EstablishmentManager {
|
|||||||
private void handlePendingIntro(OutboundEstablishState state) {
|
private void handlePendingIntro(OutboundEstablishState state) {
|
||||||
long nonce = _context.random().nextLong(MAX_NONCE);
|
long nonce = _context.random().nextLong(MAX_NONCE);
|
||||||
while (true) {
|
while (true) {
|
||||||
OutboundEstablishState old = _liveIntroductions.putIfAbsent(new Long(nonce), state);
|
OutboundEstablishState old = _liveIntroductions.putIfAbsent(Long.valueOf(nonce), state);
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
nonce = _context.random().nextLong(MAX_NONCE);
|
nonce = _context.random().nextLong(MAX_NONCE);
|
||||||
} else {
|
} else {
|
||||||
@ -669,7 +669,7 @@ class EstablishmentManager {
|
|||||||
}
|
}
|
||||||
public void timeReached() {
|
public void timeReached() {
|
||||||
// remove only if value equal to state
|
// remove only if value equal to state
|
||||||
boolean removed = _liveIntroductions.remove(new Long(_nonce), _state);
|
boolean removed = _liveIntroductions.remove(Long.valueOf(_nonce), _state);
|
||||||
if (removed) {
|
if (removed) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("Send intro for " + _state.getRemoteHostId().toString() + " timed out");
|
_log.debug("Send intro for " + _state.getRemoteHostId().toString() + " timed out");
|
||||||
@ -681,7 +681,7 @@ class EstablishmentManager {
|
|||||||
|
|
||||||
void receiveRelayResponse(RemoteHostId bob, UDPPacketReader reader) {
|
void receiveRelayResponse(RemoteHostId bob, UDPPacketReader reader) {
|
||||||
long nonce = reader.getRelayResponseReader().readNonce();
|
long nonce = reader.getRelayResponseReader().readNonce();
|
||||||
OutboundEstablishState state = _liveIntroductions.remove(new Long(nonce));
|
OutboundEstablishState state = _liveIntroductions.remove(Long.valueOf(nonce));
|
||||||
if (state == null)
|
if (state == null)
|
||||||
return; // already established
|
return; // already established
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class InboundMessageFragments /*implements UDPTransport.PartialACKSource */{
|
|||||||
|
|
||||||
for (int i = 0; i < fragments; i++) {
|
for (int i = 0; i < fragments; i++) {
|
||||||
long mid = data.readMessageId(i);
|
long mid = data.readMessageId(i);
|
||||||
Long messageId = new Long(mid);
|
Long messageId = Long.valueOf(mid);
|
||||||
|
|
||||||
if (_recentlyCompletedMessages.isKnown(mid)) {
|
if (_recentlyCompletedMessages.isKnown(mid)) {
|
||||||
_context.statManager().addRateData("udp.ignoreRecentDuplicate", 1, 0);
|
_context.statManager().addRateData("udp.ignoreRecentDuplicate", 1, 0);
|
||||||
|
@ -53,7 +53,7 @@ class IntroductionManager {
|
|||||||
_log.debug("Adding peer " + peer.getRemoteHostId() + ", weRelayToThemAs "
|
_log.debug("Adding peer " + peer.getRemoteHostId() + ", weRelayToThemAs "
|
||||||
+ peer.getWeRelayToThemAs() + ", theyRelayToUsAs " + peer.getTheyRelayToUsAs());
|
+ peer.getWeRelayToThemAs() + ", theyRelayToUsAs " + peer.getTheyRelayToUsAs());
|
||||||
if (peer.getWeRelayToThemAs() > 0)
|
if (peer.getWeRelayToThemAs() > 0)
|
||||||
_outbound.put(new Long(peer.getWeRelayToThemAs()), peer);
|
_outbound.put(Long.valueOf(peer.getWeRelayToThemAs()), peer);
|
||||||
if (peer.getTheyRelayToUsAs() > 0) {
|
if (peer.getTheyRelayToUsAs() > 0) {
|
||||||
_inbound.add(peer);
|
_inbound.add(peer);
|
||||||
}
|
}
|
||||||
@ -65,14 +65,14 @@ class IntroductionManager {
|
|||||||
_log.debug("removing peer " + peer.getRemoteHostId() + ", weRelayToThemAs "
|
_log.debug("removing peer " + peer.getRemoteHostId() + ", weRelayToThemAs "
|
||||||
+ peer.getWeRelayToThemAs() + ", theyRelayToUsAs " + peer.getTheyRelayToUsAs());
|
+ peer.getWeRelayToThemAs() + ", theyRelayToUsAs " + peer.getTheyRelayToUsAs());
|
||||||
if (peer.getWeRelayToThemAs() > 0)
|
if (peer.getWeRelayToThemAs() > 0)
|
||||||
_outbound.remove(new Long(peer.getWeRelayToThemAs()));
|
_outbound.remove(Long.valueOf(peer.getWeRelayToThemAs()));
|
||||||
if (peer.getTheyRelayToUsAs() > 0) {
|
if (peer.getTheyRelayToUsAs() > 0) {
|
||||||
_inbound.remove(peer);
|
_inbound.remove(peer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PeerState get(long id) {
|
public PeerState get(long id) {
|
||||||
return _outbound.get(new Long(id));
|
return _outbound.get(Long.valueOf(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -661,7 +661,6 @@ class PacketBuilder {
|
|||||||
*/
|
*/
|
||||||
public UDPPacket buildSessionDestroyPacket(PeerState peer) {
|
public UDPPacket buildSessionDestroyPacket(PeerState peer) {
|
||||||
UDPPacket packet = buildPacketHeader((byte)(UDPPacket.PAYLOAD_TYPE_SESSION_DESTROY << 4));
|
UDPPacket packet = buildPacketHeader((byte)(UDPPacket.PAYLOAD_TYPE_SESSION_DESTROY << 4));
|
||||||
byte data[] = packet.getPacket().getData();
|
|
||||||
int off = HEADER_SIZE;
|
int off = HEADER_SIZE;
|
||||||
|
|
||||||
StringBuilder msg = null;
|
StringBuilder msg = null;
|
||||||
|
@ -20,14 +20,14 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class PacketHandler {
|
class PacketHandler {
|
||||||
private RouterContext _context;
|
private final RouterContext _context;
|
||||||
private Log _log;
|
private final Log _log;
|
||||||
private UDPTransport _transport;
|
private final UDPTransport _transport;
|
||||||
private UDPEndpoint _endpoint;
|
private final UDPEndpoint _endpoint;
|
||||||
private EstablishmentManager _establisher;
|
private final EstablishmentManager _establisher;
|
||||||
private InboundMessageFragments _inbound;
|
private final InboundMessageFragments _inbound;
|
||||||
private PeerTestManager _testManager;
|
private final PeerTestManager _testManager;
|
||||||
private IntroductionManager _introManager;
|
private final IntroductionManager _introManager;
|
||||||
private boolean _keepReading;
|
private boolean _keepReading;
|
||||||
private final Handler[] _handlers;
|
private final Handler[] _handlers;
|
||||||
|
|
||||||
@ -337,6 +337,9 @@ class PacketHandler {
|
|||||||
_state = 30;
|
_state = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param state non-null
|
||||||
|
*/
|
||||||
private void receivePacket(UDPPacketReader reader, UDPPacket packet, InboundEstablishState state) {
|
private void receivePacket(UDPPacketReader reader, UDPPacket packet, InboundEstablishState state) {
|
||||||
receivePacket(reader, packet, state, true);
|
receivePacket(reader, packet, state, true);
|
||||||
}
|
}
|
||||||
@ -345,11 +348,12 @@ class PacketHandler {
|
|||||||
* Inbound establishing conn
|
* Inbound establishing conn
|
||||||
* Decrypt and validate the packet then call handlePacket()
|
* Decrypt and validate the packet then call handlePacket()
|
||||||
*
|
*
|
||||||
|
* @param state non-null
|
||||||
* @param allowFallback if it isn't valid for this establishment state, try as a non-establishment packet
|
* @param allowFallback if it isn't valid for this establishment state, try as a non-establishment packet
|
||||||
*/
|
*/
|
||||||
private void receivePacket(UDPPacketReader reader, UDPPacket packet, InboundEstablishState state, boolean allowFallback) {
|
private void receivePacket(UDPPacketReader reader, UDPPacket packet, InboundEstablishState state, boolean allowFallback) {
|
||||||
_state = 31;
|
_state = 31;
|
||||||
if ( (state != null) && (_log.shouldLog(Log.DEBUG)) ) {
|
if (_log.shouldLog(Log.DEBUG)) {
|
||||||
StringBuilder buf = new StringBuilder(128);
|
StringBuilder buf = new StringBuilder(128);
|
||||||
buf.append("Attempting to receive a packet on a known inbound state: ");
|
buf.append("Attempting to receive a packet on a known inbound state: ");
|
||||||
buf.append(state);
|
buf.append(state);
|
||||||
@ -388,10 +392,12 @@ class PacketHandler {
|
|||||||
/**
|
/**
|
||||||
* Outbound establishing conn
|
* Outbound establishing conn
|
||||||
* Decrypt and validate the packet then call handlePacket()
|
* Decrypt and validate the packet then call handlePacket()
|
||||||
|
*
|
||||||
|
* @param state non-null
|
||||||
*/
|
*/
|
||||||
private void receivePacket(UDPPacketReader reader, UDPPacket packet, OutboundEstablishState state) {
|
private void receivePacket(UDPPacketReader reader, UDPPacket packet, OutboundEstablishState state) {
|
||||||
_state = 35;
|
_state = 35;
|
||||||
if ( (state != null) && (_log.shouldLog(Log.DEBUG)) ) {
|
if (_log.shouldLog(Log.DEBUG)) {
|
||||||
StringBuilder buf = new StringBuilder(128);
|
StringBuilder buf = new StringBuilder(128);
|
||||||
buf.append("Attempting to receive a packet on a known outbound state: ");
|
buf.append("Attempting to receive a packet on a known outbound state: ");
|
||||||
buf.append(state);
|
buf.append(state);
|
||||||
|
@ -153,7 +153,7 @@ class PeerTestManager {
|
|||||||
_log.debug("Running test with bob = " + bobIP + ":" + bobPort + " " + test.getNonce());
|
_log.debug("Running test with bob = " + bobIP + ":" + bobPort + " " + test.getNonce());
|
||||||
while (_recentTests.size() > 16)
|
while (_recentTests.size() > 16)
|
||||||
_recentTests.poll();
|
_recentTests.poll();
|
||||||
_recentTests.offer(new Long(test.getNonce()));
|
_recentTests.offer(Long.valueOf(test.getNonce()));
|
||||||
|
|
||||||
sendTestToBob();
|
sendTestToBob();
|
||||||
|
|
||||||
@ -432,7 +432,7 @@ class PeerTestManager {
|
|||||||
testInfo.readIP(testIP, 0);
|
testInfo.readIP(testIP, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerTestState state = _activeTests.get(new Long(nonce));
|
PeerTestState state = _activeTests.get(Long.valueOf(nonce));
|
||||||
|
|
||||||
if (state == null) {
|
if (state == null) {
|
||||||
if ( (testIP == null) || (testPort <= 0) ) {
|
if ( (testIP == null) || (testPort <= 0) ) {
|
||||||
@ -441,7 +441,7 @@ class PeerTestManager {
|
|||||||
_log.debug("test IP/port are blank coming from " + from + ", assuming we are Bob and they are alice");
|
_log.debug("test IP/port are blank coming from " + from + ", assuming we are Bob and they are alice");
|
||||||
receiveFromAliceAsBob(from, testInfo, nonce, null);
|
receiveFromAliceAsBob(from, testInfo, nonce, null);
|
||||||
} else {
|
} else {
|
||||||
if (_recentTests.contains(new Long(nonce))) {
|
if (_recentTests.contains(Long.valueOf(nonce))) {
|
||||||
// ignore the packet, as its a holdover from a recently completed locally
|
// ignore the packet, as its a holdover from a recently completed locally
|
||||||
// initiated test
|
// initiated test
|
||||||
} else {
|
} else {
|
||||||
@ -536,7 +536,7 @@ class PeerTestManager {
|
|||||||
_log.debug("Receive from bob (" + from + ") as charlie, sending back to bob and sending to alice @ " + aliceIP + ":" + alicePort);
|
_log.debug("Receive from bob (" + from + ") as charlie, sending back to bob and sending to alice @ " + aliceIP + ":" + alicePort);
|
||||||
|
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
_activeTests.put(new Long(nonce), state);
|
_activeTests.put(Long.valueOf(nonce), state);
|
||||||
SimpleScheduler.getInstance().addEvent(new RemoveTest(nonce), MAX_CHARLIE_LIFETIME);
|
SimpleScheduler.getInstance().addEvent(new RemoveTest(nonce), MAX_CHARLIE_LIFETIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -615,7 +615,7 @@ class PeerTestManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
_activeTests.put(new Long(nonce), state);
|
_activeTests.put(Long.valueOf(nonce), state);
|
||||||
SimpleScheduler.getInstance().addEvent(new RemoveTest(nonce), MAX_CHARLIE_LIFETIME);
|
SimpleScheduler.getInstance().addEvent(new RemoveTest(nonce), MAX_CHARLIE_LIFETIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,7 +691,7 @@ class PeerTestManager {
|
|||||||
_nonce = nonce;
|
_nonce = nonce;
|
||||||
}
|
}
|
||||||
public void timeReached() {
|
public void timeReached() {
|
||||||
_activeTests.remove(new Long(_nonce));
|
_activeTests.remove(Long.valueOf(_nonce));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,21 +28,15 @@ final class RemoteHostId {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int rv = 0;
|
return DataHelper.hashCode(_ip) ^ DataHelper.hashCode(_peerHash) ^ _port;
|
||||||
for (int i = 0; _ip != null && i < _ip.length; i++)
|
|
||||||
rv += _ip[i] << i;
|
|
||||||
for (int i = 0; _peerHash != null && i < _peerHash.length; i++)
|
|
||||||
rv += _peerHash[i] << i;
|
|
||||||
rv += _port;
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
throw new NullPointerException("obj is null");
|
return false;
|
||||||
if (!(obj instanceof RemoteHostId))
|
if (!(obj instanceof RemoteHostId))
|
||||||
throw new ClassCastException("obj is a " + obj.getClass().getName());
|
return false;
|
||||||
RemoteHostId id = (RemoteHostId)obj;
|
RemoteHostId id = (RemoteHostId)obj;
|
||||||
return (_port == id.getPort()) && DataHelper.eq(_ip, id.getIP()) && DataHelper.eq(_peerHash, id.getPeerHash());
|
return (_port == id.getPort()) && DataHelper.eq(_ip, id.getIP()) && DataHelper.eq(_peerHash, id.getPeerHash());
|
||||||
}
|
}
|
||||||
|
@ -20,16 +20,16 @@ import net.i2p.util.SimpleTimer;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class UDPReceiver {
|
class UDPReceiver {
|
||||||
private RouterContext _context;
|
private final RouterContext _context;
|
||||||
private Log _log;
|
private final Log _log;
|
||||||
private DatagramSocket _socket;
|
private DatagramSocket _socket;
|
||||||
private String _name;
|
private String _name;
|
||||||
private final BlockingQueue<UDPPacket> _inboundQueue;
|
private final BlockingQueue<UDPPacket> _inboundQueue;
|
||||||
private boolean _keepRunning;
|
private boolean _keepRunning;
|
||||||
private Runner _runner;
|
private final Runner _runner;
|
||||||
private UDPTransport _transport;
|
private final UDPTransport _transport;
|
||||||
private static int __id;
|
private static int __id;
|
||||||
private int _id;
|
private final int _id;
|
||||||
private static final int TYPE_POISON = -99999;
|
private static final int TYPE_POISON = -99999;
|
||||||
|
|
||||||
public UDPReceiver(RouterContext ctx, UDPTransport transport, DatagramSocket socket, String name) {
|
public UDPReceiver(RouterContext ctx, UDPTransport transport, DatagramSocket socket, String name) {
|
||||||
@ -179,7 +179,6 @@ class UDPReceiver {
|
|||||||
msg.append(queueSize);
|
msg.append(queueSize);
|
||||||
msg.append(" queued for ");
|
msg.append(" queued for ");
|
||||||
msg.append(headPeriod);
|
msg.append(headPeriod);
|
||||||
if (_transport != null)
|
|
||||||
msg.append(" packet handlers: ").append(_transport.getPacketHandlerStatus());
|
msg.append(" packet handlers: ").append(_transport.getPacketHandlerStatus());
|
||||||
_log.warn(msg.toString());
|
_log.warn(msg.toString());
|
||||||
}
|
}
|
||||||
|
@ -1635,7 +1635,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final IdleInComparator _instance = new IdleInComparator();
|
private static final IdleInComparator _instance = new IdleInComparator();
|
||||||
public static final IdleInComparator instance() { return _instance; }
|
public static final IdleInComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = r.getLastReceiveTime() - l.getLastReceiveTime();
|
long rv = r.getLastReceiveTime() - l.getLastReceiveTime();
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1647,7 +1647,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final IdleOutComparator _instance = new IdleOutComparator();
|
private static final IdleOutComparator _instance = new IdleOutComparator();
|
||||||
public static final IdleOutComparator instance() { return _instance; }
|
public static final IdleOutComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = r.getLastSendTime() - l.getLastSendTime();
|
long rv = r.getLastSendTime() - l.getLastSendTime();
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1659,7 +1659,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final RateInComparator _instance = new RateInComparator();
|
private static final RateInComparator _instance = new RateInComparator();
|
||||||
public static final RateInComparator instance() { return _instance; }
|
public static final RateInComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = l.getReceiveBps() - r.getReceiveBps();
|
long rv = l.getReceiveBps() - r.getReceiveBps();
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1671,7 +1671,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final RateOutComparator _instance = new RateOutComparator();
|
private static final RateOutComparator _instance = new RateOutComparator();
|
||||||
public static final RateOutComparator instance() { return _instance; }
|
public static final RateOutComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = l.getSendBps() - r.getSendBps();
|
long rv = l.getSendBps() - r.getSendBps();
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1683,7 +1683,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final UptimeComparator _instance = new UptimeComparator();
|
private static final UptimeComparator _instance = new UptimeComparator();
|
||||||
public static final UptimeComparator instance() { return _instance; }
|
public static final UptimeComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = r.getKeyEstablishedTime() - l.getKeyEstablishedTime();
|
long rv = r.getKeyEstablishedTime() - l.getKeyEstablishedTime();
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1695,7 +1695,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final SkewComparator _instance = new SkewComparator();
|
private static final SkewComparator _instance = new SkewComparator();
|
||||||
public static final SkewComparator instance() { return _instance; }
|
public static final SkewComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = Math.abs(l.getClockSkew()) - Math.abs(r.getClockSkew());
|
long rv = Math.abs(l.getClockSkew()) - Math.abs(r.getClockSkew());
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1707,7 +1707,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final CwndComparator _instance = new CwndComparator();
|
private static final CwndComparator _instance = new CwndComparator();
|
||||||
public static final CwndComparator instance() { return _instance; }
|
public static final CwndComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = l.getSendWindowBytes() - r.getSendWindowBytes();
|
long rv = l.getSendWindowBytes() - r.getSendWindowBytes();
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1719,7 +1719,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final SsthreshComparator _instance = new SsthreshComparator();
|
private static final SsthreshComparator _instance = new SsthreshComparator();
|
||||||
public static final SsthreshComparator instance() { return _instance; }
|
public static final SsthreshComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = l.getSlowStartThreshold() - r.getSlowStartThreshold();
|
long rv = l.getSlowStartThreshold() - r.getSlowStartThreshold();
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1731,7 +1731,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final RTTComparator _instance = new RTTComparator();
|
private static final RTTComparator _instance = new RTTComparator();
|
||||||
public static final RTTComparator instance() { return _instance; }
|
public static final RTTComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = l.getRTT() - r.getRTT();
|
long rv = l.getRTT() - r.getRTT();
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1743,7 +1743,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final DevComparator _instance = new DevComparator();
|
private static final DevComparator _instance = new DevComparator();
|
||||||
public static final DevComparator instance() { return _instance; }
|
public static final DevComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = l.getRTTDeviation() - r.getRTTDeviation();
|
long rv = l.getRTTDeviation() - r.getRTTDeviation();
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1755,7 +1755,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final RTOComparator _instance = new RTOComparator();
|
private static final RTOComparator _instance = new RTOComparator();
|
||||||
public static final RTOComparator instance() { return _instance; }
|
public static final RTOComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = l.getRTO() - r.getRTO();
|
long rv = l.getRTO() - r.getRTO();
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1767,7 +1767,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final MTUComparator _instance = new MTUComparator();
|
private static final MTUComparator _instance = new MTUComparator();
|
||||||
public static final MTUComparator instance() { return _instance; }
|
public static final MTUComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = l.getMTU() - r.getMTU();
|
long rv = l.getMTU() - r.getMTU();
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1779,7 +1779,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final SendCountComparator _instance = new SendCountComparator();
|
private static final SendCountComparator _instance = new SendCountComparator();
|
||||||
public static final SendCountComparator instance() { return _instance; }
|
public static final SendCountComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = l.getPacketsTransmitted() - r.getPacketsTransmitted();
|
long rv = l.getPacketsTransmitted() - r.getPacketsTransmitted();
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1791,7 +1791,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final RecvCountComparator _instance = new RecvCountComparator();
|
private static final RecvCountComparator _instance = new RecvCountComparator();
|
||||||
public static final RecvCountComparator instance() { return _instance; }
|
public static final RecvCountComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = l.getPacketsReceived() - r.getPacketsReceived();
|
long rv = l.getPacketsReceived() - r.getPacketsReceived();
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1803,7 +1803,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final ResendComparator _instance = new ResendComparator();
|
private static final ResendComparator _instance = new ResendComparator();
|
||||||
public static final ResendComparator instance() { return _instance; }
|
public static final ResendComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = l.getPacketsRetransmitted() - r.getPacketsRetransmitted();
|
long rv = l.getPacketsRetransmitted() - r.getPacketsRetransmitted();
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1815,7 +1815,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final DupComparator _instance = new DupComparator();
|
private static final DupComparator _instance = new DupComparator();
|
||||||
public static final DupComparator instance() { return _instance; }
|
public static final DupComparator instance() { return _instance; }
|
||||||
@Override
|
@Override
|
||||||
protected int compare(PeerState l, PeerState r) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
long rv = l.getPacketsReceivedDuplicate() - r.getPacketsReceivedDuplicate();
|
long rv = l.getPacketsReceivedDuplicate() - r.getPacketsReceivedDuplicate();
|
||||||
if (rv == 0) // fallback on alpha
|
if (rv == 0) // fallback on alpha
|
||||||
return super.compare(l, r);
|
return super.compare(l, r);
|
||||||
@ -1824,17 +1824,12 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PeerComparator implements Comparator {
|
private static class PeerComparator implements Comparator<PeerState> {
|
||||||
public int compare(Object lhs, Object rhs) {
|
public int compare(PeerState l, PeerState r) {
|
||||||
if ( (lhs == null) || (rhs == null) || !(lhs instanceof PeerState) || !(rhs instanceof PeerState))
|
return DataHelper.compareTo(l.getRemotePeer().getData(), r.getRemotePeer().getData());
|
||||||
throw new IllegalArgumentException("rhs = " + rhs + " lhs = " + lhs);
|
|
||||||
return compare((PeerState)lhs, (PeerState)rhs);
|
|
||||||
}
|
|
||||||
protected int compare(PeerState l, PeerState r) {
|
|
||||||
// base64 retains binary ordering
|
|
||||||
return l.getRemotePeer().toBase64().compareTo(r.getRemotePeer().toBase64());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class InverseComparator implements Comparator {
|
private static class InverseComparator implements Comparator {
|
||||||
private Comparator _comp;
|
private Comparator _comp;
|
||||||
public InverseComparator(Comparator comp) { _comp = comp; }
|
public InverseComparator(Comparator comp) { _comp = comp; }
|
||||||
|
@ -21,9 +21,6 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class BuildMessageGenerator {
|
public class BuildMessageGenerator {
|
||||||
// cached, rather than creating lots of temporary Integer objects whenever we build a tunnel
|
|
||||||
public static final Integer ORDER[] = new Integer[TunnelBuildMessage.MAX_RECORD_COUNT];
|
|
||||||
static { for (int i = 0; i < ORDER.length; i++) ORDER[i] = Integer.valueOf(i); }
|
|
||||||
|
|
||||||
/** return null if it is unable to find a router's public key (etc) */
|
/** return null if it is unable to find a router's public key (etc) */
|
||||||
/****
|
/****
|
||||||
|
@ -360,10 +360,10 @@ public class FragmentHandler {
|
|||||||
FragmentedMessage msg = null;
|
FragmentedMessage msg = null;
|
||||||
if (fragmented) {
|
if (fragmented) {
|
||||||
synchronized (_fragmentedMessages) {
|
synchronized (_fragmentedMessages) {
|
||||||
msg = _fragmentedMessages.get(new Long(messageId));
|
msg = _fragmentedMessages.get(Long.valueOf(messageId));
|
||||||
if (msg == null) {
|
if (msg == null) {
|
||||||
msg = new FragmentedMessage(_context);
|
msg = new FragmentedMessage(_context);
|
||||||
_fragmentedMessages.put(new Long(messageId), msg);
|
_fragmentedMessages.put(Long.valueOf(messageId), msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -377,7 +377,7 @@ public class FragmentHandler {
|
|||||||
if (!ok) return -1;
|
if (!ok) return -1;
|
||||||
if (msg.isComplete()) {
|
if (msg.isComplete()) {
|
||||||
synchronized (_fragmentedMessages) {
|
synchronized (_fragmentedMessages) {
|
||||||
_fragmentedMessages.remove(new Long(messageId));
|
_fragmentedMessages.remove(Long.valueOf(messageId));
|
||||||
}
|
}
|
||||||
if (msg.getExpireEvent() != null)
|
if (msg.getExpireEvent() != null)
|
||||||
SimpleTimer.getInstance().removeEvent(msg.getExpireEvent());
|
SimpleTimer.getInstance().removeEvent(msg.getExpireEvent());
|
||||||
@ -432,10 +432,10 @@ public class FragmentHandler {
|
|||||||
|
|
||||||
FragmentedMessage msg = null;
|
FragmentedMessage msg = null;
|
||||||
synchronized (_fragmentedMessages) {
|
synchronized (_fragmentedMessages) {
|
||||||
msg = _fragmentedMessages.get(new Long(messageId));
|
msg = _fragmentedMessages.get(Long.valueOf(messageId));
|
||||||
if (msg == null) {
|
if (msg == null) {
|
||||||
msg = new FragmentedMessage(_context);
|
msg = new FragmentedMessage(_context);
|
||||||
_fragmentedMessages.put(new Long(messageId), msg);
|
_fragmentedMessages.put(Long.valueOf(messageId), msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,7 +446,7 @@ public class FragmentHandler {
|
|||||||
|
|
||||||
if (msg.isComplete()) {
|
if (msg.isComplete()) {
|
||||||
synchronized (_fragmentedMessages) {
|
synchronized (_fragmentedMessages) {
|
||||||
_fragmentedMessages.remove(new Long(messageId));
|
_fragmentedMessages.remove(Long.valueOf(messageId));
|
||||||
}
|
}
|
||||||
if (msg.getExpireEvent() != null)
|
if (msg.getExpireEvent() != null)
|
||||||
SimpleTimer.getInstance().removeEvent(msg.getExpireEvent());
|
SimpleTimer.getInstance().removeEvent(msg.getExpireEvent());
|
||||||
@ -529,7 +529,7 @@ public class FragmentHandler {
|
|||||||
public void timeReached() {
|
public void timeReached() {
|
||||||
boolean removed = false;
|
boolean removed = false;
|
||||||
synchronized (_fragmentedMessages) {
|
synchronized (_fragmentedMessages) {
|
||||||
removed = (null != _fragmentedMessages.remove(new Long(_msg.getMessageId())));
|
removed = (null != _fragmentedMessages.remove(Long.valueOf(_msg.getMessageId())));
|
||||||
}
|
}
|
||||||
synchronized (_msg) {
|
synchronized (_msg) {
|
||||||
if (removed && !_msg.getReleased()) {
|
if (removed && !_msg.getReleased()) {
|
||||||
|
@ -73,7 +73,7 @@ public class HopConfig {
|
|||||||
}
|
}
|
||||||
public void setSendTunnelId(byte id[]) { _sendTunnelId = id; }
|
public void setSendTunnelId(byte id[]) { _sendTunnelId = id; }
|
||||||
|
|
||||||
private TunnelId getTunnel(byte id[]) {
|
private static TunnelId getTunnel(byte id[]) {
|
||||||
if (id == null)
|
if (id == null)
|
||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
|
@ -77,7 +77,7 @@ public class HopProcessor {
|
|||||||
boolean okIV = _validator.receiveIV(orig, offset, orig, offset + IV_LENGTH);
|
boolean okIV = _validator.receiveIV(orig, offset, orig, offset + IV_LENGTH);
|
||||||
if (!okIV) {
|
if (!okIV) {
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
_log.warn("Invalid IV received on tunnel " + _config.getReceiveTunnelId());
|
_log.warn("Invalid IV received on tunnel " + _config.getReceiveTunnel());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,92 +52,11 @@ public class TrivialPreprocessor implements TunnelGateway.QueuePreprocessor {
|
|||||||
* NOTE: Unused here, see BatchedPreprocessor override, super is not called.
|
* NOTE: Unused here, see BatchedPreprocessor override, super is not called.
|
||||||
*/
|
*/
|
||||||
public boolean preprocessQueue(List<TunnelGateway.Pending> pending, TunnelGateway.Sender sender, TunnelGateway.Receiver rec) {
|
public boolean preprocessQueue(List<TunnelGateway.Pending> pending, TunnelGateway.Sender sender, TunnelGateway.Receiver rec) {
|
||||||
if (true) throw new IllegalArgumentException("unused, right?");
|
throw new IllegalArgumentException("unused, right?");
|
||||||
long begin = System.currentTimeMillis();
|
|
||||||
StringBuilder buf = null;
|
|
||||||
if (_log.shouldLog(Log.DEBUG)) {
|
|
||||||
buf = new StringBuilder(256);
|
|
||||||
buf.append("Trivial preprocessing of ").append(pending.size()).append(" ");
|
|
||||||
}
|
|
||||||
while (!pending.isEmpty()) {
|
|
||||||
TunnelGateway.Pending msg = pending.remove(0);
|
|
||||||
long beforePreproc = System.currentTimeMillis();
|
|
||||||
byte preprocessed[][] = preprocess(msg);
|
|
||||||
long afterPreproc = System.currentTimeMillis();
|
|
||||||
if (buf != null)
|
|
||||||
buf.append("preprocessed into " + preprocessed.length + " fragments after " + (afterPreproc-beforePreproc) + ". ");
|
|
||||||
for (int i = 0; i < preprocessed.length; i++) {
|
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
|
||||||
_log.debug("Preprocessed: fragment " + i + "/" + (preprocessed.length-1) + " in "
|
|
||||||
+ msg.getMessageId() + ": "
|
|
||||||
+ " send through " + sender + " receive with " + rec);
|
|
||||||
//Base64.encode(preprocessed[i]));
|
|
||||||
long beforeSend = System.currentTimeMillis();
|
|
||||||
long id = sender.sendPreprocessed(preprocessed[i], rec);
|
|
||||||
long afterSend = System.currentTimeMillis();
|
|
||||||
if (buf != null)
|
|
||||||
buf.append("send of " + msg.getMessageId() + " took " + (afterSend-beforeSend) + ". ");
|
|
||||||
msg.addMessageId(id);
|
|
||||||
}
|
|
||||||
notePreprocessing(msg.getMessageId(), msg.getFragmentNumber(), preprocessed.length, msg.getMessageIds(), null);
|
|
||||||
if (preprocessed.length != msg.getFragmentNumber() + 1) {
|
|
||||||
throw new RuntimeException("wtf, preprocessed " + msg.getMessageId() + " into "
|
|
||||||
+ msg.getFragmentNumber() + "/" + preprocessed.length + " fragments, size = "
|
|
||||||
+ msg.getData().length);
|
|
||||||
}
|
|
||||||
if (buf != null)
|
|
||||||
buf.append("all fragments sent after " + (System.currentTimeMillis()-afterPreproc) + ". ");
|
|
||||||
}
|
|
||||||
if (buf != null) {
|
|
||||||
buf.append("queue preprocessed after " + (System.currentTimeMillis()-begin) + ".");
|
|
||||||
_log.debug(buf.toString());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void notePreprocessing(long messageId, int numFragments, int totalLength, List<Long> messageIds, String msg) {}
|
protected void notePreprocessing(long messageId, int numFragments, int totalLength, List<Long> messageIds, String msg) {}
|
||||||
|
|
||||||
/*
|
|
||||||
* @deprecated unused except by above
|
|
||||||
*/
|
|
||||||
private byte[][] preprocess(TunnelGateway.Pending msg) {
|
|
||||||
List<byte[]> fragments = new ArrayList(1);
|
|
||||||
|
|
||||||
while (msg.getOffset() < msg.getData().length) {
|
|
||||||
fragments.add(preprocessFragment(msg));
|
|
||||||
//if (_log.shouldLog(Log.DEBUG))
|
|
||||||
// _log.debug("\n\nafter preprocessing fragment\n\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
byte rv[][] = new byte[fragments.size()][];
|
|
||||||
for (int i = 0; i < fragments.size(); i++)
|
|
||||||
rv[i] = fragments.get(i);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Preprocess the next available fragment off the given one in phases:
|
|
||||||
* First, write it out as { instructions + payload + random IV }, calculate the
|
|
||||||
* SHA256 of that, then move the instructions + payload to the end
|
|
||||||
* of the target, setting IV as the beginning. Then add the necessary random pad
|
|
||||||
* bytes after the IV, followed by the first 4 bytes of that SHA256, lining up
|
|
||||||
* exactly to meet the beginning of the instructions. (i hope)
|
|
||||||
*
|
|
||||||
* @deprecated unused except by above
|
|
||||||
*/
|
|
||||||
private byte[] preprocessFragment(TunnelGateway.Pending msg) {
|
|
||||||
byte target[] = _dataCache.acquire().getData();
|
|
||||||
|
|
||||||
int offset = 0;
|
|
||||||
if (msg.getOffset() <= 0)
|
|
||||||
offset = writeFirstFragment(msg, target, offset);
|
|
||||||
else
|
|
||||||
offset = writeSubsequentFragment(msg, target, offset);
|
|
||||||
|
|
||||||
preprocess(target, offset);
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap the preprocessed fragments with the necessary padding / checksums
|
* Wrap the preprocessed fragments with the necessary padding / checksums
|
||||||
* to act as a tunnel message.
|
* to act as a tunnel message.
|
||||||
|
@ -623,7 +623,7 @@ public class TunnelDispatcher implements Service {
|
|||||||
// drop in proportion to size w.r.t. a standard 1024-byte message
|
// drop in proportion to size w.r.t. a standard 1024-byte message
|
||||||
// this is a little expensive but we want to adjust the curve between 0 and 1
|
// this is a little expensive but we want to adjust the curve between 0 and 1
|
||||||
// Most messages are 1024, only at the OBEP do we see other sizes
|
// Most messages are 1024, only at the OBEP do we see other sizes
|
||||||
if (len != 1024d)
|
if ((int)len != 1024)
|
||||||
pctDrop = (float) Math.pow(pctDrop, 1024d / len);
|
pctDrop = (float) Math.pow(pctDrop, 1024d / len);
|
||||||
float rand = _context.random().nextFloat();
|
float rand = _context.random().nextFloat();
|
||||||
boolean reject = rand <= pctDrop;
|
boolean reject = rand <= pctDrop;
|
||||||
|
@ -294,7 +294,9 @@ class BuildExecutor implements Runnable {
|
|||||||
if (!_repoll) {
|
if (!_repoll) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("No tunnel to build with (allowed=" + allowed + ", wanted=" + wanted.size() + ", pending=" + pendingRemaining + "), wait for a while");
|
_log.debug("No tunnel to build with (allowed=" + allowed + ", wanted=" + wanted.size() + ", pending=" + pendingRemaining + "), wait for a while");
|
||||||
|
try {
|
||||||
_currentlyBuilding.wait(1*1000+_context.random().nextInt(1*1000));
|
_currentlyBuilding.wait(1*1000+_context.random().nextInt(1*1000));
|
||||||
|
} catch (InterruptedException ie) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -369,7 +371,7 @@ class BuildExecutor implements Runnable {
|
|||||||
|
|
||||||
wanted.clear();
|
wanted.clear();
|
||||||
pools.clear();
|
pools.clear();
|
||||||
} catch (Exception e) {
|
} catch (RuntimeException e) {
|
||||||
if (_log.shouldLog(Log.CRIT))
|
if (_log.shouldLog(Log.CRIT))
|
||||||
_log.log(Log.CRIT, "B0rked in the tunnel builder", e);
|
_log.log(Log.CRIT, "B0rked in the tunnel builder", e);
|
||||||
}
|
}
|
||||||
@ -459,7 +461,7 @@ class BuildExecutor implements Runnable {
|
|||||||
for (int i = 0; i < 32; i++)
|
for (int i = 0; i < 32; i++)
|
||||||
_recentBuildIds.remove(0);
|
_recentBuildIds.remove(0);
|
||||||
}
|
}
|
||||||
_recentBuildIds.add(new Long(id));
|
_recentBuildIds.add(Long.valueOf(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -483,7 +485,7 @@ class BuildExecutor implements Runnable {
|
|||||||
|
|
||||||
public boolean wasRecentlyBuilding(long replyId) {
|
public boolean wasRecentlyBuilding(long replyId) {
|
||||||
synchronized (_recentBuildIds) {
|
synchronized (_recentBuildIds) {
|
||||||
return _recentBuildIds.contains(new Long(replyId));
|
return _recentBuildIds.contains(Long.valueOf(replyId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@ import net.i2p.util.VersionComparator;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class BuildRequestor {
|
class BuildRequestor {
|
||||||
private static final List<Integer> ORDER = new ArrayList(BuildMessageGenerator.ORDER.length);
|
private static final List<Integer> ORDER = new ArrayList(TunnelBuildMessage.MAX_RECORD_COUNT);
|
||||||
static {
|
static {
|
||||||
for (int i = 0; i < BuildMessageGenerator.ORDER.length; i++)
|
for (int i = 0; i < TunnelBuildMessage.MAX_RECORD_COUNT; i++)
|
||||||
ORDER.add(Integer.valueOf(i));
|
ORDER.add(Integer.valueOf(i));
|
||||||
}
|
}
|
||||||
private static final int PRIORITY = 500;
|
private static final int PRIORITY = 500;
|
||||||
|
@ -464,9 +464,9 @@ public class TunnelPool {
|
|||||||
* but we use latest expiration first, since we need to sort them by that anyway.
|
* but we use latest expiration first, since we need to sort them by that anyway.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class LeaseComparator implements Comparator {
|
private static class LeaseComparator implements Comparator<Lease> {
|
||||||
public int compare(Object l, Object r) {
|
public int compare(Lease l, Lease r) {
|
||||||
return ((Lease)r).getEndDate().compareTo(((Lease)l).getEndDate());
|
return r.getEndDate().compareTo(l.getEndDate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user