/** * @deprecated don't do this * @throws I2CPMessageException always */ @Deprecated protected void doReadMessage(InputStream in, int size) throws I2CPMessageException { throw new I2CPMessageException("Don't do this"); }
/** * Send dummy limits */ @Override protected void handleGetBWLimits(GetBandwidthLimitsMessage message) { int limit = 1024*1024; BandwidthLimitsMessage msg = new BandwidthLimitsMessage(limit, limit); try { _runner.doSend(msg); } catch (I2CPMessageException ime) { ime.printStackTrace(); } } }
/** * Look only in current local dests */ @Override protected void handleDestLookup(DestLookupMessage message) { Hash h = message.getHash(); DestReplyMessage msg; Destination d = ((LocalClientConnectionRunner)_runner).localLookup(h); if (d != null) msg = new DestReplyMessage(d); else msg = new DestReplyMessage(h); try { _runner.doSend(msg); } catch (I2CPMessageException ime) { ime.printStackTrace(); } }
/** * @deprecated don't do this * @throws I2CPMessageException always */ @Deprecated protected byte[] doWriteMessage() throws I2CPMessageException { throw new I2CPMessageException("Don't do this"); }
_runner.doSend(msg); } catch (I2CPMessageException ime) { ime.printStackTrace();
/** * Add this message to the writer's queue * * Nonblocking, throws exception if queue is full */ public void addMessage(I2CPMessage msg) throws I2CPMessageException { boolean success = _messagesToWrite.offer(msg); if (!success) throw new I2CPMessageException("I2CP write to queue failed"); //if (_log.shouldLog(Log.DEBUG)) // _log.debug("["+_id+"] addMessage completed for " + msg.getClass().getName()); }
/** * Just send the message directly, * don't instantiate a RequestLeaseSetJob */ @Override void requestLeaseSet(Hash h, LeaseSet set, long expirationTime, Job onCreateJob, Job onFailedJob) { RequestVariableLeaseSetMessage msg = new RequestVariableLeaseSetMessage(); msg.setSessionId(getSessionId(h)); for (int i = 0; i < set.getLeaseCount(); i++) { Lease lease = set.getLease(i); msg.addEndpoint(lease); } try { doSend(msg); } catch (I2CPMessageException ime) { ime.printStackTrace(); } }
@Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if (_sessionId == null) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); ByteArrayOutputStream os = new ByteArrayOutputStream(64); try { _sessionId.writeBytes(os); } catch (DataFormatException dfe) { throw new I2CPMessageException("Error writing out the message data", dfe); } return os.toByteArray(); }
@Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if (_sessionConfig == null) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); ByteArrayOutputStream os = new ByteArrayOutputStream(64); try { _sessionConfig.writeBytes(os); } catch (DataFormatException dfe) { throw new I2CPMessageException("Error writing out the session config", dfe); } return os.toByteArray(); }
protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if (_hash == null) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); ByteArrayOutputStream os = new ByteArrayOutputStream(Hash.HASH_LENGTH); try { _hash.writeBytes(os); } catch (DataFormatException dfe) { throw new I2CPMessageException("Error writing out the hash", dfe); } return os.toByteArray(); }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { for (int i = 0; i < LIMITS; i++) { data[i] = (int) DataHelper.readLong(in, 4); } } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
@Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(64); try { DataHelper.writeString(os, _reason); } catch (DataFormatException dfe) { throw new I2CPMessageException("Error writing out the message data", dfe); } return os.toByteArray(); }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _reason = DataHelper.readString(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
@Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(64); try { for (int i = 0; i < LIMITS; i++) { DataHelper.writeLong(os, 4, data[i]); } } catch (DataFormatException dfe) { throw new I2CPMessageException("Error writing out the message data", dfe); } return os.toByteArray(); }
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { //Hash h = new Hash(); try { //h.readBytes(in); _hash = Hash.create(in); //} catch (DataFormatException dfe) { } catch (IllegalArgumentException dfe) { throw new I2CPMessageException("Unable to load the hash", dfe); } //_hash = h; }
/** * Actually send the I2CPMessage to the client. * Nonblocking. * @throws I2CPMessageException if queue full or on other errors */ @Override void doSend(I2CPMessage msg) throws I2CPMessageException { boolean success = queue.offer(msg); if (!success) throw new I2CPMessageException("I2CP write to queue failed"); }
@Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if (_sessionId == null || _sessionConfig == null) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); ByteArrayOutputStream os = new ByteArrayOutputStream(64); try { _sessionId.writeBytes(os); _sessionConfig.writeBytes(os); } catch (DataFormatException dfe) { throw new I2CPMessageException("Error writing out the message data", dfe); } return os.toByteArray(); }
@Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if (_sessionId == null) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); ByteArrayOutputStream os = new ByteArrayOutputStream(64); try { _sessionId.writeBytes(os); DataHelper.writeLong(os, 1, _status); } catch (DataFormatException dfe) { throw new I2CPMessageException("Error writing out the message data", dfe); } return os.toByteArray(); }
/** * Actually send the I2CPMessage to the peer through the socket * */ void doSend(I2CPMessage msg) throws I2CPMessageException { if (_out == null) throw new I2CPMessageException("Output stream is not initialized"); if (msg == null) throw new I2CPMessageException("Null message?!"); //if (_log.shouldLog(Log.DEBUG)) { // if ( (_config == null) || (_config.getDestination() == null) ) // _log.debug("before doSend of a "+ msg.getClass().getName() // + " message on for establishing i2cp con"); // else // _log.debug("before doSend of a "+ msg.getClass().getName() // + " message on for " // + _config.getDestination().calculateHash().toBase64()); //} _writer.addMessage(msg); //if (_log.shouldLog(Log.DEBUG)) { // if ( (_config == null) || (_config.getDestination() == null) ) // _log.debug("after doSend of a "+ msg.getClass().getName() // + " message on for establishing i2cp con"); // else // _log.debug("after doSend of a "+ msg.getClass().getName() // + " message on for " // + _config.getDestination().calculateHash().toBase64()); //} }
@Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if (_date == null) throw new I2CPMessageException("Unable to write out the message as there is not enough data"); ByteArrayOutputStream os = new ByteArrayOutputStream(32); try { DataHelper.writeDate(os, _date); if (_version != null) DataHelper.writeString(os, _version); } catch (DataFormatException dfe) { throw new I2CPMessageException("Error writing out the message data", dfe); } return os.toByteArray(); }