2009-04-17 sponge
* Catch NPE in NTCP. This possibly augments fix 2009-04-11 welterde below. * Various LINT on NTCP sources, and removal of space-wasting spaces at end of lines in sources touched.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2009-04-17 sponge
|
||||||
|
* Catch NPE in NTCP.
|
||||||
|
This possibly augments fix 2009-04-11 welterde below.
|
||||||
|
* Various LINT on NTCP sources, and removal of space-wasting
|
||||||
|
spaces at end of lines in sources touched.
|
||||||
|
|
||||||
2009-04-13 Mathiasdm
|
2009-04-13 Mathiasdm
|
||||||
* Bugfix on tray icon updating
|
* Bugfix on tray icon updating
|
||||||
* Some more work on the general configuration menu
|
* Some more work on the general configuration menu
|
||||||
|
@ -17,7 +17,7 @@ import net.i2p.CoreVersion;
|
|||||||
public class RouterVersion {
|
public class RouterVersion {
|
||||||
public final static String ID = "$Revision: 1.548 $ $Date: 2008-06-07 23:00:00 $";
|
public final static String ID = "$Revision: 1.548 $ $Date: 2008-06-07 23:00:00 $";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 18;
|
public final static long BUILD = 19;
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
|
||||||
System.out.println("Router ID: " + RouterVersion.ID);
|
System.out.println("Router ID: " + RouterVersion.ID);
|
||||||
|
@ -14,7 +14,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -46,10 +45,10 @@ public abstract class TransportImpl implements Transport {
|
|||||||
private Log _log;
|
private Log _log;
|
||||||
private TransportEventListener _listener;
|
private TransportEventListener _listener;
|
||||||
private RouterAddress _currentAddress;
|
private RouterAddress _currentAddress;
|
||||||
private List _sendPool;
|
private final List _sendPool;
|
||||||
protected RouterContext _context;
|
protected RouterContext _context;
|
||||||
/** map from routerIdentHash to timestamp (Long) that the peer was last unreachable */
|
/** map from routerIdentHash to timestamp (Long) that the peer was last unreachable */
|
||||||
private Map<Hash, Long> _unreachableEntries;
|
private final Map<Hash, Long> _unreachableEntries;
|
||||||
private Set<Hash> _wasUnreachableEntries;
|
private Set<Hash> _wasUnreachableEntries;
|
||||||
/** global router ident -> IP */
|
/** global router ident -> IP */
|
||||||
private static Map<Hash, byte[]> _IPMap = new ConcurrentHashMap(128);
|
private static Map<Hash, byte[]> _IPMap = new ConcurrentHashMap(128);
|
||||||
@ -506,7 +505,7 @@ public abstract class TransportImpl implements Transport {
|
|||||||
_log.warn(this.getStyle() + " setting wasUnreachable to " + yes + " for " + peer);
|
_log.warn(this.getStyle() + " setting wasUnreachable to " + yes + " for " + peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setIP(Hash peer, byte[] ip) {
|
public /* static */ void setIP(Hash peer, byte[] ip) {
|
||||||
_IPMap.put(peer, ip);
|
_IPMap.put(peer, ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ public class EstablishState {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
RouterIdentity alice = new RouterIdentity();
|
RouterIdentity alice = new RouterIdentity();
|
||||||
int sz = (int)DataHelper.fromLong(b, 0, 2);
|
int sz = (int)DataHelper.fromLong(b, 0, 2); // TO-DO: Hey zzz... Throws an NPE for me... see below, for my "quick fix", need to find out the real reason
|
||||||
if ( (sz <= 0) || (sz > b.length-2-4-Signature.SIGNATURE_BYTES) ) {
|
if ( (sz <= 0) || (sz > b.length-2-4-Signature.SIGNATURE_BYTES) ) {
|
||||||
_context.statManager().addRateData("ntcp.invalidInboundSize", sz, 0);
|
_context.statManager().addRateData("ntcp.invalidInboundSize", sz, 0);
|
||||||
fail("size is invalid", new Exception("size is " + sz));
|
fail("size is invalid", new Exception("size is " + sz));
|
||||||
@ -597,6 +597,8 @@ public class EstablishState {
|
|||||||
} catch (DataFormatException dfe) {
|
} catch (DataFormatException dfe) {
|
||||||
_context.statManager().addRateData("ntcp.invalidInboundDFE", 1, 0);
|
_context.statManager().addRateData("ntcp.invalidInboundDFE", 1, 0);
|
||||||
fail("Error verifying peer", dfe);
|
fail("Error verifying peer", dfe);
|
||||||
|
} catch(NullPointerException npe) {
|
||||||
|
fail("Error verifying peer", npe); // TO-DO: zzz This is that quick-fix. -- Sponge
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -658,6 +660,7 @@ public class EstablishState {
|
|||||||
public Exception getException() { return _e; }
|
public Exception getException() { return _e; }
|
||||||
|
|
||||||
private String prefix() { return toString(); }
|
private String prefix() { return toString(); }
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buf = new StringBuffer(64);
|
StringBuffer buf = new StringBuffer(64);
|
||||||
buf.append("est").append(System.identityHashCode(this));
|
buf.append("est").append(System.identityHashCode(this));
|
||||||
|
@ -36,7 +36,7 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
private SharedBid _fastBid;
|
private SharedBid _fastBid;
|
||||||
private SharedBid _slowBid;
|
private SharedBid _slowBid;
|
||||||
private SharedBid _transientFail;
|
private SharedBid _transientFail;
|
||||||
private Object _conLock;
|
private final Object _conLock;
|
||||||
private Map _conByIdent;
|
private Map _conByIdent;
|
||||||
private NTCPAddress _myAddress;
|
private NTCPAddress _myAddress;
|
||||||
private EventPumper _pumper;
|
private EventPumper _pumper;
|
||||||
@ -46,7 +46,7 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
* list of NTCPConnection of connections not yet established that we
|
* list of NTCPConnection of connections not yet established that we
|
||||||
* want to remove on establishment or close on timeout
|
* want to remove on establishment or close on timeout
|
||||||
*/
|
*/
|
||||||
private List _establishing;
|
private final List _establishing;
|
||||||
|
|
||||||
private List _sent;
|
private List _sent;
|
||||||
private NTCPSendFinisher _finisher;
|
private NTCPSendFinisher _finisher;
|
||||||
@ -238,6 +238,7 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void afterSend(OutNetMessage msg, boolean sendSuccessful, boolean allowRequeue, long msToSend) {
|
public void afterSend(OutNetMessage msg, boolean sendSuccessful, boolean allowRequeue, long msToSend) {
|
||||||
super.afterSend(msg, sendSuccessful, allowRequeue, msToSend);
|
super.afterSend(msg, sendSuccessful, allowRequeue, msToSend);
|
||||||
}
|
}
|
||||||
@ -313,6 +314,7 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
return countActivePeers() < getMaxConnections();
|
return countActivePeers() < getMaxConnections();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean haveCapacity() {
|
public boolean haveCapacity() {
|
||||||
return countActivePeers() < getMaxConnections() * 4 / 5;
|
return countActivePeers() < getMaxConnections() * 4 / 5;
|
||||||
}
|
}
|
||||||
@ -324,6 +326,7 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
return isEstablished(peer.calculateHash());
|
return isEstablished(peer.calculateHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isEstablished(Hash dest) {
|
public boolean isEstablished(Hash dest) {
|
||||||
synchronized (_conLock) {
|
synchronized (_conLock) {
|
||||||
NTCPConnection con = (NTCPConnection)_conByIdent.get(dest);
|
NTCPConnection con = (NTCPConnection)_conByIdent.get(dest);
|
||||||
@ -331,6 +334,7 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isBacklogged(Hash dest) {
|
public boolean isBacklogged(Hash dest) {
|
||||||
synchronized (_conLock) {
|
synchronized (_conLock) {
|
||||||
NTCPConnection con = (NTCPConnection)_conByIdent.get(dest);
|
NTCPConnection con = (NTCPConnection)_conByIdent.get(dest);
|
||||||
@ -357,10 +361,12 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
* How many peers can we talk to right now?
|
* How many peers can we talk to right now?
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int countActivePeers() { synchronized (_conLock) { return _conByIdent.size(); } }
|
public int countActivePeers() { synchronized (_conLock) { return _conByIdent.size(); } }
|
||||||
/**
|
/**
|
||||||
* How many peers are we actively sending messages to (this minute)
|
* How many peers are we actively sending messages to (this minute)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int countActiveSendPeers() {
|
public int countActiveSendPeers() {
|
||||||
int active = 0;
|
int active = 0;
|
||||||
synchronized (_conLock) {
|
synchronized (_conLock) {
|
||||||
@ -377,6 +383,7 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
* Return our peer clock skews on this transport.
|
* Return our peer clock skews on this transport.
|
||||||
* Vector composed of Long, each element representing a peer skew in seconds.
|
* Vector composed of Long, each element representing a peer skew in seconds.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Vector getClockSkews() {
|
public Vector getClockSkews() {
|
||||||
|
|
||||||
Vector peers = new Vector();
|
Vector peers = new Vector();
|
||||||
@ -555,6 +562,7 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
public static final String STYLE = "NTCP";
|
public static final String STYLE = "NTCP";
|
||||||
|
|
||||||
public void renderStatusHTML(java.io.Writer out, int sortFlags) throws IOException {}
|
public void renderStatusHTML(java.io.Writer out, int sortFlags) throws IOException {}
|
||||||
|
@Override
|
||||||
public void renderStatusHTML(java.io.Writer out, String urlBase, int sortFlags) throws IOException {
|
public void renderStatusHTML(java.io.Writer out, String urlBase, int sortFlags) throws IOException {
|
||||||
TreeSet peers = new TreeSet(getComparator(sortFlags));
|
TreeSet peers = new TreeSet(getComparator(sortFlags));
|
||||||
synchronized (_conLock) {
|
synchronized (_conLock) {
|
||||||
@ -674,7 +682,7 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
buf.setLength(0);
|
buf.setLength(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static NumberFormat _rateFmt = new DecimalFormat("#,#0.00");
|
private static final NumberFormat _rateFmt = new DecimalFormat("#,#0.00");
|
||||||
private static String formatRate(float rate) {
|
private static String formatRate(float rate) {
|
||||||
synchronized (_rateFmt) { return _rateFmt.format(rate); }
|
synchronized (_rateFmt) { return _rateFmt.format(rate); }
|
||||||
}
|
}
|
||||||
@ -717,7 +725,9 @@ public class NTCPTransport extends TransportImpl {
|
|||||||
*/
|
*/
|
||||||
private class SharedBid extends TransportBid {
|
private class SharedBid extends TransportBid {
|
||||||
public SharedBid(int ms) { super(); setLatencyMs(ms); }
|
public SharedBid(int ms) { super(); setLatencyMs(ms); }
|
||||||
|
@Override
|
||||||
public Transport getTransport() { return NTCPTransport.this; }
|
public Transport getTransport() { return NTCPTransport.this; }
|
||||||
|
@Override
|
||||||
public String toString() { return "NTCP bid @ " + getLatencyMs(); }
|
public String toString() { return "NTCP bid @ " + getLatencyMs(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,18 +26,18 @@ public class OutboundMessageFragments {
|
|||||||
private RouterContext _context;
|
private RouterContext _context;
|
||||||
private Log _log;
|
private Log _log;
|
||||||
private UDPTransport _transport;
|
private UDPTransport _transport;
|
||||||
private ActiveThrottle _throttle;
|
private ActiveThrottle _throttle; // LINT not used ??
|
||||||
/** peers we are actively sending messages to */
|
/** peers we are actively sending messages to */
|
||||||
private List _activePeers;
|
private final List _activePeers;
|
||||||
private boolean _alive;
|
private boolean _alive;
|
||||||
/** which peer should we build the next packet out of? */
|
/** which peer should we build the next packet out of? */
|
||||||
private int _nextPeer;
|
private int _nextPeer;
|
||||||
private PacketBuilder _builder;
|
private PacketBuilder _builder;
|
||||||
/** if we can handle more messages explicitly, set this to true */
|
/** if we can handle more messages explicitly, set this to true */
|
||||||
private boolean _allowExcess;
|
private boolean _allowExcess; // LINT not used??
|
||||||
private volatile long _packetsRetransmitted;
|
private volatile long _packetsRetransmitted; // LINT not used??
|
||||||
|
|
||||||
private static final int MAX_ACTIVE = 64;
|
// private static final int MAX_ACTIVE = 64; // not used.
|
||||||
// don't send a packet more than 10 times
|
// don't send a packet more than 10 times
|
||||||
static final int MAX_VOLLEYS = 10;
|
static final int MAX_VOLLEYS = 10;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user