forked from I2P_Developers/i2p.i2p
Console: Add tooltip to unban link
Don't show both ban and unban buttons if peer param provided Don't put hash in form again after ban/unban POST
This commit is contained in:
@@ -56,6 +56,7 @@ class BanlistRenderer {
|
|||||||
|
|
||||||
buf.append("<ul id=\"banlist\">");
|
buf.append("<ul id=\"banlist\">");
|
||||||
|
|
||||||
|
String unban = _t("unban now");
|
||||||
for (Map.Entry<Hash, Banlist.Entry> e : entries.entrySet()) {
|
for (Map.Entry<Hash, Banlist.Entry> e : entries.entrySet()) {
|
||||||
Hash key = e.getKey();
|
Hash key = e.getKey();
|
||||||
Banlist.Entry entry = e.getValue();
|
Banlist.Entry entry = e.getValue();
|
||||||
@@ -82,8 +83,9 @@ class BanlistRenderer {
|
|||||||
buf.append(_t(entry.cause));
|
buf.append(_t(entry.cause));
|
||||||
}
|
}
|
||||||
if (!key.equals(Hash.FAKE_HASH)) {
|
if (!key.equals(Hash.FAKE_HASH)) {
|
||||||
|
// note: CSS hides anchor text
|
||||||
buf.append(" <a href=\"configpeer?peer=").append(key.toBase64())
|
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");
|
buf.append("</li>\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.math.BigInteger;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.i2p.data.Hash;
|
||||||
import net.i2p.router.Blocklist;
|
import net.i2p.router.Blocklist;
|
||||||
import net.i2p.router.web.HelperBase;
|
import net.i2p.router.web.HelperBase;
|
||||||
import net.i2p.util.Addresses;
|
import net.i2p.util.Addresses;
|
||||||
@@ -132,6 +133,13 @@ public class ConfigPeerHelper extends HelperBase {
|
|||||||
return out.toString();
|
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
|
* Convert a (non-negative) two's complement IP to exactly 16 bytes
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -15,8 +15,23 @@
|
|||||||
<jsp:useBean class="net.i2p.router.web.helpers.ConfigPeerHelper" id="peerhelper" scope="request" />
|
<jsp:useBean class="net.i2p.router.web.helpers.ConfigPeerHelper" id="peerhelper" scope="request" />
|
||||||
<jsp:setProperty name="peerhelper" property="contextId" value="<%=i2pcontextId%>" />
|
<jsp:setProperty name="peerhelper" property="contextId" value="<%=i2pcontextId%>" />
|
||||||
<% String peer = "";
|
<% String peer = "";
|
||||||
if (request.getParameter("peer") != null)
|
net.i2p.data.Hash peerHash = null;
|
||||||
peer = net.i2p.data.DataHelper.stripHTML(request.getParameter("peer")); // XSS
|
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">
|
<form action="configpeer" method="POST">
|
||||||
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
|
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
|
||||||
@@ -25,16 +40,23 @@
|
|||||||
<a name="bonus"> </a>
|
<a name="bonus"> </a>
|
||||||
<h3 class="tabletitle"><%=intl._t("Manual Peer Controls")%></h3>
|
<h3 class="tabletitle"><%=intl._t("Manual Peer Controls")%></h3>
|
||||||
<table class="configtable">
|
<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><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="infohelp" colspan="2"><%=intl._t("Banning will prevent the participation of this peer in tunnels you create.")%></td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="optionsave" colspan="2">
|
<td class="optionsave" colspan="2">
|
||||||
|
<%
|
||||||
|
if (peerHash == null || !isBanned) {
|
||||||
|
%>
|
||||||
<input type="submit" name="action" class="delete" value="<%=intl._t("Ban peer until restart")%>" />
|
<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")%>" />
|
<input type="submit" name="action" class="accept" value="<%=intl._t("Unban peer")%>" />
|
||||||
<% if (! "".equals(peer)) { %>
|
<%
|
||||||
<!-- <font color="blue"><---- click to verify action</font> -->
|
}
|
||||||
<% } %>
|
%>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><th colspan="2"><%=intl._t("Adjust Profile Bonuses")%></th></tr>
|
<tr><th colspan="2"><%=intl._t("Adjust Profile Bonuses")%></th></tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user