diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java index ce547cd029b10265236d35cc1639e9741ebd6807..24bbb9119a4237c0cb546382465bc657a454ad60 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/web/IndexBean.java @@ -145,7 +145,7 @@ public class IndexBean { if ( (_action == null) || (_action.trim().length() <= 0) || ("Cancel".equals(_action))) return ""; if ( (_prevNonce != _curNonce) && (!validPassphrase(_passphrase)) ) - return "Invalid nonce, are you being spoofed?"; + return "Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit."; if ("Stop all".equals(_action)) return stopAll(); else if ("Start all".equals(_action)) diff --git a/apps/routerconsole/java/src/net/i2p/router/web/FormHandler.java b/apps/routerconsole/java/src/net/i2p/router/web/FormHandler.java index 69a39c28cc71e591f78fba013ee56a41b6fe799f..e8f5e4d4231a4d9825dc780db33f24b4baca77f0 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/FormHandler.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/FormHandler.java @@ -12,7 +12,7 @@ import net.i2p.util.Log; * <jsp:setProperty name="handler" property="*" /> * * The form is "processed" after the properties are set and the first output - * property is retrieved - either getNotices() or getErrors(). + * property is retrieved - either getAll(), getNotices() or getErrors(). * */ public class FormHandler { @@ -21,8 +21,8 @@ public class FormHandler { private String _nonce; protected String _action; protected String _passphrase; - private List _errors; - private List _notices; + private List<String> _errors; + private List<String> _notices; private boolean _processed; private boolean _valid; @@ -78,6 +78,31 @@ public class FormHandler { _notices.add(msg); } + /** + * Display everything, wrap it in a div for consistent presentation + * + */ + public String getAllMessages() { + validate(); + process(); + if (_errors.size() <= 0 && _notices.size() <= 0) + return ""; + StringBuffer buf = new StringBuffer(512); + buf.append("<div class=\"messages\" id=\"messages\"><p>"); + if (_errors.size() > 0) { + buf.append("<span class=\"error\">"); + buf.append(render(_errors)); + buf.append("</span>"); + } + if (_notices.size() > 0) { + buf.append("<span class=\"notice\">"); + buf.append(render(_notices)); + buf.append("</span>"); + } + buf.append("</p></div>"); + return buf.toString(); + } + /** * Display any error messages (processing the form if it hasn't * been yet) @@ -85,6 +110,7 @@ public class FormHandler { */ public String getErrors() { validate(); + process(); return render(_errors); } @@ -95,6 +121,7 @@ public class FormHandler { */ public String getNotices() { validate(); + process(); return render(_notices); } @@ -133,28 +160,29 @@ public class FormHandler { if ( (expected != null) && (expected.trim().length() > 0) && (expected.equals(_passphrase)) ) { // ok } else { - addFormError("Invalid nonce, are you being spoofed?"); + addFormError("Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit."); _valid = false; } } } - private String render(List source) { + private void process() { if (!_processed) { if (_valid) processForm(); _processed = true; } + } + + private String render(List<String> source) { if (source.size() <= 0) { return ""; - } else if (source.size() == 1) { - return (String)source.get(0); } else { StringBuffer buf = new StringBuffer(512); buf.append("<ul>\n"); for (int i = 0; i < source.size(); i++) { buf.append("<li>"); - buf.append((String)source.get(i)); + buf.append(source.get(i)); buf.append("</li>\n"); } buf.append("</ul>\n"); diff --git a/apps/routerconsole/jsp/config.jsp b/apps/routerconsole/jsp/config.jsp index 16593f5d0b7303a6e05b12debee12671a5297fb4..3e5d5893fbfd39ad9c8cba270ca317f87226ad88 100644 --- a/apps/routerconsole/jsp/config.jsp +++ b/apps/routerconsole/jsp/config.jsp @@ -18,8 +18,7 @@ <jsp:useBean class="net.i2p.router.web.ConfigNetHandler" id="formhandler" scope="request" /> <jsp:setProperty name="formhandler" property="*" /> <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> - <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font> - <i><jsp:getProperty name="formhandler" property="notices" /></i> + <jsp:getProperty name="formhandler" property="allMessages" /> <form action="config.jsp" method="POST"> <% String prev = System.getProperty("net.i2p.router.web.ConfigNetHandler.nonce"); @@ -116,7 +115,7 @@ %> <br /> <input type="radio" name="udpAutoIP" value="hidden" <%=nethelper.getUdpAutoIPChecked(2) %> /> - Hidden mode - do not publish IP<i>(prevents participating traffic; change restarts router)</i><br /> + Hidden mode - do not publish IP <i>(prevents participating traffic; change restarts router)</i><br /> </p><p> <b>UDP Configuration:</b><br /> UDP port: diff --git a/apps/routerconsole/jsp/configadvanced.jsp b/apps/routerconsole/jsp/configadvanced.jsp index bdb64be38e1b7c4fd9d5ac2a542e2266d4b9d43e..dbf75ccf1575ab2da486527e75cf513592027216 100644 --- a/apps/routerconsole/jsp/configadvanced.jsp +++ b/apps/routerconsole/jsp/configadvanced.jsp @@ -19,8 +19,7 @@ <jsp:useBean class="net.i2p.router.web.ConfigAdvancedHandler" id="formhandler" scope="request" /> <jsp:setProperty name="formhandler" property="*" /> <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> - <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font> - <i><jsp:getProperty name="formhandler" property="notices" /></i> + <jsp:getProperty name="formhandler" property="allMessages" /> <form action="configadvanced.jsp" method="POST"> <% String prev = System.getProperty("net.i2p.router.web.ConfigAdvancedHandler.nonce"); diff --git a/apps/routerconsole/jsp/configclients.jsp b/apps/routerconsole/jsp/configclients.jsp index 8e66cb54eed530a12f27ea8b6c92b4cac95eda2d..96916fff128ff6f7480d19d021262ac67d58f11b 100644 --- a/apps/routerconsole/jsp/configclients.jsp +++ b/apps/routerconsole/jsp/configclients.jsp @@ -26,8 +26,7 @@ button span.hide{ <jsp:setProperty name="formhandler" property="action" value="<%=request.getParameter("action")%>" /> <jsp:setProperty name="formhandler" property="nonce" value="<%=request.getParameter("nonce")%>" /> <jsp:setProperty name="formhandler" property="settings" value="<%=request.getParameterMap()%>" /> - <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font> - <i><jsp:getProperty name="formhandler" property="notices" /></i> + <jsp:getProperty name="formhandler" property="allMessages" /> <form action="configclients.jsp" method="POST"> <% String prev = System.getProperty("net.i2p.router.web.ConfigClientsHandler.nonce"); diff --git a/apps/routerconsole/jsp/configkeyring.jsp b/apps/routerconsole/jsp/configkeyring.jsp index 7dd8bf1784bef7252ad2cad1bfd5c46374cd2c36..b26f094db8a32ca7cb74a34479d6460f8b1815f7 100644 --- a/apps/routerconsole/jsp/configkeyring.jsp +++ b/apps/routerconsole/jsp/configkeyring.jsp @@ -16,8 +16,7 @@ <jsp:useBean class="net.i2p.router.web.ConfigKeyringHandler" id="formhandler" scope="request" /> <jsp:setProperty name="formhandler" property="*" /> <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> - <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font> - <i><jsp:getProperty name="formhandler" property="notices" /></i> + <jsp:getProperty name="formhandler" property="allMessages" /> diff --git a/apps/routerconsole/jsp/configlogging.jsp b/apps/routerconsole/jsp/configlogging.jsp index 11db8e8b7fe055f8c5b90e7b9d86992a1464e315..65a661551debb3b744a42cdb6cf7d0dab9bc6e89 100644 --- a/apps/routerconsole/jsp/configlogging.jsp +++ b/apps/routerconsole/jsp/configlogging.jsp @@ -18,8 +18,7 @@ <jsp:useBean class="net.i2p.router.web.ConfigLoggingHandler" id="formhandler" scope="request" /> <jsp:setProperty name="formhandler" property="*" /> <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> - <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font> - <i><jsp:getProperty name="formhandler" property="notices" /></i> + <jsp:getProperty name="formhandler" property="allMessages" /> <form action="configlogging.jsp" method="POST"> <% String prev = System.getProperty("net.i2p.router.web.ConfigLoggingHandler.nonce"); diff --git a/apps/routerconsole/jsp/configpeer.jsp b/apps/routerconsole/jsp/configpeer.jsp index 5690e470e185a4f84778935524c1488e0f7a4f9f..590e39dab723e797a3f0690a0d1d9d9d9479531f 100644 --- a/apps/routerconsole/jsp/configpeer.jsp +++ b/apps/routerconsole/jsp/configpeer.jsp @@ -16,8 +16,7 @@ <jsp:useBean class="net.i2p.router.web.ConfigPeerHandler" id="formhandler" scope="request" /> <jsp:setProperty name="formhandler" property="*" /> <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> - <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font> - <i><jsp:getProperty name="formhandler" property="notices" /></i> + <jsp:getProperty name="formhandler" property="allMessages" /> diff --git a/apps/routerconsole/jsp/configservice.jsp b/apps/routerconsole/jsp/configservice.jsp index 4a720afeeb2c6f2466417e96ebef4463d1b5345e..5d9de218abfc1eab7f820d29992abc87e5890e55 100644 --- a/apps/routerconsole/jsp/configservice.jsp +++ b/apps/routerconsole/jsp/configservice.jsp @@ -16,8 +16,7 @@ <jsp:useBean class="net.i2p.router.web.ConfigServiceHandler" id="formhandler" scope="request" /> <jsp:setProperty name="formhandler" property="*" /> <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> - <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font> - <i><jsp:getProperty name="formhandler" property="notices" /></i> + <jsp:getProperty name="formhandler" property="allMessages" /> <form action="configservice.jsp" method="POST"> <% String prev = System.getProperty("net.i2p.router.web.ConfigServiceHandler.nonce"); diff --git a/apps/routerconsole/jsp/configstats.jsp b/apps/routerconsole/jsp/configstats.jsp index c7ec3090ca9b6a30e3be43e1a26591f624bb50a5..12e5f1b91f236a54bb33bc1676c28b0adf1d3ba2 100644 --- a/apps/routerconsole/jsp/configstats.jsp +++ b/apps/routerconsole/jsp/configstats.jsp @@ -61,8 +61,7 @@ function toggleAll(category) <jsp:useBean class="net.i2p.router.web.ConfigStatsHandler" id="formhandler" scope="request" /> <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> <jsp:setProperty name="formhandler" property="*" /> - <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font> - <i><jsp:getProperty name="formhandler" property="notices" /></i> + <jsp:getProperty name="formhandler" property="allMessages" /> <jsp:useBean class="net.i2p.router.web.ConfigStatsHelper" id="statshelper" scope="request" /> <jsp:setProperty name="statshelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> diff --git a/apps/routerconsole/jsp/configtunnels.jsp b/apps/routerconsole/jsp/configtunnels.jsp index e4559b86c200bbbf68a4222e9bbf14bdd7ba468e..b2ba61475b00309237833c7db44da73ebb64ca26 100644 --- a/apps/routerconsole/jsp/configtunnels.jsp +++ b/apps/routerconsole/jsp/configtunnels.jsp @@ -22,8 +22,7 @@ <jsp:setProperty name="formhandler" property="action" value="<%=request.getParameter("action")%>" /> <jsp:setProperty name="formhandler" property="nonce" value="<%=request.getParameter("nonce")%>" /> <jsp:setProperty name="formhandler" property="settings" value="<%=request.getParameterMap()%>" /> - <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font> - <i><jsp:getProperty name="formhandler" property="notices" /></i> + <jsp:getProperty name="formhandler" property="allMessages" /> <p><i> NOTE: The default settings work for most people. diff --git a/apps/routerconsole/jsp/configupdate.jsp b/apps/routerconsole/jsp/configupdate.jsp index ae6f9bc0cc25d385dd75e025527e72bed95fa1e1..59e621963197475eafd13de01d5a7750508077f7 100644 --- a/apps/routerconsole/jsp/configupdate.jsp +++ b/apps/routerconsole/jsp/configupdate.jsp @@ -16,8 +16,7 @@ <jsp:useBean class="net.i2p.router.web.ConfigUpdateHandler" id="formhandler" scope="request" /> <jsp:setProperty name="formhandler" property="*" /> <jsp:setProperty name="formhandler" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> - <font color="red"><jsp:getProperty name="formhandler" property="errors" /></font> - <i><jsp:getProperty name="formhandler" property="notices" /></i> + <jsp:getProperty name="formhandler" property="allMessages" /> <jsp:useBean class="net.i2p.router.web.ConfigUpdateHelper" id="updatehelper" scope="request" /> <jsp:setProperty name="updatehelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" /> diff --git a/apps/routerconsole/jsp/default.css b/apps/routerconsole/jsp/default.css index a996b5962719a7a8bf99fea024da5a556e0c349a..99077d1e013637fa26b5ac13deffaa339e3eeb28 100644 --- a/apps/routerconsole/jsp/default.css +++ b/apps/routerconsole/jsp/default.css @@ -89,9 +89,24 @@ div.news { } div.confignav { + padding: 1em; background-color: #efefff; } div.configure { + padding: 1em; background-color: #ffffc0; } + +div.messages { + padding: 1em; + background-color: #fafaff; +} + +div.messages span.error { + color: #d00000; +} + +div.messages span.notice { + font-style: italic; +} diff --git a/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java b/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java index de4cff527d55320f9a591eb3d4f0896d5107bad1..27971d47dab6e26b9e101f27cdfb334247f102a7 100644 --- a/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java +++ b/apps/susidns/src/java/src/i2p/susi/dns/AddressbookBean.java @@ -270,7 +270,7 @@ public class AddressbookBean } } else { - message += "Invalid nonce. Are you being spoofed?"; + message = "Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit."; } } diff --git a/apps/susidns/src/java/src/i2p/susi/dns/ConfigBean.java b/apps/susidns/src/java/src/i2p/susi/dns/ConfigBean.java index 85a4ffe6d1c45badf37a462d6b38cee83ce2d503..15a2204f8ebf5bcfc81d55e95dd167fa038adbdb 100644 --- a/apps/susidns/src/java/src/i2p/susi/dns/ConfigBean.java +++ b/apps/susidns/src/java/src/i2p/susi/dns/ConfigBean.java @@ -142,7 +142,7 @@ public class ConfigBean implements Serializable { } } else { - message = "Invalid nonce. Are you being spoofed?"; + message = "Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit."; } } if( message.length() > 0 ) diff --git a/apps/susidns/src/java/src/i2p/susi/dns/SubscriptionsBean.java b/apps/susidns/src/java/src/i2p/susi/dns/SubscriptionsBean.java index 5bcfa6d121dcabd13d84aa7c04d4be645014eabd..9d16701f90dd4247e32be0a7d398fcac578b7ecd 100644 --- a/apps/susidns/src/java/src/i2p/susi/dns/SubscriptionsBean.java +++ b/apps/susidns/src/java/src/i2p/susi/dns/SubscriptionsBean.java @@ -136,7 +136,7 @@ public class SubscriptionsBean } } else { - message = "Invalid nonce. Are you being spoofed?"; + message = "Invalid form submission, probably because you used the 'back' or 'reload' button on your browser. Please resubmit."; } } if( message.length() > 0 ) diff --git a/router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java b/router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java index 8820015af7c1a66b997e51d52274c07f37293c2a..63157ec843792236243ca3ebafc06f984932ff8c 100644 --- a/router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java +++ b/router/java/src/net/i2p/router/tunnel/pool/TunnelPoolManager.java @@ -523,8 +523,25 @@ public class TunnelPoolManager implements TunnelManagerFacade { long processedIn = (in != null ? in.getLifetimeProcessed() : 0); long processedOut = (outPool != null ? outPool.getLifetimeProcessed() : 0); - out.write("<table border=\"1\"><tr><td><b>Direction</b></td><td><b>Expiration</b></td><td><b>Usage</b></td><td align=\"left\">Hops (gateway first)</td></tr>\n"); int live = 0; + int maxLength = 1; + for (int i = 0; i < tunnels.size(); i++) { + TunnelInfo info = (TunnelInfo)tunnels.get(i); + if (info.getLength() > maxLength) + maxLength = info.getLength(); + } + out.write("<table border=\"1\"><tr><th>Direction</th><th>Expiration</th><th>Usage</th><th>Gateway</th>"); + if (maxLength > 3) { + out.write("<th align=\"center\" colspan=\"" + (maxLength - 2)); + out.write("\">Participants</th>"); + } + else if (maxLength == 3) { + out.write("<th>Participant</th>"); + } + if (maxLength > 1) { + out.write("<th>Endpoint</th>"); + } + out.write("</tr>\n"); for (int i = 0; i < tunnels.size(); i++) { TunnelInfo info = (TunnelInfo)tunnels.get(i); long timeLeft = info.getExpiration()-_context.clock().now(); @@ -546,6 +563,10 @@ public class TunnelPoolManager implements TunnelManagerFacade { String cap = getCapacity(peer); out.write("<td>" + netDbLink(peer) + (id == null ? "" : " " + id) + cap + "</td>"); } + if (info.getLength() < maxLength && (info.getLength() == 1 || j == info.getLength() - 2)) { + for (int k = info.getLength(); k < maxLength; k++) + out.write("<td> </td>"); + } } out.write("</tr>\n");