Search in sources :

Example 16 with TunnelInfo

use of net.i2p.router.TunnelInfo in project i2p.i2p by i2p.

the class TunnelPoolManager method selectInboundTunnel.

/**
 * Pick a random inbound exploratory tunnel.
 * Warning - selectInboundExploratoryTunnel(Hash) is preferred.
 *
 * @return null if none
 */
public TunnelInfo selectInboundTunnel() {
    TunnelInfo info = _inboundExploratory.selectTunnel();
    if (info == null) {
        _inboundExploratory.buildFallback();
        // still can be null, but probably not
        info = _inboundExploratory.selectTunnel();
    }
    return info;
}
Also used : TunnelInfo(net.i2p.router.TunnelInfo)

Example 17 with TunnelInfo

use of net.i2p.router.TunnelInfo in project i2p.i2p by i2p.

the class TunnelPoolManager method getTunnelInfo.

/**
 *  Expensive (iterates through all tunnels of all pools) and unnecessary.
 *  @deprecated unused
 */
@Deprecated
public TunnelInfo getTunnelInfo(TunnelId id) {
    TunnelInfo info = null;
    for (TunnelPool pool : _clientInboundPools.values()) {
        info = pool.getTunnel(id);
        if (info != null)
            return info;
    }
    info = _inboundExploratory.getTunnel(id);
    if (info != null)
        return info;
    info = _outboundExploratory.getTunnel(id);
    if (info != null)
        return info;
    return null;
}
Also used : TunnelInfo(net.i2p.router.TunnelInfo)

Example 18 with TunnelInfo

use of net.i2p.router.TunnelInfo in project i2p.i2p by i2p.

the class TunnelPoolManager method selectOutboundTunnel.

/**
 * Pick a random outbound exploratory tunnel.
 * Warning - selectOutboundExploratoryTunnel(Hash) is preferred.
 *
 * @return null if none
 */
public TunnelInfo selectOutboundTunnel() {
    TunnelInfo info = _outboundExploratory.selectTunnel();
    if (info == null) {
        _outboundExploratory.buildFallback();
        // still can be null, but probably not
        info = _outboundExploratory.selectTunnel();
    }
    return info;
}
Also used : TunnelInfo(net.i2p.router.TunnelInfo)

Example 19 with TunnelInfo

use of net.i2p.router.TunnelInfo in project i2p.i2p by i2p.

the class TunnelPoolManager method countTunnelsPerPeer.

/**
 * @return total number of non-fallback expl. + client tunnels
 */
private int countTunnelsPerPeer(ObjectCounter<Hash> lc) {
    List<TunnelPool> pools = new ArrayList<TunnelPool>();
    listPools(pools);
    int tunnelCount = 0;
    for (TunnelPool tp : pools) {
        for (TunnelInfo info : tp.listTunnels()) {
            if (info.getLength() > 1) {
                tunnelCount++;
                for (int j = 0; j < info.getLength(); j++) {
                    Hash peer = info.getPeer(j);
                    if (!_context.routerHash().equals(peer))
                        lc.increment(peer);
                }
            }
        }
    }
    return tunnelCount;
}
Also used : ArrayList(java.util.ArrayList) TunnelInfo(net.i2p.router.TunnelInfo) Hash(net.i2p.data.Hash)

Example 20 with TunnelInfo

use of net.i2p.router.TunnelInfo in project i2p.i2p by i2p.

the class TunnelPoolManager method selectInboundExploratoryTunnel.

/**
 * Pick the inbound exploratory tunnel with the gateway closest to the given hash.
 * By using this instead of the random selectTunnel(),
 * we force some locality in OBEP-IBGW connections to minimize
 * those connections network-wide.
 *
 * @param closestTo non-null
 * @return null if none
 * @since 0.8.10
 */
public TunnelInfo selectInboundExploratoryTunnel(Hash closestTo) {
    TunnelInfo info = _inboundExploratory.selectTunnel(closestTo);
    if (info == null) {
        _inboundExploratory.buildFallback();
        // still can be null, but probably not
        info = _inboundExploratory.selectTunnel();
    }
    return info;
}
Also used : TunnelInfo(net.i2p.router.TunnelInfo)

Aggregations

TunnelInfo (net.i2p.router.TunnelInfo)30 Hash (net.i2p.data.Hash)15 TunnelId (net.i2p.data.TunnelId)8 RouterInfo (net.i2p.data.router.RouterInfo)6 ArrayList (java.util.ArrayList)4 DatabaseLookupMessage (net.i2p.data.i2np.DatabaseLookupMessage)4 DatabaseStoreMessage (net.i2p.data.i2np.DatabaseStoreMessage)4 I2NPMessage (net.i2p.data.i2np.I2NPMessage)4 TunnelManagerFacade (net.i2p.router.TunnelManagerFacade)4 Job (net.i2p.router.Job)3 TunnelPoolSettings (net.i2p.router.TunnelPoolSettings)3 HashSet (java.util.HashSet)2 OutNetMessage (net.i2p.router.OutNetMessage)2 ReplyJob (net.i2p.router.ReplyJob)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1