use of net.i2p.data.i2cp.HostReplyMessage in project i2p.i2p by i2p.
the class LocalClientMessageEventListener method handleHostLookup.
/**
* Look only in current local dests
*/
@Override
protected void handleHostLookup(HostLookupMessage message) {
Hash h = message.getHash();
String name = message.getHostname();
long reqID = message.getReqID();
SessionId sessID = message.getSessionId();
if (h == null && name != null && name.length() == 60) {
// convert a b32 lookup to a hash lookup
String nlc = name.toLowerCase(Locale.US);
if (nlc.endsWith(".b32.i2p")) {
byte[] b = Base32.decode(nlc.substring(0, 52));
if (b != null && b.length == Hash.HASH_LENGTH) {
h = Hash.create(b);
}
}
}
Destination d = null;
if (h != null)
d = ((LocalClientConnectionRunner) _runner).localLookup(h);
HostReplyMessage msg;
if (d != null)
msg = new HostReplyMessage(sessID, d, reqID);
else
msg = new HostReplyMessage(sessID, HostReplyMessage.RESULT_FAILURE, reqID);
try {
_runner.doSend(msg);
} catch (I2CPMessageException ime) {
ime.printStackTrace();
}
}
use of net.i2p.data.i2cp.HostReplyMessage in project i2p.i2p by i2p.
the class HostReplyMessageHandler method handleMessage.
public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Handle message " + message);
HostReplyMessage msg = (HostReplyMessage) message;
Destination d = msg.getDestination();
long id = msg.getReqID();
if (d != null) {
session.destReceived(id, d);
} else {
session.destLookupFailed(id);
}
}
Aggregations