public I2PSinkAnywhere(I2PSession sess, boolean raw) { this.sess = sess; this.raw = raw; // create maker if (raw) { this.maker = null; } else { this.maker = new I2PDatagramMaker(); this.maker.setI2PDatagramMaker(this.sess); } }
/** * Create a new SAM DATAGRAM session on an existing I2P session. * * @param props unused for now * @since 0.9.25 */ protected SAMDatagramSession(I2PSession sess, Properties props, int listenPort, SAMDatagramReceiver recv) throws IOException, DataFormatException, I2PSessionException { super(sess, I2PSession.PROTO_DATAGRAM, listenPort); this.recv = recv; dgramMaker = new I2PDatagramMaker(getI2PSession()); }
public I2PSink(I2PSession sess, Destination dest, boolean raw) { this.sess = sess; this.dest = dest; this.raw = raw; // create maker if (raw) { this.maker = null; } else { this.maker = new I2PDatagramMaker(); this.maker.setI2PDatagramMaker(this.sess); } }
/** * Create a new SAM DATAGRAM session. * * @param dest Base64-encoded destination (private key) * @param props Properties to setup the I2P session * @param recv Object that will receive incoming data * @throws IOException * @throws DataFormatException * @throws I2PSessionException */ protected SAMDatagramSession(String dest, Properties props, SAMDatagramReceiver recv) throws IOException, DataFormatException, I2PSessionException { super(dest, props); this.recv = recv; dgramMaker = new I2PDatagramMaker(getI2PSession()); }
/** * Create a new SAM DATAGRAM session. * * Caller MUST call start(). * * @param destStream Input stream containing the destination keys * @param props Properties to setup the I2P session * @param recv Object that will receive incoming data * @throws IOException * @throws DataFormatException * @throws I2PSessionException */ public SAMDatagramSession(InputStream destStream, Properties props, SAMDatagramReceiver recv) throws IOException, DataFormatException, I2PSessionException { super(destStream, props); this.recv = recv; dgramMaker = new I2PDatagramMaker(getI2PSession()); }
I2PDatagramMaker dgMaker = new I2PDatagramMaker(_session); payload = dgMaker.makeI2PDatagram(payload); if (payload == null) {
public void testDatagram() throws Exception{ ByteArrayOutputStream out = new ByteArrayOutputStream(); I2PClient client = I2PClientFactory.createClient(); Destination d = client.createDestination(out); I2PSession session = client.createSession(new ByteArrayInputStream(out.toByteArray()), null); I2PDatagramMaker dm = new I2PDatagramMaker(session); byte[] dg = dm.makeI2PDatagram(DataHelper.getASCII("What's the deal with 42?")); I2PDatagramDissector dd = new I2PDatagramDissector(); dd.loadI2PDatagram(dg); byte[] x = dd.getPayload(); assertTrue(DataHelper.eq(x, DataHelper.getASCII("What's the deal with 42?"))); x = dd.extractPayload(); assertTrue(DataHelper.eq(x, DataHelper.getASCII("What's the deal with 42?"))); assertEquals(d, dd.getSender()); assertEquals(d, dd.extractSender()); }
/** * @param i2pSession * @param i2pReceiver */ public I2PSendQueue(I2PSession i2pSession, I2PPacketDispatcher i2pReceiver) { super("I2PSendQueue"); this.i2pSession = i2pSession; i2pReceiver.addPacketListener(this); packetQueue = new PacketQueue(); runningBatches = new ConcurrentHashSet<PacketBatch>(); datagramMaker = new I2PDatagramMaker(i2pSession); }