use of net.i2p.client.I2PSession in project i2p.i2p by i2p.
the class PingIT method createSession.
private I2PSession createSession() throws Exception {
I2PClient client = I2PClientFactory.createClient();
ByteArrayOutputStream baos = new ByteArrayOutputStream(512);
client.createDestination(baos);
I2PSession sess = client.createSession(new ByteArrayInputStream(baos.toByteArray()), new Properties());
sess.connect();
return sess;
}
use of net.i2p.client.I2PSession in project i2p.i2p by i2p.
the class StreamingITBase method createSession.
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;
}
use of net.i2p.client.I2PSession in project i2p.i2p by i2p.
the class PrivateKeyFile method open.
public I2PSession open(Properties opts) throws I2PSessionException, IOException {
InputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(this.file));
I2PSession s = this.client.createSession(in, opts);
return s;
} finally {
if (in != null) {
try {
in.close();
} catch (IOException ioe) {
}
}
}
}
use of net.i2p.client.I2PSession in project i2p.i2p by i2p.
the class PrivateKeyFile method getDestination.
/**
* If the destination is not set, read it in from the file.
* Also sets the local privKey and signingPrivKey.
*/
public Destination getDestination() throws I2PSessionException, IOException, DataFormatException {
if (dest == null) {
I2PSession s = open();
if (s != null) {
this.dest = new VerifiedDestination(s.getMyDestination());
this.privKey = s.getDecryptionKey();
this.signingPrivKey = s.getPrivateKey();
}
}
return this.dest;
}
use of net.i2p.client.I2PSession in project i2p.i2p by i2p.
the class I2PSocketManagerFull method destroySocketManager.
/**
* Destroy the socket manager, freeing all the associated resources. This
* method will block until all the managed sockets are closed.
*
* CANNOT be restarted.
*/
public void destroySocketManager() {
if (!_isDestroyed.compareAndSet(false, true)) {
// shouldn't happen, log a stack trace to find out why it happened
_log.logCloseLoop("I2PSocketManager", getName());
return;
}
_connectionManager.setAllowIncomingConnections(false);
_connectionManager.shutdown();
if (!_subsessions.isEmpty()) {
for (I2PSession sess : _subsessions) {
removeSubsession(sess);
}
}
// yes, since the old lib did (and SAM wants it to, and i dont know why not)
if ((_session != null) && (!_session.isClosed())) {
try {
_session.destroySession();
} catch (I2PSessionException ise) {
_log.warn("Unable to destroy the session", ise);
}
PcapWriter pcap = null;
synchronized (_pcapInitLock) {
pcap = pcapWriter;
}
if (pcap != null)
pcap.flush();
}
}
Aggregations