cleanup: annotated a bunch of files
This commit is contained in:
@ -33,16 +33,19 @@ public class I2PException extends Exception {
|
|||||||
_source = source;
|
_source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void printStackTrace() {
|
public void printStackTrace() {
|
||||||
if (_source != null) _source.printStackTrace();
|
if (_source != null) _source.printStackTrace();
|
||||||
super.printStackTrace();
|
super.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void printStackTrace(PrintStream ps) {
|
public void printStackTrace(PrintStream ps) {
|
||||||
if (_source != null) _source.printStackTrace(ps);
|
if (_source != null) _source.printStackTrace(ps);
|
||||||
super.printStackTrace(ps);
|
super.printStackTrace(ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void printStackTrace(PrintWriter pw) {
|
public void printStackTrace(PrintWriter pw) {
|
||||||
if (_source != null) _source.printStackTrace(pw);
|
if (_source != null) _source.printStackTrace(pw);
|
||||||
super.printStackTrace(pw);
|
super.printStackTrace(pw);
|
||||||
|
@ -131,6 +131,7 @@ public class ATalk implements I2PSessionListener, Runnable {
|
|||||||
* application is complete.
|
* application is complete.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
connect();
|
connect();
|
||||||
@ -241,6 +242,7 @@ public class ATalk implements I2PSessionListener, Runnable {
|
|||||||
* message to the user.
|
* message to the user.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void messageAvailable(I2PSession session, int msgId, long size) {
|
public void messageAvailable(I2PSession session, int msgId, long size) {
|
||||||
_log.debug("Message available: id = " + msgId + " size = " + size);
|
_log.debug("Message available: id = " + msgId + " size = " + size);
|
||||||
try {
|
try {
|
||||||
@ -351,16 +353,19 @@ public class ATalk implements I2PSessionListener, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** required by {@link I2PSessionListener I2PSessionListener} to notify of disconnect */
|
/** required by {@link I2PSessionListener I2PSessionListener} to notify of disconnect */
|
||||||
|
@Override
|
||||||
public void disconnected(I2PSession session) {
|
public void disconnected(I2PSession session) {
|
||||||
_log.debug("Disconnected");
|
_log.debug("Disconnected");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** required by {@link I2PSessionListener I2PSessionListener} to notify of error */
|
/** required by {@link I2PSessionListener I2PSessionListener} to notify of error */
|
||||||
|
@Override
|
||||||
public void errorOccurred(I2PSession session, String message, Throwable error) {
|
public void errorOccurred(I2PSession session, String message, Throwable error) {
|
||||||
_log.debug("Error occurred: " + message, error);
|
_log.debug("Error occurred: " + message, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** required by {@link I2PSessionListener I2PSessionListener} to notify of abuse */
|
/** required by {@link I2PSessionListener I2PSessionListener} to notify of abuse */
|
||||||
|
@Override
|
||||||
public void reportAbuse(I2PSession session, int severity) {
|
public void reportAbuse(I2PSession session, int severity) {
|
||||||
_log.debug("Abuse reported of severity " + severity);
|
_log.debug("Abuse reported of severity " + severity);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ class DisconnectMessageHandler extends HandlerImpl {
|
|||||||
super(context, DisconnectMessage.MESSAGE_TYPE);
|
super(context, DisconnectMessage.MESSAGE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
|
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
|
||||||
_log.debug("Handle message " + message);
|
_log.debug("Handle message " + message);
|
||||||
session.destroySession(false);
|
session.destroySession(false);
|
||||||
|
@ -28,6 +28,7 @@ abstract class HandlerImpl implements I2CPMessageHandler {
|
|||||||
_log = new Log(getClass());
|
_log = new Log(getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return _type;
|
return _type;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ class I2PClientImpl implements I2PClient {
|
|||||||
/**
|
/**
|
||||||
* Create the destination with a null payload
|
* Create the destination with a null payload
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Destination createDestination(OutputStream destKeyStream) throws I2PException, IOException {
|
public Destination createDestination(OutputStream destKeyStream) throws I2PException, IOException {
|
||||||
Certificate cert = new Certificate();
|
Certificate cert = new Certificate();
|
||||||
cert.setCertificateType(Certificate.CERTIFICATE_TYPE_NULL);
|
cert.setCertificateType(Certificate.CERTIFICATE_TYPE_NULL);
|
||||||
@ -45,6 +46,7 @@ class I2PClientImpl implements I2PClient {
|
|||||||
* the PrivateKey and SigningPrivateKey to the destKeyStream
|
* the PrivateKey and SigningPrivateKey to the destKeyStream
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Destination createDestination(OutputStream destKeyStream, Certificate cert) throws I2PException, IOException {
|
public Destination createDestination(OutputStream destKeyStream, Certificate cert) throws I2PException, IOException {
|
||||||
Destination d = new Destination();
|
Destination d = new Destination();
|
||||||
d.setCertificate(cert);
|
d.setCertificate(cert);
|
||||||
@ -69,6 +71,7 @@ class I2PClientImpl implements I2PClient {
|
|||||||
* Create a new session (though do not connect it yet)
|
* Create a new session (though do not connect it yet)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public I2PSession createSession(InputStream destKeyStream, Properties options) throws I2PSessionException {
|
public I2PSession createSession(InputStream destKeyStream, Properties options) throws I2PSessionException {
|
||||||
return createSession(I2PAppContext.getGlobalContext(), destKeyStream, options);
|
return createSession(I2PAppContext.getGlobalContext(), destKeyStream, options);
|
||||||
}
|
}
|
||||||
|
@ -231,6 +231,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
* @throws I2PSessionException if there is a configuration error or the router is
|
* @throws I2PSessionException if there is a configuration error or the router is
|
||||||
* not reachable
|
* not reachable
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void connect() throws I2PSessionException {
|
public void connect() throws I2PSessionException {
|
||||||
_closed = false;
|
_closed = false;
|
||||||
_availabilityNotifier.stopNotifying();
|
_availabilityNotifier.stopNotifying();
|
||||||
@ -303,6 +304,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
* notified the user that its available.
|
* notified the user that its available.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public byte[] receiveMessage(int msgId) throws I2PSessionException {
|
public byte[] receiveMessage(int msgId) throws I2PSessionException {
|
||||||
int remaining = 0;
|
int remaining = 0;
|
||||||
MessagePayloadMessage msg = null;
|
MessagePayloadMessage msg = null;
|
||||||
@ -321,6 +323,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
/**
|
/**
|
||||||
* Report abuse with regards to the given messageId
|
* Report abuse with regards to the given messageId
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void reportAbuse(int msgId, int severity) throws I2PSessionException {
|
public void reportAbuse(int msgId, int severity) throws I2PSessionException {
|
||||||
if (isClosed()) throw new I2PSessionException(getPrefix() + "Already closed");
|
if (isClosed()) throw new I2PSessionException(getPrefix() + "Already closed");
|
||||||
_producer.reportAbuse(this, msgId, severity);
|
_producer.reportAbuse(this, msgId, severity);
|
||||||
@ -332,8 +335,10 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
* delivered successfully. make this wait for at least ACCEPTED
|
* delivered successfully. make this wait for at least ACCEPTED
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public abstract boolean sendMessage(Destination dest, byte[] payload) throws I2PSessionException;
|
public abstract boolean sendMessage(Destination dest, byte[] payload) throws I2PSessionException;
|
||||||
|
|
||||||
|
@Override
|
||||||
public abstract boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed,
|
public abstract boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed,
|
||||||
Set tagsSent) throws I2PSessionException;
|
Set tagsSent) throws I2PSessionException;
|
||||||
|
|
||||||
@ -374,6 +379,8 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
private class VerifyUsage implements SimpleTimer.TimedEvent {
|
private class VerifyUsage implements SimpleTimer.TimedEvent {
|
||||||
private Long _msgId;
|
private Long _msgId;
|
||||||
public VerifyUsage(Long id) { _msgId = id; }
|
public VerifyUsage(Long id) { _msgId = id; }
|
||||||
|
|
||||||
|
@Override
|
||||||
public void timeReached() {
|
public void timeReached() {
|
||||||
MessagePayloadMessage removed = null;
|
MessagePayloadMessage removed = null;
|
||||||
int remaining = 0;
|
int remaining = 0;
|
||||||
@ -412,6 +419,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
AvailabilityNotifier.this.notifyAll();
|
AvailabilityNotifier.this.notifyAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
_alive = true;
|
_alive = true;
|
||||||
while (_alive) {
|
while (_alive) {
|
||||||
@ -453,6 +461,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
* Recieve notification of some I2CP message and handle it if possible
|
* Recieve notification of some I2CP message and handle it if possible
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void messageReceived(I2CPMessageReader reader, I2CPMessage message) {
|
public void messageReceived(I2CPMessageReader reader, I2CPMessage message) {
|
||||||
I2CPMessageHandler handler = _handlerMap.getHandler(message.getType());
|
I2CPMessageHandler handler = _handlerMap.getHandler(message.getType());
|
||||||
if (handler == null) {
|
if (handler == null) {
|
||||||
@ -471,6 +480,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
* Recieve notifiation of an error reading the I2CP stream
|
* Recieve notifiation of an error reading the I2CP stream
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void readError(I2CPMessageReader reader, Exception error) {
|
public void readError(I2CPMessageReader reader, Exception error) {
|
||||||
propogateError("There was an error reading data", error);
|
propogateError("There was an error reading data", error);
|
||||||
disconnect();
|
disconnect();
|
||||||
@ -479,16 +489,19 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
/**
|
/**
|
||||||
* Retrieve the destination of the session
|
* Retrieve the destination of the session
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Destination getMyDestination() { return _myDestination; }
|
public Destination getMyDestination() { return _myDestination; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the decryption PrivateKey
|
* Retrieve the decryption PrivateKey
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public PrivateKey getDecryptionKey() { return _privateKey; }
|
public PrivateKey getDecryptionKey() { return _privateKey; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the signing SigningPrivateKey
|
* Retrieve the signing SigningPrivateKey
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public SigningPrivateKey getPrivateKey() { return _signingPrivateKey; }
|
public SigningPrivateKey getPrivateKey() { return _signingPrivateKey; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -508,9 +521,11 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
void setSessionId(SessionId id) { _sessionId = id; }
|
void setSessionId(SessionId id) { _sessionId = id; }
|
||||||
|
|
||||||
/** configure the listener */
|
/** configure the listener */
|
||||||
|
@Override
|
||||||
public void setSessionListener(I2PSessionListener lsnr) { _sessionListener = lsnr; }
|
public void setSessionListener(I2PSessionListener lsnr) { _sessionListener = lsnr; }
|
||||||
|
|
||||||
/** has the session been closed (or not yet connected)? */
|
/** has the session been closed (or not yet connected)? */
|
||||||
|
@Override
|
||||||
public boolean isClosed() { return _closed; }
|
public boolean isClosed() { return _closed; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -560,6 +575,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
/**
|
/**
|
||||||
* Tear down the session, and do NOT reconnect
|
* Tear down the session, and do NOT reconnect
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void destroySession() {
|
public void destroySession() {
|
||||||
destroySession(true);
|
destroySession(true);
|
||||||
}
|
}
|
||||||
@ -607,6 +623,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
|||||||
/**
|
/**
|
||||||
* Recieve notification that the I2CP connection was disconnected
|
* Recieve notification that the I2CP connection was disconnected
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void disconnected(I2CPMessageReader reader) {
|
public void disconnected(I2CPMessageReader reader) {
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Disconnected", new Exception("Disconnected"));
|
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Disconnected", new Exception("Disconnected"));
|
||||||
disconnect();
|
disconnect();
|
||||||
|
@ -70,21 +70,26 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
|||||||
return SEND_TIMEOUT;
|
return SEND_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void destroySession(boolean sendDisconnect) {
|
public void destroySession(boolean sendDisconnect) {
|
||||||
clearStates();
|
clearStates();
|
||||||
super.destroySession(sendDisconnect);
|
super.destroySession(sendDisconnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean sendMessage(Destination dest, byte[] payload) throws I2PSessionException {
|
public boolean sendMessage(Destination dest, byte[] payload) throws I2PSessionException {
|
||||||
return sendMessage(dest, payload, 0, payload.length);
|
return sendMessage(dest, payload, 0, payload.length);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size) throws I2PSessionException {
|
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size) throws I2PSessionException {
|
||||||
return sendMessage(dest, payload, offset, size, new SessionKey(), new HashSet(64));
|
return sendMessage(dest, payload, offset, size, new SessionKey(), new HashSet(64));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed, Set tagsSent) throws I2PSessionException {
|
public boolean sendMessage(Destination dest, byte[] payload, SessionKey keyUsed, Set tagsSent) throws I2PSessionException {
|
||||||
return sendMessage(dest, payload, 0, payload.length, keyUsed, tagsSent);
|
return sendMessage(dest, payload, 0, payload.length, keyUsed, tagsSent);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent)
|
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set tagsSent)
|
||||||
throws I2PSessionException {
|
throws I2PSessionException {
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("sending message");
|
if (_log.shouldLog(Log.DEBUG)) _log.debug("sending message");
|
||||||
@ -97,6 +102,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
|||||||
/**
|
/**
|
||||||
* pull the unencrypted AND DECOMPRESSED data
|
* pull the unencrypted AND DECOMPRESSED data
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public byte[] receiveMessage(int msgId) throws I2PSessionException {
|
public byte[] receiveMessage(int msgId) throws I2PSessionException {
|
||||||
byte compressed[] = super.receiveMessage(msgId);
|
byte compressed[] = super.receiveMessage(msgId);
|
||||||
if (compressed == null) {
|
if (compressed == null) {
|
||||||
@ -267,6 +273,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void receiveStatus(int msgId, long nonce, int status) {
|
public void receiveStatus(int msgId, long nonce, int status) {
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Received status " + status + " for msgId " + msgId + " / " + nonce);
|
if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Received status " + status + " for msgId " + msgId + " / " + nonce);
|
||||||
MessageState state = null;
|
MessageState state = null;
|
||||||
@ -335,6 +342,7 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
|||||||
* to override this to clear out the message state
|
* to override this to clear out the message state
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected boolean reconnect() {
|
protected boolean reconnect() {
|
||||||
// even if we succeed in reconnecting, we want to clear the old states,
|
// even if we succeed in reconnecting, we want to clear the old states,
|
||||||
// since this will be a new sessionId
|
// since this will be a new sessionId
|
||||||
|
@ -29,6 +29,7 @@ class MessagePayloadMessageHandler extends HandlerImpl {
|
|||||||
super(context, MessagePayloadMessage.MESSAGE_TYPE);
|
super(context, MessagePayloadMessage.MESSAGE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
|
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("Handle message " + message);
|
_log.debug("Handle message " + message);
|
||||||
|
@ -26,6 +26,7 @@ class MessageStatusMessageHandler extends HandlerImpl {
|
|||||||
super(context, MessageStatusMessage.MESSAGE_TYPE);
|
super(context, MessageStatusMessage.MESSAGE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
|
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
|
||||||
boolean skipStatus = true;
|
boolean skipStatus = true;
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
@ -40,6 +40,7 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
|
|||||||
_existingLeaseSets = new HashMap(32);
|
_existingLeaseSets = new HashMap(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
|
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("Handle message " + message);
|
_log.debug("Handle message " + message);
|
||||||
@ -122,11 +123,13 @@ class RequestLeaseSetMessageHandler extends HandlerImpl {
|
|||||||
return _signingPrivKey;
|
return _signingPrivKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return DataHelper.hashCode(_pubKey) + 7 * DataHelper.hashCode(_privKey) + 7 * 7
|
return DataHelper.hashCode(_pubKey) + 7 * DataHelper.hashCode(_privKey) + 7 * 7
|
||||||
* DataHelper.hashCode(_signingPubKey) + 7 * 7 * 7 * DataHelper.hashCode(_signingPrivKey);
|
* DataHelper.hashCode(_signingPubKey) + 7 * 7 * 7 * DataHelper.hashCode(_signingPrivKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if ((obj == null) || !(obj instanceof LeaseInfo)) return false;
|
if ((obj == null) || !(obj instanceof LeaseInfo)) return false;
|
||||||
LeaseInfo li = (LeaseInfo) obj;
|
LeaseInfo li = (LeaseInfo) obj;
|
||||||
|
@ -24,6 +24,7 @@ class SessionStatusMessageHandler extends HandlerImpl {
|
|||||||
super(context, SessionStatusMessage.MESSAGE_TYPE);
|
super(context, SessionStatusMessage.MESSAGE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
|
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
|
||||||
_log.debug("Handle message " + message);
|
_log.debug("Handle message " + message);
|
||||||
SessionStatusMessage msg = (SessionStatusMessage) message;
|
SessionStatusMessage msg = (SessionStatusMessage) message;
|
||||||
|
@ -24,6 +24,7 @@ class SetDateMessageHandler extends HandlerImpl {
|
|||||||
super(ctx, SetDateMessage.MESSAGE_TYPE);
|
super(ctx, SetDateMessage.MESSAGE_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
|
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
|
||||||
_log.debug("Handle message " + message);
|
_log.debug("Handle message " + message);
|
||||||
SetDateMessage msg = (SetDateMessage) message;
|
SetDateMessage msg = (SetDateMessage) message;
|
||||||
|
@ -19,6 +19,7 @@ public class AddressDBNamingService extends NamingService {
|
|||||||
super(null);
|
super(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Destination lookup(String hostname) {
|
public Destination lookup(String hostname) {
|
||||||
Address addr = _addressdb.get(hostname);
|
Address addr = _addressdb.get(hostname);
|
||||||
if (addr != null) {
|
if (addr != null) {
|
||||||
@ -29,6 +30,7 @@ public class AddressDBNamingService extends NamingService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String reverseLookup(Destination dest) {
|
public String reverseLookup(Destination dest) {
|
||||||
Iterator iter = _addressdb.hostnames().iterator();
|
Iterator iter = _addressdb.hostnames().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
|
@ -11,30 +11,37 @@ public class DummyAddressDB extends AddressDB {
|
|||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Address get(String hostname) {
|
public Address get(String hostname) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Address put(Address address) {
|
public Address put(Address address) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Address remove(String hostname) {
|
public Address remove(String hostname) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Address remove(Address address) {
|
public Address remove(Address address) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean contains(Address address) {
|
public boolean contains(Address address) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean contains(String hostname) {
|
public boolean contains(String hostname) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Collection hostnames() {
|
public Collection hostnames() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,12 @@ class DummyNamingService extends NamingService {
|
|||||||
protected DummyNamingService(I2PAppContext context) { super(context); }
|
protected DummyNamingService(I2PAppContext context) { super(context); }
|
||||||
private DummyNamingService() { super(null); }
|
private DummyNamingService() { super(null); }
|
||||||
|
|
||||||
|
@Override
|
||||||
public Destination lookup(String hostname) {
|
public Destination lookup(String hostname) {
|
||||||
return lookupBase64(hostname);
|
return lookupBase64(hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String reverseLookup(Destination dest) {
|
public String reverseLookup(Destination dest) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ public class EepGetNamingService extends NamingService {
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Destination lookup(String hostname) {
|
public Destination lookup(String hostname) {
|
||||||
// If it's long, assume it's a key.
|
// If it's long, assume it's a key.
|
||||||
if (hostname.length() >= DEST_SIZE)
|
if (hostname.length() >= DEST_SIZE)
|
||||||
@ -136,6 +137,7 @@ public class EepGetNamingService extends NamingService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String reverseLookup(Destination dest) {
|
public String reverseLookup(Destination dest) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ public class ExecNamingService extends NamingService {
|
|||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Destination lookup(String hostname) {
|
public Destination lookup(String hostname) {
|
||||||
// If it's long, assume it's a key.
|
// If it's long, assume it's a key.
|
||||||
if (hostname.length() >= DEST_SIZE)
|
if (hostname.length() >= DEST_SIZE)
|
||||||
@ -126,6 +127,7 @@ public class ExecNamingService extends NamingService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String reverseLookup(Destination dest) {
|
public String reverseLookup(Destination dest) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ public class FilesystemAddressDB extends AddressDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Address get(String hostname) {
|
public Address get(String hostname) {
|
||||||
String dir = _context.getProperty(PROP_ADDRESS_DIR, DEFAULT_ADDRESS_DIR);
|
String dir = _context.getProperty(PROP_ADDRESS_DIR, DEFAULT_ADDRESS_DIR);
|
||||||
File f = new File(dir, hostname);
|
File f = new File(dir, hostname);
|
||||||
@ -74,6 +75,7 @@ public class FilesystemAddressDB extends AddressDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Address put(Address address) {
|
public Address put(Address address) {
|
||||||
Address previous = get(address.getHostname());
|
Address previous = get(address.getHostname());
|
||||||
|
|
||||||
@ -87,6 +89,7 @@ public class FilesystemAddressDB extends AddressDB {
|
|||||||
return previous;
|
return previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Address remove(String hostname) {
|
public Address remove(String hostname) {
|
||||||
Address previous = get(hostname);
|
Address previous = get(hostname);
|
||||||
|
|
||||||
@ -96,6 +99,7 @@ public class FilesystemAddressDB extends AddressDB {
|
|||||||
return previous;
|
return previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Address remove(Address address) {
|
public Address remove(Address address) {
|
||||||
if (contains(address)) {
|
if (contains(address)) {
|
||||||
return remove(address.getHostname());
|
return remove(address.getHostname());
|
||||||
@ -104,15 +108,18 @@ public class FilesystemAddressDB extends AddressDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean contains(Address address) {
|
public boolean contains(Address address) {
|
||||||
Address inDb = get(address.getHostname());
|
Address inDb = get(address.getHostname());
|
||||||
return inDb.equals(address);
|
return inDb.equals(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean contains(String hostname) {
|
public boolean contains(String hostname) {
|
||||||
return hostnames().contains(hostname);
|
return hostnames().contains(hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Collection hostnames() {
|
public Collection hostnames() {
|
||||||
String dir = _context.getProperty(PROP_ADDRESS_DIR, DEFAULT_ADDRESS_DIR);
|
String dir = _context.getProperty(PROP_ADDRESS_DIR, DEFAULT_ADDRESS_DIR);
|
||||||
File f = new File(dir);
|
File f = new File(dir);
|
||||||
|
@ -55,6 +55,7 @@ public class HostsTxtNamingService extends NamingService {
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Destination lookup(String hostname) {
|
public Destination lookup(String hostname) {
|
||||||
Destination d = getCache(hostname);
|
Destination d = getCache(hostname);
|
||||||
if (d != null)
|
if (d != null)
|
||||||
@ -95,6 +96,7 @@ public class HostsTxtNamingService extends NamingService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String reverseLookup(Destination dest) {
|
public String reverseLookup(Destination dest) {
|
||||||
String destkey = dest.toBase64();
|
String destkey = dest.toBase64();
|
||||||
List filenames = getFilenames();
|
List filenames = getFilenames();
|
||||||
|
@ -33,6 +33,7 @@ public class MetaNamingService extends NamingService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Destination lookup(String hostname) {
|
public Destination lookup(String hostname) {
|
||||||
Iterator iter = _services.iterator();
|
Iterator iter = _services.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
@ -45,6 +46,7 @@ public class MetaNamingService extends NamingService {
|
|||||||
return lookupBase64(hostname);
|
return lookupBase64(hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String reverseLookup(Destination dest) {
|
public String reverseLookup(Destination dest) {
|
||||||
Iterator iter = _services.iterator();
|
Iterator iter = _services.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
|
@ -122,6 +122,7 @@ public class PetName {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer buf = new StringBuffer(256);
|
StringBuffer buf = new StringBuffer(256);
|
||||||
if (_name != null) buf.append(_name.trim());
|
if (_name != null) buf.append(_name.trim());
|
||||||
@ -142,6 +143,7 @@ public class PetName {
|
|||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if ( (obj == null) || !(obj instanceof PetName) ) return false;
|
if ( (obj == null) || !(obj instanceof PetName) ) return false;
|
||||||
PetName pn = (PetName)obj;
|
PetName pn = (PetName)obj;
|
||||||
@ -150,6 +152,7 @@ public class PetName {
|
|||||||
DataHelper.eq(_network, pn._network) &&
|
DataHelper.eq(_network, pn._network) &&
|
||||||
DataHelper.eq(_protocol, pn._protocol);
|
DataHelper.eq(_protocol, pn._protocol);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
rv += DataHelper.hashCode(_name);
|
rv += DataHelper.hashCode(_name);
|
||||||
|
@ -46,6 +46,7 @@ public class PetNameNamingService extends NamingService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Destination lookup(String hostname) {
|
public Destination lookup(String hostname) {
|
||||||
PetName name = _petnameDb.getByName(hostname);
|
PetName name = _petnameDb.getByName(hostname);
|
||||||
if (name != null && name.getNetwork().equalsIgnoreCase("i2p")) {
|
if (name != null && name.getNetwork().equalsIgnoreCase("i2p")) {
|
||||||
@ -55,6 +56,7 @@ public class PetNameNamingService extends NamingService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String reverseLookup(Destination dest) {
|
public String reverseLookup(Destination dest) {
|
||||||
return _petnameDb.getByLocation(dest.toBase64()).getName();
|
return _petnameDb.getByLocation(dest.toBase64()).getName();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user