use of net.i2p.router.transport.ntcp.NTCPTransport 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");
}
use of net.i2p.router.transport.ntcp.NTCPTransport 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();
}
Aggregations