/** * Create a new SAM message-based session handler on an existing I2PSession * * @since 0.9.25 */ public SAMMessageSessionHandler(I2PSession sess) throws I2PSessionException { _session = sess; _session.addMuxedSessionListener(this, listenProtocol, listenPort); }
/** * Unsupported * @throws I2PSessionException always * @since 0.9.25 */ public boolean sendBytes(String s, byte[] b, int pr, int fp, int tp, boolean sendLeaseSet, int sendTags, int tagThreshold, int expiration) throws I2PSessionException { throw new I2PSessionException("Unsupported in STREAM or MASTER session"); }
/** * If we are low on tags, send this many. * @return default 0, meaning unset, use the SKM config (default 40) */ public static int getTagsToSend(int flags) { int exp = (flags & TAGS_SEND_MASK); return codeToVal(exp, TAGS_SEND); }
protected I2PSession createSession() throws Exception { I2PClient client = I2PClientFactory.createClient(); ByteArrayOutputStream baos = new ByteArrayOutputStream(512); client.createDestination(baos); Properties p = getProperties(); I2PSession sess = client.createSession(new ByteArrayInputStream(baos.toByteArray()), p); sess.connect(); return sess; }
public static int[] getBWLimits(String host, int port) { int[] rv = null; try { I2PClient client = new I2PSimpleClient(); Properties opts = new Properties(); opts.put(I2PClient.PROP_TCP_HOST, host); opts.put(I2PClient.PROP_TCP_PORT, "" + port); I2PSession session = client.createSession(null, opts); session.connect(); rv = session.bandwidthLimits(); session.destroySession(); } catch (I2PSessionException ise) {} return rv; }
/** * Can't be used for writing * @since 0.9.26 */ public PrivateKeyFile(InputStream in) throws I2PSessionException { this("/dev/null"); I2PSession s = this.client.createSession(in, new Properties()); this.dest = s.getMyDestination(); this.privKey = s.getDecryptionKey(); this.signingPrivKey = s.getPrivateKey(); }
/** @since 0.8.9 */ public PrivateKeyFile(File file, I2PSession session) { this(file, session.getMyDestination(), session.getDecryptionKey(), session.getPrivateKey()); }
public PrivateKeyFile(File file) { this(file, I2PClientFactory.createClient()); }
/** * Get the SAM message-based session Destination. * * @return The SAM message-based session Destination. */ public Destination getDestination() { return session.getMyDestination(); }
/** * @return a list of subsessions, non-null, does not include the primary session * @since 0.9.21 */ public List<I2PSession> getSubsessions() { return _session.getSubsessions(); }
/** * If we are low on tags, send this many. * @return default 0, meaning unset, use the SKM config (default 40) */ public int getTagsToSend() { return getTagsToSend(_flags); }
/** * Low tag threshold. If less than this many, send more. * @return default 0, meaning unset, use the SKM config (default 30) */ public int getTagThreshold() { return getTagThreshold(_flags); }
/** default true */ public boolean getSendLeaseSet() { return getSendLeaseSet(_flags); }
/** * default Reliability.DEFAULT * @since 0.9.14 */ public Reliability getReliability() { return getReliability(_flags); }
public void reportAbuse(I2PSession session, int severity) { _l.reportAbuse(session, severity); } public void disconnected(I2PSession session) {
public void messageAvailable(I2PSession session, int msgId, long size, int proto, int fromport, int toport) { _l.messageAvailable(session, msgId, size); } public void reportAbuse(I2PSession session, int severity) {
public void disconnected(I2PSession session) { _l.disconnected(session); } public void errorOccurred(I2PSession session, String message, Throwable error) {
public void errorOccurred(I2PSession session, String message, Throwable error) { _l.errorOccurred(session, message, error); } }
/** * Unsupported * @throws I2PSessionException always * @since 0.9.25 moved from subclass SAMv3StreamSession to implement SAMMessageSess */ public boolean sendBytes(String s, byte[] b, int pr, int fp, int tp) throws I2PSessionException { throw new I2PSessionException("Unsupported in STREAM or MASTER session"); }
/** * Low tag threshold. If less than this many, send more. * @return default 0, meaning unset, use the SKM config (default 30) */ public static int getTagThreshold(int flags) { int exp = (flags & TAGS_REQD_MASK) >> 4; return codeToVal(exp, TAGS_REQD); }