Search in sources :

Example 1 with UDPTransport

use of net.i2p.router.transport.udp.UDPTransport in project i2p.i2p by i2p.

the class CommSystemFacadeImpl method notifyReplaceAddress.

/**
 * UDP changed addresses, tell NTCP and restart
 *
 * All the work moved to NTCPTransport.externalAddressReceived()
 *
 * @param udpAddr may be null; or udpAddr's host/IP may be null
 */
@Override
public void notifyReplaceAddress(RouterAddress udpAddr) {
    byte[] ip = null;
    int port = 0;
    // we probably shouldn't, see UDPTransport rebuildExternalAddress() TODO
    if (udpAddr != null && udpAddr.getOption("ihost0") == null) {
        ip = udpAddr.getIP();
        port = udpAddr.getPort();
    }
    if (port < 0) {
        Transport udp = _manager.getTransport(UDPTransport.STYLE);
        if (udp != null)
            port = udp.getRequestedPort();
    }
    if (ip != null || port > 0)
        _manager.externalAddressReceived(Transport.AddressSource.SOURCE_SSU, ip, port);
    else
        notifyRemoveAddress(false);
}
Also used : UDPTransport(net.i2p.router.transport.udp.UDPTransport)

Example 2 with UDPTransport

use of net.i2p.router.transport.udp.UDPTransport in project i2p.i2p by i2p.

the class TransportManager method configTransports.

private void configTransports() {
    boolean enableUDP = _context.getBooleanPropertyDefaultTrue(PROP_ENABLE_UDP);
    Transport udp = null;
    if (enableUDP) {
        udp = new UDPTransport(_context, _dhThread);
        addTransport(udp);
        initializeAddress(udp);
    }
    if (isNTCPEnabled(_context)) {
        Transport ntcp = new NTCPTransport(_context, _dhThread);
        addTransport(ntcp);
        initializeAddress(ntcp);
        if (udp != null) {
            // pass along the port SSU is probably going to use
            // so that NTCP may bind early
            int port = udp.getRequestedPort();
            if (port > 0)
                ntcp.externalAddressReceived(SOURCE_CONFIG, (byte[]) null, port);
        }
    }
    if (_transports.isEmpty())
        _log.log(Log.CRIT, "No transports are enabled");
}
Also used : UDPTransport(net.i2p.router.transport.udp.UDPTransport) NTCPTransport(net.i2p.router.transport.ntcp.NTCPTransport) UDPTransport(net.i2p.router.transport.udp.UDPTransport) NTCPTransport(net.i2p.router.transport.ntcp.NTCPTransport)

Example 3 with UDPTransport

use of net.i2p.router.transport.udp.UDPTransport in project i2p.i2p by i2p.

the class PeerHelper method renderStatusHTML.

/**
 *  Warning - blocking, very slow, queries the active UPnP router,
 *  will take many seconds if it has vanished.
 *
 *  @since 0.9.31 moved from TransportManager
 */
private void renderStatusHTML(Writer out, String urlBase, int sortFlags) throws IOException {
    if (isAdvanced()) {
        out.write("<p id=\"upnpstatus\"><b>");
        out.write(_t("Status"));
        out.write(": ");
        out.write(_t(_context.commSystem().getStatus().toStatusString()));
        out.write("</b></p>");
    }
    SortedMap<String, Transport> transports = _context.commSystem().getTransports();
    for (Map.Entry<String, Transport> e : transports.entrySet()) {
        String style = e.getKey();
        Transport t = e.getValue();
        if (style.equals("NTCP")) {
            NTCPTransport nt = (NTCPTransport) t;
            render(nt, out, urlBase, sortFlags);
        } else if (style.equals("SSU")) {
            UDPTransport ut = (UDPTransport) t;
            render(ut, out, urlBase, sortFlags);
        } else {
            // pluggable (none yet)
            t.renderStatusHTML(out, urlBase, sortFlags);
        }
    }
    if (!transports.isEmpty()) {
        out.write(getTransportsLegend());
    }
    StringBuilder buf = new StringBuilder(4 * 1024);
    buf.append("<h3 id=\"transports\">").append(_t("Router Transport Addresses")).append("</h3><pre id=\"transports\">\n");
    for (Transport t : transports.values()) {
        if (t.hasCurrentAddress()) {
            for (RouterAddress ra : t.getCurrentAddresses()) {
                buf.append(ra.toString());
                buf.append("\n\n");
            }
        } else {
            buf.append(_t("{0} is used for outbound connections only", t.getStyle()));
            buf.append("\n\n");
        }
    }
    buf.append("</pre>\n");
    out.write(buf.toString());
    // UPnP Status
    _context.commSystem().renderStatusHTML(_out, _urlBase, _sortFlags);
    out.write("</p>\n");
    out.flush();
}
Also used : RouterAddress(net.i2p.data.router.RouterAddress) UDPTransport(net.i2p.router.transport.udp.UDPTransport) NTCPTransport(net.i2p.router.transport.ntcp.NTCPTransport) Transport(net.i2p.router.transport.Transport) UDPTransport(net.i2p.router.transport.udp.UDPTransport) TreeMap(java.util.TreeMap) Map(java.util.Map) SortedMap(java.util.SortedMap) NTCPTransport(net.i2p.router.transport.ntcp.NTCPTransport)

Aggregations

UDPTransport (net.i2p.router.transport.udp.UDPTransport)3 NTCPTransport (net.i2p.router.transport.ntcp.NTCPTransport)2 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 RouterAddress (net.i2p.data.router.RouterAddress)1 Transport (net.i2p.router.transport.Transport)1