diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/BanlistRenderer.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/BanlistRenderer.java index 64a530a8ccdfc96f741a16698b7f11a4988cc5e0..29e1c482bff7ca53d97aa42c3a469ca2de14474b 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/BanlistRenderer.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/BanlistRenderer.java @@ -56,6 +56,7 @@ class BanlistRenderer { buf.append("<ul id=\"banlist\">"); + String unban = _t("unban now"); for (Map.Entry<Hash, Banlist.Entry> e : entries.entrySet()) { Hash key = e.getKey(); Banlist.Entry entry = e.getValue(); @@ -82,8 +83,9 @@ class BanlistRenderer { buf.append(_t(entry.cause)); } if (!key.equals(Hash.FAKE_HASH)) { + // note: CSS hides anchor text buf.append(" <a href=\"configpeer?peer=").append(key.toBase64()) - .append("#unsh\">[").append(_t("unban now")).append("]</a>"); + .append("#unsh\" title=\"").append(unban).append("\">[").append(unban).append("]</a>"); } buf.append("</li>\n"); } diff --git a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigPeerHelper.java b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigPeerHelper.java index 3ac90c728e96b968c5c6bef43b8f2b2b6e89375f..67815308de921c382e8fc14b89dd42cc58932e3b 100644 --- a/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigPeerHelper.java +++ b/apps/routerconsole/java/src/net/i2p/router/web/helpers/ConfigPeerHelper.java @@ -5,6 +5,7 @@ import java.math.BigInteger; import java.util.Collections; import java.util.List; +import net.i2p.data.Hash; import net.i2p.router.Blocklist; import net.i2p.router.web.HelperBase; import net.i2p.util.Addresses; @@ -132,6 +133,13 @@ public class ConfigPeerHelper extends HelperBase { return out.toString(); } + /** + * @since 0.9.50 + */ + public boolean isBanned(Hash h) { + return _context.banlist().isBanlisted(h); + } + /** * Convert a (non-negative) two's complement IP to exactly 16 bytes * diff --git a/apps/routerconsole/jsp/configpeer.jsp b/apps/routerconsole/jsp/configpeer.jsp index a222c005e261cb37e7592f6582761b7fe4c85f78..fb8d89a4dbd3d4621c80df9a5b6bd35091e07ca3 100644 --- a/apps/routerconsole/jsp/configpeer.jsp +++ b/apps/routerconsole/jsp/configpeer.jsp @@ -15,8 +15,23 @@ <jsp:useBean class="net.i2p.router.web.helpers.ConfigPeerHelper" id="peerhelper" scope="request" /> <jsp:setProperty name="peerhelper" property="contextId" value="<%=i2pcontextId%>" /> <% String peer = ""; - if (request.getParameter("peer") != null) - peer = net.i2p.data.DataHelper.stripHTML(request.getParameter("peer")); // XSS + net.i2p.data.Hash peerHash = null; + boolean isBanned = false; + if (request.getParameter("peer") != null) { + // don't redisplay after POST, we don't do P-R-G + if (!"POST".equals(request.getMethod())) { + peer = net.i2p.data.DataHelper.stripHTML(request.getParameter("peer")); // XSS + if (peer.length() == 44) { + byte[] h = net.i2p.data.Base64.decode(peer); + if (h != null) { + try { + peerHash = net.i2p.data.Hash.create(h); + isBanned = peerhelper.isBanned(peerHash); + } catch (Exception e) {} + } + } + } + } %> <form action="configpeer" method="POST"> <input type="hidden" name="nonce" value="<%=pageNonce%>" > @@ -25,16 +40,23 @@ <a name="bonus"> </a> <h3 class="tabletitle"><%=intl._t("Manual Peer Controls")%></h3> <table class="configtable"> - <tr><td colspan="2"><b><%=intl._t("Router Hash")%>:</b> <input type="text" size="55" name="peer" value="<%=peer%>" /></td></tr> + <tr><td colspan="2"><b><%=intl._t("Router Hash")%>:</b> <input type="text" size="44" name="peer" value="<%=peer%>" /></td></tr> <tr><th colspan="2"><%=intl._t("Manually Ban / Unban a Peer")%></th></tr> <tr><td class="infohelp" colspan="2"><%=intl._t("Banning will prevent the participation of this peer in tunnels you create.")%></td></tr> <tr> <td class="optionsave" colspan="2"> +<% + if (peerHash == null || !isBanned) { + %> <input type="submit" name="action" class="delete" value="<%=intl._t("Ban peer until restart")%>" /> +<% + } + if (peerHash == null || isBanned) { + %> <input type="submit" name="action" class="accept" value="<%=intl._t("Unban peer")%>" /> - <% if (! "".equals(peer)) { %> - <!-- <font color="blue"><---- click to verify action</font> --> - <% } %> +<% + } + %> </td> </tr> <tr><th colspan="2"><%=intl._t("Adjust Profile Bonuses")%></th></tr>