i2pcontrol: Handle more router states mapping to i2pcontrol states

Linkify start/stop webapp on password page
This commit is contained in:
zzz
2022-01-02 11:13:15 -05:00
parent 131da9bdb9
commit 2d42541b79
2 changed files with 31 additions and 12 deletions

View File

@@ -156,11 +156,11 @@ public class JSONRPC2Servlet extends HttpServlet {
} else {
out.println("<p>Current API password:<input name=\"password\" type=\"password\">");
}
out.println("<p>New API password (twice):<input name=\"password2\" type=\"password\">" +
"<input name=\"password3\" type=\"password\">" +
out.println("<p>New API password (twice): <input name=\"password2\" type=\"password\"> " +
"<input name=\"password3\" type=\"password\"> " +
"<input name=\"save\" type=\"submit\" value=\"Change API Password\">" +
"<p>If you forget the API password, stop i2pcontrol, delete the file <tt>" + _conf.getConfFile() +
"</tt>, and restart i2pcontrol.");
"<p>If you forget the API password, <a href=\"/configwebapps\">stop jsonrpc</a>, delete the file <tt>" + _conf.getConfFile() +
"</tt>, and <a href=\"/configwebapps\">restart jsonrpc</a>.");
out.println("</form>");
} else {
out.println("<p><a href=\"password\">Change API Password</a>");

View File

@@ -179,25 +179,44 @@ public class RouterInfoHandler implements RequestHandler {
int status = _context.commSystem().getStatus().getCode();
switch (status) {
case CommSystemFacade.STATUS_OK:
RouterAddress ra = _context.router().getRouterInfo().getTargetAddress("NTCP");
case CommSystemFacade.STATUS_OK:
case CommSystemFacade.STATUS_IPV4_OK_IPV6_UNKNOWN:
case CommSystemFacade.STATUS_IPV4_OK_IPV6_FIREWALLED:
case CommSystemFacade.STATUS_IPV4_FIREWALLED_IPV6_OK:
case CommSystemFacade.STATUS_IPV4_DISABLED_IPV6_OK:
RouterAddress ra = _context.router().getRouterInfo().getTargetAddress("NTCP2");
if (ra == null || TransportUtil.isPubliclyRoutable(ra.getIP(), true))
return NETWORK_STATUS.OK;
return NETWORK_STATUS.ERROR_PRIVATE_TCP_ADDRESS;
case CommSystemFacade.STATUS_DIFFERENT:
case CommSystemFacade.STATUS_DIFFERENT:
case CommSystemFacade.STATUS_IPV4_SNAT_IPV6_OK:
case CommSystemFacade.STATUS_IPV4_SNAT_IPV6_UNKNOWN:
return NETWORK_STATUS.ERROR_SYMMETRIC_NAT;
case CommSystemFacade.STATUS_REJECT_UNSOLICITED:
if (_context.router().getRouterInfo().getTargetAddress("NTCP") != null)
case CommSystemFacade.STATUS_REJECT_UNSOLICITED:
case CommSystemFacade.STATUS_IPV4_FIREWALLED_IPV6_UNKNOWN:
case CommSystemFacade.STATUS_IPV4_DISABLED_IPV6_FIREWALLED:
if (_context.router().getRouterInfo().getTargetAddress("NTCP2") != null)
return NETWORK_STATUS.WARN_FIREWALLED_WITH_INBOUND_TCP;
if (((FloodfillNetworkDatabaseFacade) _context.netDb()).floodfillEnabled())
return NETWORK_STATUS.WARN_FIREWALLED_AND_FLOODFILL;
if (_context.router().getRouterInfo().getCapabilities().indexOf('O') >= 0)
return NETWORK_STATUS.WARN_FIREWALLED_AND_FAST;
return NETWORK_STATUS.FIREWALLED;
case CommSystemFacade.STATUS_HOSED:
case CommSystemFacade.STATUS_HOSED:
return NETWORK_STATUS.ERROR_UDP_PORT_IN_USE;
case CommSystemFacade.STATUS_UNKNOWN: // fallthrough
default:
case CommSystemFacade.STATUS_DISCONNECTED:
return NETWORK_STATUS.ERROR_NO_ACTIVE_PEERS_CHECK_CONNECTION_AND_FIREWALL;
case CommSystemFacade.STATUS_UNKNOWN: // fallthrough
case CommSystemFacade.STATUS_IPV4_UNKNOWN_IPV6_OK:
case CommSystemFacade.STATUS_IPV4_UNKNOWN_IPV6_FIREWALLED:
case CommSystemFacade.STATUS_IPV4_DISABLED_IPV6_UNKNOWN:
default:
ra = _context.router().getRouterInfo().getTargetAddress("SSU");
if (ra == null && _context.router().getUptime() > 5 * 60 * 1000) {
if (_context.commSystem().countActivePeers() <= 0)