Search in sources :

Example 6 with Status

use of net.i2p.router.CommSystemFacade.Status in project i2p.i2p by i2p.

the class PeerTestManager method testComplete.

/**
 * Evaluate the info we have and act accordingly, since the test has either timed out or
 * we have successfully received the second PeerTest from a Charlie.
 *
 * @param forgetTest must be true to clear out this test and allow another
 *
 * call from a synchronized method
 */
private void testComplete(boolean forgetTest) {
    _currentTestComplete = true;
    PeerTestState test = _currentTest;
    // Don't do this or we won't call honorStatus()
    // to set the status to UNKNOWN or REJECT_UNSOLICITED
    // if (expired()) {
    // _currentTest = null;
    // return;
    // }
    boolean isIPv6 = test.isIPv6();
    Status status;
    if (test.getAlicePortFromCharlie() > 0) {
        // we received a second message from charlie
        if ((test.getAlicePort() == test.getAlicePortFromCharlie()) && (test.getAliceIP() != null) && (test.getAliceIPFromCharlie() != null) && (test.getAliceIP().equals(test.getAliceIPFromCharlie()))) {
            status = isIPv6 ? Status.IPV4_UNKNOWN_IPV6_OK : Status.IPV4_OK_IPV6_UNKNOWN;
        } else {
            // we don't have a SNAT state for IPv6
            status = isIPv6 ? Status.IPV4_UNKNOWN_IPV6_FIREWALLED : Status.IPV4_SNAT_IPV6_UNKNOWN;
        }
    } else if (test.getReceiveCharlieTime() > 0) {
        // we received only one message from charlie
        status = Status.UNKNOWN;
    } else if (test.getReceiveBobTime() > 0) {
        // we received a message from bob but no messages from charlie
        status = isIPv6 ? Status.IPV4_UNKNOWN_IPV6_FIREWALLED : Status.IPV4_FIREWALLED_IPV6_UNKNOWN;
    } else {
        // we never received anything from bob - he is either down,
        // ignoring us, or unable to get a Charlie to respond
        status = Status.UNKNOWN;
    }
    if (_log.shouldLog(Log.INFO))
        _log.info("Test complete: " + test);
    honorStatus(status, isIPv6);
    if (forgetTest)
        _currentTest = null;
}
Also used : Status(net.i2p.router.CommSystemFacade.Status)

Example 7 with Status

use of net.i2p.router.CommSystemFacade.Status in project i2p.i2p by i2p.

the class TransportImpl method markUnreachable.

/**
 * called when we can't reach a peer
 */
public void markUnreachable(Hash peer) {
    Status status = _context.commSystem().getStatus();
    if (status == Status.DISCONNECTED || status == Status.HOSED)
        return;
    Long now = Long.valueOf(_context.clock().now());
    synchronized (_unreachableEntries) {
        // This isn't very useful since it is cleared when they contact us
        _unreachableEntries.put(peer, now);
    }
    // This is not cleared when they contact us
    markWasUnreachable(peer, true);
}
Also used : Status(net.i2p.router.CommSystemFacade.Status)

Example 8 with Status

use of net.i2p.router.CommSystemFacade.Status in project i2p.i2p by i2p.

the class SummaryHelper method reachability.

private NetworkStateMessage reachability() {
    if (_context.commSystem().isDummy())
        return new NetworkStateMessage(NetworkState.VMCOMM, "VM Comm System");
    if (_context.router().getUptime() > 60 * 1000 && (!_context.router().gracefulShutdownInProgress()) && !_context.clientManager().isAlive())
        // not a router problem but the user should know
        return new NetworkStateMessage(NetworkState.ERROR, _t("ERR-Client Manager I2CP Error - check logs"));
    // Warn based on actual skew from peers, not update status, so if we successfully offset
    // the clock, we don't complain.
    // if (!_context.clock().getUpdatedSuccessfully())
    long skew = _context.commSystem().getFramedAveragePeerClockSkew(33);
    // Display the actual skew, not the offset
    if (Math.abs(skew) > 30 * 1000)
        return new NetworkStateMessage(NetworkState.CLOCKSKEW, _t("ERR-Clock Skew of {0}", DataHelper.formatDuration2(Math.abs(skew))));
    if (_context.router().isHidden())
        return new NetworkStateMessage(NetworkState.HIDDEN, _t("Hidden"));
    RouterInfo routerInfo = _context.router().getRouterInfo();
    if (routerInfo == null)
        return new NetworkStateMessage(NetworkState.TESTING, _t("Testing"));
    Status status = _context.commSystem().getStatus();
    NetworkState state = NetworkState.RUNNING;
    switch(status) {
        case OK:
        case IPV4_OK_IPV6_UNKNOWN:
        case IPV4_OK_IPV6_FIREWALLED:
        case IPV4_UNKNOWN_IPV6_OK:
        case IPV4_DISABLED_IPV6_OK:
        case IPV4_SNAT_IPV6_OK:
            RouterAddress ra = routerInfo.getTargetAddress("NTCP");
            if (ra == null)
                return new NetworkStateMessage(NetworkState.RUNNING, _t(status.toStatusString()));
            byte[] ip = ra.getIP();
            if (ip == null)
                return new NetworkStateMessage(NetworkState.ERROR, _t("ERR-Unresolved TCP Address"));
            // TODO set IPv6 arg based on configuration?
            if (TransportUtil.isPubliclyRoutable(ip, true))
                return new NetworkStateMessage(NetworkState.RUNNING, _t(status.toStatusString()));
            return new NetworkStateMessage(NetworkState.ERROR, _t("ERR-Private TCP Address"));
        case IPV4_SNAT_IPV6_UNKNOWN:
        case DIFFERENT:
            return new NetworkStateMessage(NetworkState.ERROR, _t("ERR-SymmetricNAT"));
        case REJECT_UNSOLICITED:
            state = NetworkState.FIREWALLED;
        case IPV4_DISABLED_IPV6_FIREWALLED:
            if (routerInfo.getTargetAddress("NTCP") != null)
                return new NetworkStateMessage(NetworkState.WARN, _t("WARN-Firewalled with Inbound TCP Enabled"));
        // fall through...
        case IPV4_FIREWALLED_IPV6_OK:
        case IPV4_FIREWALLED_IPV6_UNKNOWN:
            if (((FloodfillNetworkDatabaseFacade) _context.netDb()).floodfillEnabled())
                return new NetworkStateMessage(NetworkState.WARN, _t("WARN-Firewalled and Floodfill"));
            // return new NetworkStateMessage(NetworkState.WARN, _t("WARN-Firewalled and Fast"));
            return new NetworkStateMessage(state, _t(status.toStatusString()));
        case DISCONNECTED:
            return new NetworkStateMessage(NetworkState.TESTING, _t("Disconnected - check network connection"));
        case HOSED:
            return new NetworkStateMessage(NetworkState.ERROR, _t("ERR-UDP Port In Use - Set i2np.udp.internalPort=xxxx in advanced config and restart"));
        case UNKNOWN:
            state = NetworkState.TESTING;
        case IPV4_UNKNOWN_IPV6_FIREWALLED:
        case IPV4_DISABLED_IPV6_UNKNOWN:
        default:
            ra = routerInfo.getTargetAddress("SSU");
            if (ra == null && _context.router().getUptime() > 5 * 60 * 1000) {
                if (getActivePeers() <= 0)
                    return new NetworkStateMessage(NetworkState.ERROR, _t("ERR-No Active Peers, Check Network Connection and Firewall"));
                else if (_context.getProperty(ConfigNetHelper.PROP_I2NP_NTCP_HOSTNAME) == null || _context.getProperty(ConfigNetHelper.PROP_I2NP_NTCP_PORT) == null)
                    return new NetworkStateMessage(NetworkState.ERROR, _t("ERR-UDP Disabled and Inbound TCP host/port not set"));
                else
                    return new NetworkStateMessage(NetworkState.WARN, _t("WARN-Firewalled with UDP Disabled"));
            }
            return new NetworkStateMessage(state, _t(status.toStatusString()));
    }
}
Also used : Status(net.i2p.router.CommSystemFacade.Status) FloodfillNetworkDatabaseFacade(net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade) RouterInfo(net.i2p.data.router.RouterInfo) RouterAddress(net.i2p.data.router.RouterAddress)

Aggregations

Status (net.i2p.router.CommSystemFacade.Status)8 RouterAddress (net.i2p.data.router.RouterAddress)3 IOException (java.io.IOException)1 SocketException (java.net.SocketException)1 UnknownHostException (java.net.UnknownHostException)1 Hash (net.i2p.data.Hash)1 RouterInfo (net.i2p.data.router.RouterInfo)1 FloodfillNetworkDatabaseFacade (net.i2p.router.networkdb.kademlia.FloodfillNetworkDatabaseFacade)1 TransportUtil (net.i2p.router.transport.TransportUtil)1 IPv6Config (net.i2p.router.transport.TransportUtil.IPv6Config)1