Search in sources :

Example 1 with PortMapper

use of net.i2p.util.PortMapper in project i2p.i2p by i2p.

the class SummaryBarRenderer method renderI2PServicesHTML.

public String renderI2PServicesHTML() {
    StringBuilder buf = new StringBuilder(512);
    buf.append("<h3><a href=\"/configclients\" target=\"_top\" title=\"").append(_t("Configure startup of clients and webapps (services); manually start dormant services")).append("\">").append(_t("I2P Services")).append("</a></h3>\n" + "<hr class=\"b\"><table id=\"sb_services\"><tr><td>");
    PortMapper pm = _context.portMapper();
    if (pm.getPort(PortMapper.SVC_SUSIMAIL) > 0) {
        buf.append("<a href=\"/webmail\" target=\"_top\" title=\"").append(_t("Anonymous webmail client")).append("\">").append(nbsp(_t("Email"))).append("</a>\n");
    }
    if (pm.getPort(PortMapper.SVC_I2PSNARK) > 0) {
        buf.append("<a href=\"/torrents\" target=\"_top\" title=\"").append(_t("Built-in anonymous BitTorrent Client")).append("\">").append(nbsp(_t("Torrents"))).append("</a>\n");
    }
    int port = pm.getPort(PortMapper.SVC_EEPSITE);
    int sslPort = pm.getPort(PortMapper.SVC_HTTPS_EEPSITE);
    if (sslPort > 0 || port > 0) {
        String svc;
        if (sslPort > 0) {
            buf.append("<a href=\"https://");
            svc = PortMapper.SVC_HTTPS_EEPSITE;
            port = sslPort;
        } else {
            buf.append("<a href=\"http://");
            svc = PortMapper.SVC_EEPSITE;
        }
        buf.append(pm.getActualHost(svc, "127.0.0.1")).append(':').append(port).append("/\" target=\"_blank\" title=\"").append(_t("Local web server")).append("\">").append(nbsp(_t("Web Server"))).append("</a>\n");
    }
    buf.append(NavHelper.getClientAppLinks(_context)).append("</td></tr></table>\n");
    return buf.toString();
}
Also used : PortMapper(net.i2p.util.PortMapper)

Example 2 with PortMapper

use of net.i2p.util.PortMapper in project i2p.i2p by i2p.

the class SummaryBarRenderer method renderI2PInternalsHTML.

public String renderI2PInternalsHTML() {
    StringBuilder buf = new StringBuilder(512);
    buf.append("<h3><a href=\"/config\" target=\"_top\" title=\"").append(_t("Configure I2P Router")).append("\">").append(_t("I2P Internals")).append("</a></h3><hr class=\"b\">\n" + "<table id=\"sb_internals\"><tr><td>\n");
    PortMapper pm = _context.portMapper();
    if (pm.getPort(PortMapper.SVC_SUSIDNS) > 0) {
        buf.append("<a href=\"/dns\" target=\"_top\" title=\"").append(_t("Manage your I2P hosts file here (I2P domain name resolution)")).append("\">").append(nbsp(_t("Addressbook"))).append("</a>\n");
    }
    if (!StatSummarizer.isDisabled()) {
        buf.append("<a href=\"/graphs\" target=\"_top\" title=\"").append(_t("Graph router performance")).append("\">").append(nbsp(_t("Graphs"))).append("</a>\n");
    }
    buf.append("<a href=\"/help\" target=\"_top\" title=\"").append(_t("Router Help and FAQ")).append("\">").append(nbsp(_t("Help"))).append("</a>\n");
    if (pm.getPort(PortMapper.SVC_I2PTUNNEL) > 0) {
        buf.append("<a href=\"/i2ptunnelmgr\" target=\"_top\" title=\"").append(_t("Local Tunnels")).append("\">").append(nbsp(_t("Hidden Services Manager"))).append("</a>\n");
    }
    buf.append("<a href=\"/logs\" target=\"_top\" title=\"").append(_t("Health Report")).append("\">").append(nbsp(_t("Logs"))).append("</a>\n" + "<a href=\"/netdb\" target=\"_top\" title=\"").append(_t("Show list of all known I2P routers")).append("\">").append(nbsp(_t("NetDB"))).append("</a>\n" + "<a href=\"/peers\" target=\"_top\" title=\"").append(_t("Show all current peer connections")).append("\">").append(nbsp(_t("Peers"))).append("</a>\n" + "<a href=\"/profiles\" target=\"_top\" title=\"").append(_t("Show recent peer performance profiles")).append("\">").append(nbsp(_t("Profiles"))).append("</a>\n" + "<a href=\"/tunnels\" target=\"_top\" title=\"").append(_t("View existing tunnels and tunnel build status")).append("\">").append(nbsp(_t("Tunnels"))).append("</a>\n");
    buf.append("</td></tr></table>\n");
    return buf.toString();
}
Also used : PortMapper(net.i2p.util.PortMapper)

Example 3 with PortMapper

use of net.i2p.util.PortMapper in project i2p.i2p by i2p.

the class LocalHTTPServer method writeRedirectPage.

/**
 * @since 0.8.7
 */
private static void writeRedirectPage(OutputStream out, boolean success, String host, String book, String url) throws IOException {
    String tbook;
    if ("hosts.txt".equals(book))
        tbook = _t("router");
    else if ("userhosts.txt".equals(book))
        tbook = _t("master");
    else if ("privatehosts.txt".equals(book))
        tbook = _t("private");
    else
        tbook = book;
    PortMapper pm = I2PAppContext.getGlobalContext().portMapper();
    String conURL = pm.getConsoleURL();
    out.write(("HTTP/1.1 200 OK\r\n" + "Content-Type: text/html; charset=UTF-8\r\n" + "Referrer-Policy: no-referrer\r\n" + "Connection: close\r\n" + "Proxy-Connection: close\r\n" + "\r\n" + "<html><head>" + "<title>" + _t("Redirecting to {0}", host) + "</title>\n" + "<link rel=\"shortcut icon\" href=\"http://proxy.i2p/themes/console/images/favicon.ico\" >\n" + "<link href=\"http://proxy.i2p/themes/console/default/console.css\" rel=\"stylesheet\" type=\"text/css\" >\n" + "<meta http-equiv=\"Refresh\" content=\"1; url=" + url + "\">\n" + "</head><body>\n" + "<div class=logo>\n" + "<a href=\"" + conURL + "\" title=\"" + _t("Router Console") + "\"><img src=\"http://proxy.i2p/themes/console/images/i2plogo.png\" alt=\"I2P Router Console\" border=\"0\"></a><hr>\n" + "<a href=\"" + conURL + "config\">" + _t("Configuration") + "</a> <a href=\"" + conURL + "help.jsp\">" + _t("Help") + "</a>").getBytes("UTF-8"));
    if (pm.getPort(PortMapper.SVC_SUSIDNS) > 0)
        out.write((" <a href=\"" + conURL + "susidns/index\">" + _t("Addressbook") + "</a>\n").getBytes("UTF-8"));
    out.write(("</div>" + "<div class=warning id=warning>\n" + "<h3>" + (success ? _t("Saved {0} to the {1} addressbook, redirecting now.", host, tbook) : _t("Failed to save {0} to the {1} addressbook, redirecting now.", host, tbook)) + "</h3>\n<p><a href=\"" + url + "\">" + _t("Click here if you are not redirected automatically.") + "</a></p></div>").getBytes("UTF-8"));
    I2PTunnelHTTPClient.writeFooter(out);
    out.flush();
}
Also used : PortMapper(net.i2p.util.PortMapper)

Example 4 with PortMapper

use of net.i2p.util.PortMapper in project i2p.i2p by i2p.

the class RouterConsoleRunner method shutdown.

/**
 * @since 0.9.4
 */
public synchronized void shutdown(String[] args) {
    if (_state == STOPPED)
        return;
    changeState(STOPPING);
    if (PluginStarter.pluginsEnabled(_context))
        (new I2PAppThread(new PluginStopper(_context), "PluginStopper")).start();
    stopAllWebApps();
    try {
        _server.stop();
    } catch (Exception ie) {
    }
    PortMapper portMapper = _context.portMapper();
    portMapper.unregister(PortMapper.SVC_CONSOLE);
    portMapper.unregister(PortMapper.SVC_HTTPS_CONSOLE);
    synchronized (RouterConsoleRunner.class) {
        if (_jettyTimer != null) {
            try {
                _jettyTimer.stop();
            } catch (Exception e) {
            }
            _jettyTimer = null;
        }
    }
    changeState(STOPPED);
}
Also used : PortMapper(net.i2p.util.PortMapper) I2PAppThread(net.i2p.util.I2PAppThread) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException)

Example 5 with PortMapper

use of net.i2p.util.PortMapper in project i2p.i2p by i2p.

the class HomeHelper method renderApps.

private String renderApps(Collection<App> apps) {
    String website = _t("Web Server");
    StringBuilder buf = new StringBuilder(1024);
    buf.append("<div class=\"appgroup\">");
    PortMapper pm = _context.portMapper();
    for (App app : apps) {
        String url;
        if (app.name.equals(website) && app.url.equals("http://127.0.0.1:7658/")) {
            int port = pm.getPort(PortMapper.SVC_EEPSITE);
            int sslPort = pm.getPort(PortMapper.SVC_HTTPS_EEPSITE);
            if (port <= 0 && sslPort <= 0)
                continue;
            // fixup eepsite link
            if (sslPort > 0) {
                url = "https://" + pm.getActualHost(PortMapper.SVC_HTTPS_EEPSITE, "127.0.0.1") + ':' + sslPort + '/';
            } else {
                url = "http://" + pm.getActualHost(PortMapper.SVC_EEPSITE, "127.0.0.1") + ':' + port + '/';
            }
        } else {
            url = app.url;
            // check for disabled webapps and other things
            if (url.equals("/dns")) {
                if (pm.getPort("susidns") <= 0)
                    continue;
            } else if (url.equals("/webmail")) {
                if (pm.getPort("susimail") <= 0)
                    continue;
            } else if (url.equals("/torrents")) {
                if (pm.getPort("i2psnark") <= 0)
                    continue;
            } else if (url.equals("/configplugins")) {
                if (!PluginStarter.pluginsEnabled(_context))
                    continue;
            }
        }
        buf.append("\n<div class=\"app\">\n" + "<div class=\"appimg\">" + // usability: add tabindex -1 so we avoid 2 tabs per app
        "<a href=\"").append(url).append("\" tabindex=\"-1\">" + "<img alt=\"\" title=\"").append(app.desc).append("\" src=\"").append(app.icon).append("\"></a>" + "</div>\n" + "<table><tr><td>" + "<div class=\"applabel\">" + "<a href=\"").append(url).append("\" title=\"").append(app.desc).append("\">").append(app.name).append("</a>" + "</div>" + "</td></tr></table>\n" + "</div>");
    }
    buf.append("</div>\n");
    return buf.toString();
}
Also used : App(net.i2p.router.web.App) PortMapper(net.i2p.util.PortMapper)

Aggregations

PortMapper (net.i2p.util.PortMapper)5 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 App (net.i2p.router.web.App)1 I2PAppThread (net.i2p.util.I2PAppThread)1