* configpeer.jsp: New
This commit is contained in:
@ -0,0 +1,80 @@
|
||||
package net.i2p.router.web;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.data.Base64;
|
||||
import net.i2p.router.Router;
|
||||
import net.i2p.router.peermanager.PeerProfile;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class ConfigPeerHandler extends FormHandler {
|
||||
private String _peer;
|
||||
private String _speed;
|
||||
private String _capacity;
|
||||
|
||||
protected void processForm() {
|
||||
if ("Save Configuration".equals(_action)) {
|
||||
_context.router().saveConfig();
|
||||
addFormNotice("Settings saved - not really!!!!!");
|
||||
} else if (_action.startsWith("Shitlist")) {
|
||||
Hash h = getHash();
|
||||
if (h != null) {
|
||||
_context.shitlist().shitlistRouterForever(h, "Manually shitlisted via <a href=\"configpeer.jsp\">configpeer.jsp</a>");
|
||||
addFormNotice("Peer " + _peer + " shitlisted forever");
|
||||
return;
|
||||
}
|
||||
addFormError("Invalid peer");
|
||||
} else if (_action.startsWith("Unshitlist")) {
|
||||
Hash h = getHash();
|
||||
if (h != null) {
|
||||
if (_context.shitlist().isShitlisted(h)) {
|
||||
_context.shitlist().unshitlistRouter(h);
|
||||
addFormNotice("Peer " + _peer + " unshitlisted");
|
||||
} else
|
||||
addFormNotice("Peer " + _peer + " is not currently shitlisted");
|
||||
return;
|
||||
}
|
||||
addFormError("Invalid peer");
|
||||
} else if (_action.startsWith("Adjust")) {
|
||||
Hash h = getHash();
|
||||
if (h != null) {
|
||||
PeerProfile prof = _context.profileOrganizer().getProfile(h);
|
||||
if (prof != null) {
|
||||
try {
|
||||
prof.setSpeedBonus(Long.parseLong(_speed));
|
||||
} catch (NumberFormatException nfe) {
|
||||
addFormError("Bad speed value");
|
||||
}
|
||||
try {
|
||||
prof.setCapacityBonus(Long.parseLong(_capacity));
|
||||
} catch (NumberFormatException nfe) {
|
||||
addFormError("Bad capacity value");
|
||||
}
|
||||
addFormNotice("Bonuses adjusted for " + _peer);
|
||||
} else
|
||||
addFormError("No profile exists for " + _peer);
|
||||
return;
|
||||
}
|
||||
addFormError("Invalid peer");
|
||||
} else if (_action.startsWith("Check")) {
|
||||
addFormError("Unsupported");
|
||||
}
|
||||
}
|
||||
|
||||
private Hash getHash() {
|
||||
if (_peer != null && _peer.length() == 44) {
|
||||
byte[] b = Base64.decode(_peer);
|
||||
if (b != null)
|
||||
return new Hash(b);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setPeer(String peer) { _peer = peer; }
|
||||
public void setSpeed(String bonus) { _speed = bonus; }
|
||||
public void setCapacity(String bonus) { _capacity = bonus; }
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package net.i2p.router.web;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.router.RouterContext;
|
||||
|
||||
public class ConfigPeerHelper {
|
||||
private RouterContext _context;
|
||||
/**
|
||||
* Configure this bean to query a particular router context
|
||||
*
|
||||
* @param contextId begging few characters of the routerHash, or null to pick
|
||||
* the first one we come across.
|
||||
*/
|
||||
public void setContextId(String contextId) {
|
||||
try {
|
||||
_context = ContextHelper.getContext(contextId);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigPeerHelper() {}
|
||||
|
||||
}
|
@ -8,6 +8,8 @@
|
||||
%>Tunnels | <% } else { %><a href="configtunnels.jsp">Tunnels</a> | <% }
|
||||
if (request.getRequestURI().indexOf("configclients.jsp") != -1) {
|
||||
%>Clients | <% } else { %><a href="configclients.jsp">Clients</a> | <% }
|
||||
if (request.getRequestURI().indexOf("configpeer.jsp") != -1) {
|
||||
%>Peers | <% } else { %><a href="configpeer.jsp">Peers</a> | <% }
|
||||
if (request.getRequestURI().indexOf("configlogging.jsp") != -1) {
|
||||
%>Logging | <% } else { %><a href="configlogging.jsp">Logging</a> | <% }
|
||||
if (request.getRequestURI().indexOf("configstats.jsp") != -1) {
|
||||
|
83
apps/routerconsole/jsp/configpeer.jsp
Normal file
83
apps/routerconsole/jsp/configpeer.jsp
Normal file
@ -0,0 +1,83 @@
|
||||
<%@page contentType="text/html"%>
|
||||
<%@page pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
|
||||
<html><head>
|
||||
<title>I2P Router Console - config peers</title>
|
||||
<link rel="stylesheet" href="default.css" type="text/css" />
|
||||
</head><body>
|
||||
|
||||
<%@include file="nav.jsp" %>
|
||||
<%@include file="summary.jsp" %>
|
||||
|
||||
<div class="main" id="main">
|
||||
<%@include file="confignav.jsp" %>
|
||||
|
||||
<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:useBean class="net.i2p.router.web.ConfigPeerHelper" id="peerhelper" scope="request" />
|
||||
<jsp:setProperty name="peerhelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
|
||||
|
||||
<% String peer = "";
|
||||
if (request.getParameter("peer") != null)
|
||||
peer = request.getParameter("peer");
|
||||
%>
|
||||
|
||||
<form action="configpeer.jsp" method="POST">
|
||||
<% String prev = System.getProperty("net.i2p.router.web.ConfigPeerHandler.nonce");
|
||||
if (prev != null) System.setProperty("net.i2p.router.web.ConfigPeerHandler.noncePrev", prev);
|
||||
System.setProperty("net.i2p.router.web.ConfigPeerHandler.nonce", new java.util.Random().nextLong()+""); %>
|
||||
<input type="hidden" name="nonce" value="<%=System.getProperty("net.i2p.router.web.ConfigPeerHandler.nonce")%>" />
|
||||
<hr />
|
||||
<p>
|
||||
<a name="sh"> </a>
|
||||
<a name="unsh"> </a>
|
||||
<a name="bonus"> </a>
|
||||
<h2>Manual Peer Controls</h2>
|
||||
Router Hash:
|
||||
<input type="text" size="55" name="peer" value="<%=peer%>" />
|
||||
<h3>Manually Shitlist / Unshitlist a Router</h3>
|
||||
Shitlisting will prevent the participation of this peer in tunnels you create.
|
||||
<p>
|
||||
<input type="submit" name="action" value="Shitlist peer until restart" />
|
||||
<input type="submit" name="action" value="Unshitlist peer" />
|
||||
<% if (! "".equals(peer)) { %>
|
||||
<font color="blue"><---- click to verify action</font>
|
||||
<% } %>
|
||||
</p>
|
||||
|
||||
<h3>Adjust Profile Bonuses</h3>
|
||||
Bonuses may be positive or negative, and affect the peer's inclusion in Fast and High Capacity tiers.
|
||||
Fast peers are used for client tunnels, and High Capacity peers are used for some exploratory tunnels.
|
||||
Current bonuses are displayed on the <a href="profiles.jsp">profiles page</a>.
|
||||
<p>
|
||||
<% long speed = 0; long capacity = 0;
|
||||
if (! "".equals(peer)) {
|
||||
// get existing bonus values?
|
||||
}
|
||||
%>
|
||||
Speed:
|
||||
<input type="text" size="8" name="speed" value="<%=speed%>" />
|
||||
Capacity:
|
||||
<input type="text" size="8" name="capacity" value="<%=capacity%>" />
|
||||
<input type="submit" name="action" value="Adjust peer bonuses" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<hr />
|
||||
<a name="shitlist"> </a>
|
||||
<jsp:useBean class="net.i2p.router.web.ProfilesHelper" id="profilesHelper" scope="request" />
|
||||
<jsp:setProperty name="profilesHelper" property="contextId" value="<%=(String)session.getAttribute("i2p.contextId")%>" />
|
||||
<jsp:getProperty name="profilesHelper" property="shitlistSummary" />
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user