/** * Return the SessionId for this message. * * @since 0.9.21 */ @Override public SessionId sessionId() { return _sessionId >= 0 ? new SessionId(_sessionId) : null; }
/** * Return the SessionId for this message. * * @since 0.9.21 */ @Override public SessionId sessionId() { return _sessionId >= 0 ? new SessionId(_sessionId) : null; }
/** * Return the SessionId for this message. * * @since 0.9.21 */ @Override public SessionId sessionId() { return _sessionId >= 0 ? new SessionId(_sessionId) : null; }
/** * Return the SessionId for this message. * * @since 0.9.21 */ @Override public SessionId sessionId() { return _sessionId >= 0 ? new SessionId(_sessionId) : null; }
public DataStructure createStructureToRead() { return new SessionId(); } }
public DataStructure createDataStructure() throws DataFormatException { SessionId id = new SessionId(); id.setSessionId(7); return id; } public DataStructure createStructureToRead() { return new SessionId(); }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); _status = (int) DataHelper.readLong(in, 1); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { SessionId id = new SessionId(); try { id.readBytes(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } setSessionId(id); }
/** * Generate a new random, unused sessionId. Caller must synch on _runners. * @return null on failure * @since 0.9.12 */ private SessionId locked_getNextSessionId() { int max = Math.max(1, Math.min(2048, _ctx.getProperty(PROP_MAX_SESSIONS, DEFAULT_MAX_SESSIONS))); if (_runnerSessionIds.size() >= max) { _log.logAlways(Log.WARN, "Session refused, max is " + max + ", increase " + PROP_MAX_SESSIONS); return null; } for (int i = 0; i < 100; i++) { SessionId id = new SessionId(_ctx.random().nextInt(MAX_SESSION_ID + 1)); if (_runnerSessionIds.add(id)) return id; } _log.logAlways(Log.WARN, "Session refused, can't find id slot"); return null; }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { if (_sessionId != null) throw new IllegalStateException(); _sessionId = new SessionId(); _sessionId.readBytes(in); int numTunnels = (int) DataHelper.readLong(in, 1); for (int i = 0; i < numTunnels; i++) { Lease lease = new Lease(); lease.readBytes(in); _endpoints.add(lease); } } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); _sessionConfig = new SessionConfig(); _sessionConfig.readBytes(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); _reqID = DataHelper.readLong(in, 4); _code = (int) DataHelper.readLong(in, 1); if (_code == RESULT_SUCCESS) _dest = Destination.create(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("bad data", dfe); } }
/** * Read the body into the data structures * * @throws IOException */ @Override public void readMessage(InputStream in, int length, int type) throws I2CPMessageException, IOException { if (type != getType()) throw new I2CPMessageException("Invalid message type (found: " + type + " supported: " + getType() + " class: " + getClass().getName() + ")"); if (length < 0) throw new IOException("Negative payload size"); try { _sessionId = new SessionId(); _sessionId.readBytes(in); _destination = Destination.create(in); _payload = new Payload(); _payload.readBytes(in); _nonce = DataHelper.readLong(in, 4); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); int numTunnels = (int) DataHelper.readLong(in, 1); _endpoints.clear(); for (int i = 0; i < numTunnels; i++) { //Hash router = new Hash(); //router.readBytes(in); Hash router = Hash.create(in); TunnelId tunnel = new TunnelId(); tunnel.readBytes(in); _endpoints.add(new TunnelEndpoint(router, tunnel)); } _end = DataHelper.readDate(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
SessionId id = _sessionId; if (id == null) id = new SessionId(65535); sendMessage_unchecked(new HostLookupMessage(id, name, nonce, maxWait)); try {
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); _reqID = DataHelper.readLong(in, 4); _timeout = DataHelper.readLong(in, 4); _lookupType = (int) DataHelper.readLong(in, 1); if (_lookupType == LOOKUP_HASH) { _hash = Hash.create(in); } else if (_lookupType == LOOKUP_HOST) { _host = DataHelper.readString(in); if (_host.length() == 0) throw new I2CPMessageException("bad host"); } else { throw new I2CPMessageException("bad type"); } } catch (DataFormatException dfe) { throw new I2CPMessageException("bad data", dfe); } }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); _severity = new AbuseSeverity(); _severity.readBytes(in); _reason = new AbuseReason(); _reason.readBytes(in); _messageId = new MessageId(); _messageId.readBytes(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
SessionId id = _sessionId; if (id == null) id = new SessionId(65535); sendMessage_unchecked(new HostLookupMessage(id, h, nonce, maxWait)); } else {
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); // Revocation is unimplemented. // As the SPK comes before the LeaseSet, we don't know the key type. // We could have some sort of callback or state setting so we get the // expected type from the session. But for now, we just assume it's 20 bytes. // Clients outside router context should throw in a dummy 20 bytes. _signingPrivateKey = new SigningPrivateKey(); _signingPrivateKey.readBytes(in); _privateKey = new PrivateKey(); _privateKey.readBytes(in); _leaseSet = new LeaseSet(); _leaseSet.readBytes(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Error reading the CreateLeaseSetMessage", dfe); } }
/** * override for testing * @since 0.9.11 */ protected void handleHostLookup(HostLookupMessage message) { SessionId sid = message.getSessionId(); Hash h; if (sid != null) { h = _runner.getDestHash(sid); } else { // fixup if necessary if (message.getReqID() >= 0) sid = new SessionId(65535); h = null; } if (h == null) { h = _runner.getDestHash(); // h may still be null, an LS lookup for b32 will go out expl. tunnels } _context.jobQueue().addJob(new LookupDestJob(_context, _runner, message.getReqID(), message.getTimeout(), sid, message.getHash(), message.getHostname(), h)); }