Search in sources :

Example 6 with I2PSocketManager

use of net.i2p.client.streaming.I2PSocketManager in project i2p.i2p by i2p.

the class I2PTunnelClientBase method optionsUpdated.

/**
 *  Update the I2PSocketManager.
 *
 *  @since 0.9.1
 */
@Override
public void optionsUpdated(I2PTunnel tunnel) {
    if (getTunnel() != tunnel)
        return;
    I2PSocketManager sm = _ownDest ? sockMgr : socketManager;
    if (sm == null)
        return;
    Properties props = tunnel.getClientOptions();
    sm.setDefaultOptions(sm.buildOptions(props));
}
Also used : I2PSocketManager(net.i2p.client.streaming.I2PSocketManager) Properties(java.util.Properties)

Example 7 with I2PSocketManager

use of net.i2p.client.streaming.I2PSocketManager in project i2p.i2p by i2p.

the class I2PSnarkUtil method connect.

/**
 * connect to the given destination
 */
I2PSocket connect(PeerID peer) throws IOException {
    I2PSocketManager mgr = _manager;
    if (mgr == null)
        throw new IOException("No socket manager");
    Destination addr = peer.getAddress();
    if (addr == null)
        throw new IOException("Null address");
    if (addr.equals(getMyDestination()))
        throw new IOException("Attempt to connect to myself");
    Hash dest = addr.calculateHash();
    if (_banlist.contains(dest))
        throw new IOException("Not trying to contact " + dest.toBase64() + ", as they are banlisted");
    try {
        // TODO opts.setPort(xxx); connect(addr, opts)
        // DHT moved above 6881 in 0.9.9
        I2PSocket rv = _manager.connect(addr);
        if (rv != null)
            _banlist.remove(dest);
        return rv;
    } catch (I2PException ie) {
        _banlist.add(dest);
        _context.simpleTimer2().addEvent(new Unbanlist(dest), 10 * 60 * 1000);
        IOException ioe = new IOException("Unable to reach the peer " + peer);
        ioe.initCause(ie);
        throw ioe;
    }
}
Also used : I2PException(net.i2p.I2PException) Destination(net.i2p.data.Destination) I2PSocketManager(net.i2p.client.streaming.I2PSocketManager) I2PSocket(net.i2p.client.streaming.I2PSocket) IOException(java.io.IOException) Hash(net.i2p.data.Hash)

Aggregations

I2PSocketManager (net.i2p.client.streaming.I2PSocketManager)7 IOException (java.io.IOException)5 Properties (java.util.Properties)4 I2PSessionException (net.i2p.client.I2PSessionException)3 I2PException (net.i2p.I2PException)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InterruptedIOException (java.io.InterruptedIOException)1 URISyntaxException (java.net.URISyntaxException)1 I2PSession (net.i2p.client.I2PSession)1 I2PSocket (net.i2p.client.streaming.I2PSocket)1 I2PSocketEepGet (net.i2p.client.streaming.I2PSocketEepGet)1 DataFormatException (net.i2p.data.DataFormatException)1 Destination (net.i2p.data.Destination)1 Hash (net.i2p.data.Hash)1 Log (net.i2p.util.Log)1 SecureFile (net.i2p.util.SecureFile)1