* Console: Some colon cleansing

* Shitlist: Move HTML renderer to router console,
      add cause parameter for ease of translation,
      tag all causes
This commit is contained in:
zzz
2009-11-11 20:28:13 +00:00
parent 573ac357d8
commit 6c00bb20b6
16 changed files with 223 additions and 78 deletions

View File

@ -35,8 +35,11 @@ fi
# list specific files in router/ here, so we don't scan the whole tree # list specific files in router/ here, so we don't scan the whole tree
ROUTERFILES="\ ROUTERFILES="\
../../../router/java/src/net/i2p/router/RouterThrottleImpl.java \ ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java \
../../../router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java" ../../../router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java \
JPATHS="src ../jsp/WEB-INF strings $JFILE $ROUTERFILES" ../../../router/java/src/net/i2p/router/transport/TransportManager.java \
../../../router/java/src/net/i2p/router/transport/GetBidsJob.java \
../../../router/java/src/net/i2p/router/Blocklist.java \
../../../router/java/src/net/i2p/router/transport/ntcp/EstablishState.java"
for i in ../locale/messages_*.po for i in ../locale/messages_*.po
do do
# get language # get language

View File

@ -24,7 +24,12 @@ fi
# list specific files in router/ here, so we don't scan the whole tree # list specific files in router/ here, so we don't scan the whole tree
ROUTERFILES="\ ROUTERFILES="\
../../../router/java/src/net/i2p/router/RouterThrottleImpl.java \ ../../../router/java/src/net/i2p/router/RouterThrottleImpl.java \
../../../router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java" ../../../router/java/src/net/i2p/router/tunnel/pool/BuildHandler.java \
../../../router/java/src/net/i2p/router/transport/TransportManager.java \
../../../router/java/src/net/i2p/router/transport/GetBidsJob.java \
../../../router/java/src/net/i2p/router/Blocklist.java \
../../../router/java/src/net/i2p/router/transport/ntcp/EstablishState.java"
JPATHS="src ../jsp/WEB-INF strings $JFILE $ROUTERFILES" JPATHS="src ../jsp/WEB-INF strings $JFILE $ROUTERFILES"
for i in ../locale/messages_*.po for i in ../locale/messages_*.po
do do

View File

@ -20,7 +20,7 @@ public class ConfigPeerHandler extends FormHandler {
} else if (_action.equals(_("Ban peer until restart"))) { } else if (_action.equals(_("Ban peer until restart"))) {
Hash h = getHash(); Hash h = getHash();
if (h != null) { if (h != null) {
_context.shitlist().shitlistRouterForever(h, "Manually banned via <a href=\"configpeer.jsp\">configpeer.jsp</a>"); _context.shitlist().shitlistRouterForever(h, _("Manually banned via {0}"), "<a href=\"configpeer.jsp\">configpeer.jsp</a>");
addFormNotice(_("Peer") + " " + _peer + " " + _("banned until restart") ); addFormNotice(_("Peer") + " " + _peer + " " + _("banned until restart") );
return; return;
} }

View File

@ -276,7 +276,7 @@ public class NetDbRenderer {
} }
for (Iterator iter = info.getAddresses().iterator(); iter.hasNext(); ) { for (Iterator iter = info.getAddresses().iterator(); iter.hasNext(); ) {
RouterAddress addr = (RouterAddress)iter.next(); RouterAddress addr = (RouterAddress)iter.next();
buf.append("<b>").append(DataHelper.stripHTML(addr.getTransportStyle())).append("</b>: "); buf.append("<b>").append(DataHelper.stripHTML(addr.getTransportStyle())).append(":</b> ");
for (Iterator optIter = addr.getOptions().keySet().iterator(); optIter.hasNext(); ) { for (Iterator optIter = addr.getOptions().keySet().iterator(); optIter.hasNext(); ) {
String name = (String)optIter.next(); String name = (String)optIter.next();
String val = addr.getOptions().getProperty(name); String val = addr.getOptions().getProperty(name);

View File

@ -234,14 +234,14 @@ class ProfileOrganizerRenderer {
} }
buf.append("</table>"); buf.append("</table>");
buf.append("<h3>").append(_("Thresholds:")).append("</h3>"); buf.append("<h3>").append(_("Thresholds")).append("</h3>");
buf.append("<p><b>").append(_("Speed")).append(":</b> ").append(num(_organizer.getSpeedThreshold())) buf.append("<p><b>").append(_("Speed")).append(":</b> ").append(num(_organizer.getSpeedThreshold()))
.append(" (").append(fast).append(' ').append(_("fast peers")).append(")<br>"); .append(" (").append(fast).append(' ').append(_("fast peers")).append(")<br>");
buf.append("<b>").append(_("Capacity")).append(":</b> ").append(num(_organizer.getCapacityThreshold())) buf.append("<b>").append(_("Capacity")).append(":</b> ").append(num(_organizer.getCapacityThreshold()))
.append(" (").append(reliable).append(' ').append(_("high capacity peers")).append(")<br>"); .append(" (").append(reliable).append(' ').append(_("high capacity peers")).append(")<br>");
buf.append("<b>").append(_("Integration")).append(":</b> ").append(num(_organizer.getIntegrationThreshold())) buf.append("<b>").append(_("Integration")).append(":</b> ").append(num(_organizer.getIntegrationThreshold()))
.append(" (").append(integrated).append(' ').append(_(" well integrated peers")).append(")</p>"); .append(" (").append(integrated).append(' ').append(_(" well integrated peers")).append(")</p>");
buf.append("<h3>").append(_("Definitions")).append(":</h3><ul>"); buf.append("<h3>").append(_("Definitions")).append("</h3><ul>");
buf.append("<li><b>").append(_("groups")).append("</b>: ").append(_("as determined by the profile organizer")).append("</li>"); buf.append("<li><b>").append(_("groups")).append("</b>: ").append(_("as determined by the profile organizer")).append("</li>");
buf.append("<li><b>").append(_("caps")).append("</b>: ").append(_("capabilities in the netDb, not used to determine profiles")).append("</li>"); buf.append("<li><b>").append(_("caps")).append("</b>: ").append(_("capabilities in the netDb, not used to determine profiles")).append("</li>");
buf.append("<li><b>").append(_("speed")).append("</b>: ").append(_("peak throughput (bytes per second) over a 1 minute period that the peer has sustained in a single tunnel")).append("</li>"); buf.append("<li><b>").append(_("speed")).append("</b>: ").append(_("peak throughput (bytes per second) over a 1 minute period that the peer has sustained in a single tunnel")).append("</li>");

View File

@ -20,7 +20,8 @@ public class ProfilesHelper extends HelperBase {
/** @return empty string, writes directly to _out */ /** @return empty string, writes directly to _out */
public String getShitlistSummary() { public String getShitlistSummary() {
try { try {
_context.shitlist().renderStatusHTML(_out); ShitlistRenderer rend = new ShitlistRenderer(_context);
rend.renderStatusHTML(_out);
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
} }

View File

@ -0,0 +1,99 @@
package net.i2p.router.web;
/*
* free (adj.): unencumbered; not under the control of others
* Written by jrandom in 2003 and released into the public domain
* with no warranty of any kind, either expressed or implied.
* It probably won't make your computer catch on fire, or eat
* your children, but it might. Use at your own risk.
*
*/
import java.io.IOException;
import java.io.Writer;
import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import net.i2p.data.DataHelper;
import net.i2p.data.Hash;
import net.i2p.router.RouterContext;
import net.i2p.router.Shitlist;
/**
* Moved from Shitlist.java
*/
public class ShitlistRenderer {
private RouterContext _context;
public ShitlistRenderer(RouterContext context) {
_context = context;
}
private static class HashComparator implements Comparator {
public int compare(Object l, Object r) {
return ((Hash)l).toBase64().compareTo(((Hash)r).toBase64());
}
}
public void renderStatusHTML(Writer out) throws IOException {
StringBuilder buf = new StringBuilder(1024);
// move to the jsp
//buf.append("<h2>Banned Peers</h2>");
Map<Hash, Shitlist.Entry> entries = new TreeMap(new HashComparator());
entries.putAll(_context.shitlist().getEntries());
buf.append("<ul>");
for (Map.Entry<Hash, Shitlist.Entry> e : entries.entrySet()) {
Hash key = e.getKey();
Shitlist.Entry entry = e.getValue();
buf.append("<li>").append(_context.commSystem().renderPeerHTML(key));
buf.append(' ');
long expires = entry.expireOn-_context.clock().now();
String expireString = DataHelper.formatDuration(expires);
if (expires < 5l*24*60*60*1000)
buf.append(_("Temporary ban expiring in {0}", expireString));
else
buf.append(_("Banned until restart or in {0}", expireString));
Set transports = entry.transports;
if ( (transports != null) && (transports.size() > 0) )
buf.append(" on the following transport: ").append(transports);
if (entry.cause != null) {
buf.append("<br>\n");
if (entry.causeCode != null)
buf.append(_(entry.cause, entry.causeCode));
else
buf.append(_(entry.cause));
}
buf.append(" (<a href=\"configpeer.jsp?peer=").append(key.toBase64())
.append("#unsh\">").append(_("unban now")).append("</a>)");
buf.append("</li>\n");
}
buf.append("</ul>\n");
out.write(buf.toString());
out.flush();
}
/** translate a string */
private String _(String s) {
return Messages.getString(s, _context);
}
/**
* translate a string with a parameter
* This is a lot more expensive than _(s), so use sparingly.
*
* @param s string to be translated containing {0}
* The {0} will be replaced by the parameter.
* Single quotes must be doubled, i.e. ' -> '' in the string.
* @param o parameter, not translated.
* To tranlslate parameter also, use _("foo {0} bar", _("baz"))
* Do not double the single quotes in the parameter.
* Use autoboxing to call with ints, longs, floats, etc.
*/
private String _(String s, Object o) {
return Messages.getString(s, o, _context);
}
}

View File

@ -37,7 +37,7 @@ public class TunnelRenderer {
} }
public void renderStatusHTML(Writer out) throws IOException { public void renderStatusHTML(Writer out) throws IOException {
out.write("<div class=\"wideload\"><h2><a name=\"exploratory\" ></a>" + _("Exploratory tunnels") + " (<a href=\"/configtunnels.jsp#exploratory\">" + _("config") + "</a>):</h2>\n"); out.write("<div class=\"wideload\"><h2><a name=\"exploratory\" ></a>" + _("Exploratory tunnels") + " (<a href=\"/configtunnels.jsp#exploratory\">" + _("configure") + "</a>)</h2>\n");
renderPool(out, _context.tunnelManager().getInboundExploratoryPool(), _context.tunnelManager().getOutboundExploratoryPool()); renderPool(out, _context.tunnelManager().getInboundExploratoryPool(), _context.tunnelManager().getOutboundExploratoryPool());
List<Hash> destinations = null; List<Hash> destinations = null;
@ -59,15 +59,15 @@ public class TunnelRenderer {
out.write("<h2><a name=\"" + client.toBase64().substring(0,4) out.write("<h2><a name=\"" + client.toBase64().substring(0,4)
+ "\" ></a>" + _("Client tunnels for") + ' ' + _(name)); + "\" ></a>" + _("Client tunnels for") + ' ' + _(name));
if (_context.clientManager().isLocal(client)) if (_context.clientManager().isLocal(client))
out.write(" (<a href=\"/configtunnels.jsp#" + client.toBase64().substring(0,4) +"\">" + _("config") + "</a>):</h2>\n"); out.write(" (<a href=\"/configtunnels.jsp#" + client.toBase64().substring(0,4) +"\">" + _("configure") + "</a>)</h2>\n");
else else
out.write(" (dead):</h2>\n"); out.write(" (" + _("dead") + ")</h2>\n");
renderPool(out, in, outPool); renderPool(out, in, outPool);
} }
List participating = _context.tunnelDispatcher().listParticipatingTunnels(); List participating = _context.tunnelDispatcher().listParticipatingTunnels();
Collections.sort(participating, new TunnelComparator()); Collections.sort(participating, new TunnelComparator());
out.write("<h2><a name=\"participating\"></a>" + _("Participating tunnels") + ":</h2><table>\n"); out.write("<h2><a name=\"participating\"></a>" + _("Participating tunnels") + "</h2><table>\n");
out.write("<tr><th>" + _("Receive on") + "</th><th>" + _("From") + "</th><th>" out.write("<tr><th>" + _("Receive on") + "</th><th>" + _("From") + "</th><th>"
+ _("Send on") + "</th><th>" + _("To") + "</th><th>" + _("Expiration") + "</th>" + _("Send on") + "</th><th>" + _("To") + "</th><th>" + _("Expiration") + "</th>"
+ "<th>" + _("Usage") + "</th><th>" + _("Rate") + "</th><th>" + _("Role") + "</th></tr>\n"); + "<th>" + _("Usage") + "</th><th>" + _("Rate") + "</th><th>" + _("Role") + "</th></tr>\n");
@ -104,7 +104,7 @@ public class TunnelRenderer {
if (timeLeft > 0) if (timeLeft > 0)
out.write(" <td class=\"cells\" align=\"center\">" + DataHelper.formatDuration(timeLeft) + "</td>"); out.write(" <td class=\"cells\" align=\"center\">" + DataHelper.formatDuration(timeLeft) + "</td>");
else else
out.write(" <td class=\"cells\" align=\"center\">(grace period)</td>"); out.write(" <td class=\"cells\" align=\"center\">(" + _("grace period") + ")</td>");
out.write(" <td class=\"cells\" align=\"center\">" + cfg.getProcessedMessagesCount() + "KB</td>"); out.write(" <td class=\"cells\" align=\"center\">" + cfg.getProcessedMessagesCount() + "KB</td>");
int lifetime = (int) ((_context.clock().now() - cfg.getCreation()) / 1000); int lifetime = (int) ((_context.clock().now() - cfg.getCreation()) / 1000);
if (lifetime <= 0) if (lifetime <= 0)
@ -231,7 +231,7 @@ public class TunnelRenderer {
List<Hash> peerList = new ArrayList(peers); List<Hash> peerList = new ArrayList(peers);
Collections.sort(peerList, new HashComparator()); Collections.sort(peerList, new HashComparator());
out.write("<h2><a name=\"peers\"></a>" + _("Tunnel Counts By Peer") + ":</h2>\n"); out.write("<h2><a name=\"peers\"></a>" + _("Tunnel Counts By Peer") + "</h2>\n");
out.write("<table><tr><th>" + _("Peer") + "</th><th>" + _("Expl. + Client") + "</th><th>" + _("% of total") + "</th><th>" + _("Part. from + to") + "</th><th>" + _("% of total") + "</th></tr>\n"); out.write("<table><tr><th>" + _("Peer") + "</th><th>" + _("Expl. + Client") + "</th><th>" + _("% of total") + "</th><th>" + _("Part. from + to") + "</th><th>" + _("% of total") + "</th></tr>\n");
for (Hash h : peerList) { for (Hash h : peerList) {
out.write("<tr> <td class=\"cells\" align=\"center\">"); out.write("<tr> <td class=\"cells\" align=\"center\">");

View File

@ -1,3 +1,10 @@
2009-11-11 zzz
* Console: Some colon cleansing
* FloodfillPeerSelector: Adjustments
* Shitlist: Move HTML renderer to router console,
add cause parameter for ease of translation,
tag all causes
2009-11-11 zzz 2009-11-11 zzz
* Addressbook, NamingService: Allow 516 byte dests * Addressbook, NamingService: Allow 516 byte dests
that end with AA but not AAAA, so we can permit that end with AA but not AAAA, so we can permit

View File

@ -111,11 +111,13 @@ public class Blocklist {
} }
for (Iterator iter = _peerBlocklist.keySet().iterator(); iter.hasNext(); ) { for (Iterator iter = _peerBlocklist.keySet().iterator(); iter.hasNext(); ) {
Hash peer = (Hash) iter.next(); Hash peer = (Hash) iter.next();
String reason = "Banned by router hash"; String reason;
String comment = (String) _peerBlocklist.get(peer); String comment = (String) _peerBlocklist.get(peer);
if (comment != null) if (comment != null)
reason = reason + ": " + comment; reason = _x("Banned by router hash: {0}");
_context.shitlist().shitlistRouterForever(peer, reason); else
reason = _x("Banned by router hash");
_context.shitlist().shitlistRouterForever(peer, reason, comment);
} }
_peerBlocklist = null; _peerBlocklist = null;
@ -659,7 +661,7 @@ public class Blocklist {
*/ */
public void shitlist(Hash peer) { public void shitlist(Hash peer) {
// Temporary reason, until the job finishes // Temporary reason, until the job finishes
_context.shitlist().shitlistRouterForever(peer, "IP Banned"); _context.shitlist().shitlistRouterForever(peer, _x("IP banned"));
if (! "true".equals( _context.getProperty(PROP_BLOCKLIST_DETAIL, "true"))) if (! "true".equals( _context.getProperty(PROP_BLOCKLIST_DETAIL, "true")))
return; return;
boolean shouldRunJob; boolean shouldRunJob;
@ -729,16 +731,17 @@ public class Blocklist {
} }
if (match(ipint, toEntry(e.ip1, e.ip2))) { if (match(ipint, toEntry(e.ip1, e.ip2))) {
try { in.close(); } catch (IOException ioe) {} try { in.close(); } catch (IOException ioe) {}
String reason = "IP "; String reason = _x("IP banned by blocklist.txt entry {0}");
for (int i = 0; i < 4; i++) { // only one translate parameter for now
reason = reason + (ip[i] & 0xff); //for (int i = 0; i < 4; i++) {
if (i != 3) // reason = reason + (ip[i] & 0xff);
reason = reason + '.'; // if (i != 3)
} // reason = reason + '.';
reason = reason + " banned by " + BLOCKLIST_FILE_DEFAULT + " entry \"" + buf + "\""; //}
//reason = reason + " banned by " + BLOCKLIST_FILE_DEFAULT + " entry \"" + buf + "\"";
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
_log.warn("Shitlisting " + peer + " " + reason); _log.warn("Shitlisting " + peer + " " + reason);
_context.shitlist().shitlistRouterForever(peer, reason); _context.shitlist().shitlistRouterForever(peer, reason, buf.toString());
return; return;
} }
buf.setLength(0); buf.setLength(0);
@ -791,6 +794,16 @@ public class Blocklist {
out.flush(); out.flush();
} }
/**
* Mark a string for extraction by xgettext and translation.
* Use this only in static initializers.
* It does not translate!
* @return s
*/
private static final String _x(String s) {
return s;
}
public static void main(String args[]) { public static void main(String args[]) {
Blocklist b = new Blocklist(); Blocklist b = new Blocklist();
if ( (args != null) && (args.length == 1) ) if ( (args != null) && (args.length == 1) )

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 15; public final static long BUILD = 16;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = ""; public final static String EXTRA = "";
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA; public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;

View File

@ -12,12 +12,11 @@ import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeMap;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
import net.i2p.data.Hash; import net.i2p.data.Hash;
@ -36,13 +35,15 @@ public class Shitlist {
private RouterContext _context; private RouterContext _context;
private Map<Hash, Entry> _entries; private Map<Hash, Entry> _entries;
private static class Entry { public static class Entry {
/** when it should expire, per the i2p clock */ /** when it should expire, per the i2p clock */
long expireOn; public long expireOn;
/** why they were shitlisted */ /** why they were shitlisted */
String cause; public String cause;
/** separate code so cause can contain {0} for translation */
public String causeCode;
/** what transports they were shitlisted for (String), or null for all transports */ /** what transports they were shitlisted for (String), or null for all transports */
Set<String> transports; public Set<String> transports;
} }
public final static long SHITLIST_DURATION_MS = 20*60*1000; public final static long SHITLIST_DURATION_MS = 20*60*1000;
@ -95,17 +96,32 @@ public class Shitlist {
return _entries.size(); return _entries.size();
} }
/** for ShitlistRenderer in router console */
public Map<Hash, Entry> getEntries() {
return new HashMap<Hash, Entry>(_entries);
}
public boolean shitlistRouter(Hash peer) { public boolean shitlistRouter(Hash peer) {
return shitlistRouter(peer, null); return shitlistRouter(peer, null);
} }
public boolean shitlistRouter(Hash peer, String reason) { return shitlistRouter(peer, reason, null); } public boolean shitlistRouter(Hash peer, String reason) { return shitlistRouter(peer, reason, null); }
/** ick have to put the reasonCode in the front to avoid ambiguity */
public boolean shitlistRouter(String reasonCode, Hash peer, String reason) {
return shitlistRouter(peer, reason, reasonCode, null, false);
}
public boolean shitlistRouter(Hash peer, String reason, String transport) { public boolean shitlistRouter(Hash peer, String reason, String transport) {
return shitlistRouter(peer, reason, transport, false); return shitlistRouter(peer, reason, transport, false);
} }
public boolean shitlistRouterForever(Hash peer, String reason) { public boolean shitlistRouterForever(Hash peer, String reason) {
return shitlistRouter(peer, reason, null, true); return shitlistRouter(peer, reason, null, true);
} }
public boolean shitlistRouterForever(Hash peer, String reason, String reasonCode) {
return shitlistRouter(peer, reason, reasonCode, null, true);
}
public boolean shitlistRouter(Hash peer, String reason, String transport, boolean forever) { public boolean shitlistRouter(Hash peer, String reason, String transport, boolean forever) {
return shitlistRouter(peer, reason, null, null, true);
}
private boolean shitlistRouter(Hash peer, String reason, String reasonCode, String transport, boolean forever) {
if (peer == null) { if (peer == null) {
_log.error("wtf, why did we try to shitlist null?", new Exception("shitfaced")); _log.error("wtf, why did we try to shitlist null?", new Exception("shitfaced"));
return false; return false;
@ -137,6 +153,7 @@ public class Shitlist {
e.expireOn = _context.clock().now() + period; e.expireOn = _context.clock().now() + period;
} }
e.cause = reason; e.cause = reason;
e.causeCode = reasonCode;
e.transports = null; e.transports = null;
if (transport != null) { if (transport != null) {
e.transports = new ConcurrentHashSet(1); e.transports = new ConcurrentHashSet(1);
@ -150,6 +167,7 @@ public class Shitlist {
if (old.expireOn > e.expireOn) { if (old.expireOn > e.expireOn) {
e.expireOn = old.expireOn; e.expireOn = old.expireOn;
e.cause = old.cause; e.cause = old.cause;
e.causeCode = old.causeCode;
} }
if (e.transports != null) { if (e.transports != null) {
if (old.transports != null) if (old.transports != null)
@ -157,6 +175,7 @@ public class Shitlist {
else { else {
e.transports = null; e.transports = null;
e.cause = reason; e.cause = reason;
e.causeCode = reasonCode;
} }
} }
} }
@ -245,44 +264,7 @@ public class Shitlist {
return entry != null && entry.expireOn > _context.clock().now() + SHITLIST_DURATION_MAX; return entry != null && entry.expireOn > _context.clock().now() + SHITLIST_DURATION_MAX;
} }
class HashComparator implements Comparator { /** @deprecated moved to router console */
public int compare(Object l, Object r) {
return ((Hash)l).toBase64().compareTo(((Hash)r).toBase64());
}
}
public void renderStatusHTML(Writer out) throws IOException { public void renderStatusHTML(Writer out) throws IOException {
StringBuilder buf = new StringBuilder(1024);
// move to the jsp
//buf.append("<h2>Banned Peers</h2>");
Map<Hash, Entry> entries = new TreeMap(new HashComparator());
entries.putAll(_entries);
buf.append("<ul>");
for (Map.Entry<Hash, Entry> e : entries.entrySet()) {
Hash key = e.getKey();
Entry entry = e.getValue();
buf.append("<li>").append(_context.commSystem().renderPeerHTML(key));
long expires = entry.expireOn-_context.clock().now();
if (expires < 5l*24*60*60*1000)
buf.append(" Temporary ban expiring in ");
else
buf.append(" Banned until restart or in ");
buf.append(DataHelper.formatDuration(expires));
Set transports = entry.transports;
if ( (transports != null) && (transports.size() > 0) )
buf.append(" on the following transport: ").append(transports);
if (entry.cause != null) {
buf.append("<br>\n");
buf.append(entry.cause);
}
buf.append(" (<a href=\"configpeer.jsp?peer=").append(key.toBase64()).append("#unsh\">unban now</a>)");
buf.append("</li>\n");
}
buf.append("</ul>\n");
out.write(buf.toString());
out.flush();
} }
} }

View File

@ -67,7 +67,7 @@ public class GetBidsJob extends JobImpl {
if (failedCount == 0) { if (failedCount == 0) {
context.statManager().addRateData("transport.bidFailNoTransports", msg.getLifetime(), 0); context.statManager().addRateData("transport.bidFailNoTransports", msg.getLifetime(), 0);
// This used to be "no common transports" but it is almost always no transports at all // This used to be "no common transports" but it is almost always no transports at all
context.shitlist().shitlistRouter(to, "No transports (hidden or starting up?)"); context.shitlist().shitlistRouter(to, _x("No transports (hidden or starting up?)"));
} else if (failedCount >= facade.getTransportCount()) { } else if (failedCount >= facade.getTransportCount()) {
context.statManager().addRateData("transport.bidFailAllTransports", msg.getLifetime(), 0); context.statManager().addRateData("transport.bidFailAllTransports", msg.getLifetime(), 0);
// fail after all transports were unsuccessful // fail after all transports were unsuccessful
@ -98,4 +98,14 @@ public class GetBidsJob extends JobImpl {
msg.discardData(); msg.discardData();
} }
/**
* Mark a string for extraction by xgettext and translation.
* Use this only in static initializers.
* It does not translate!
* @return s
*/
private static final String _x(String s) {
return s;
}
} }

View File

@ -447,7 +447,7 @@ public class TransportManager implements TransportEventListener {
// Don't shitlist if we aren't talking to anybody, as we may have a network connection issue // Don't shitlist if we aren't talking to anybody, as we may have a network connection issue
if (unreachableTransports >= _transports.size() && countActivePeers() > 0) { if (unreachableTransports >= _transports.size() && countActivePeers() > 0) {
_context.statManager().addRateData("transport.shitlistOnUnreachable", msg.getLifetime(), msg.getLifetime()); _context.statManager().addRateData("transport.shitlistOnUnreachable", msg.getLifetime(), msg.getLifetime());
_context.shitlist().shitlistRouter(peer, "Unreachable on any transport"); _context.shitlist().shitlistRouter(peer, _x("Unreachable on any transport"));
} }
} else if (rv == null) { } else if (rv == null) {
_context.statManager().addRateData("transport.noBidsYetNotAllUnreachable", unreachableTransports, msg.getLifetime()); _context.statManager().addRateData("transport.noBidsYetNotAllUnreachable", unreachableTransports, msg.getLifetime());
@ -493,7 +493,7 @@ public class TransportManager implements TransportEventListener {
t.renderStatusHTML(out, urlBase, sortFlags); t.renderStatusHTML(out, urlBase, sortFlags);
} }
StringBuilder buf = new StringBuilder(4*1024); StringBuilder buf = new StringBuilder(4*1024);
buf.append("<h3>Router Transport Addresses:</h3><pre>\n"); buf.append("<h3>Router Transport Addresses</h3><pre>\n");
for (int i = 0; i < _transports.size(); i++) { for (int i = 0; i < _transports.size(); i++) {
Transport t = (Transport)_transports.get(i); Transport t = (Transport)_transports.get(i);
if (t.getCurrentAddress() != null) if (t.getCurrentAddress() != null)
@ -508,4 +508,15 @@ public class TransportManager implements TransportEventListener {
buf.append("</p>\n"); buf.append("</p>\n");
out.flush(); out.flush();
} }
/**
* Mark a string for extraction by xgettext and translation.
* Use this only in static initializers.
* It does not translate!
* @return s
*/
private static final String _x(String s) {
return s;
}
} }

View File

@ -368,8 +368,9 @@ public class EstablishState {
if (diff >= Router.CLOCK_FUDGE_FACTOR) { if (diff >= Router.CLOCK_FUDGE_FACTOR) {
_context.statManager().addRateData("ntcp.invalidOutboundSkew", diff, 0); _context.statManager().addRateData("ntcp.invalidOutboundSkew", diff, 0);
_transport.markReachable(_con.getRemotePeer().calculateHash(), false); _transport.markReachable(_con.getRemotePeer().calculateHash(), false);
_context.shitlist().shitlistRouter(_con.getRemotePeer().calculateHash(), _context.shitlist().shitlistRouter(DataHelper.formatDuration(diff),
"Excessive clock skew: " + DataHelper.formatDuration(diff)); _con.getRemotePeer().calculateHash(),
_x("Excessive clock skew: {0}"));
fail("Clocks too skewed (" + diff + " ms)", null, true); fail("Clocks too skewed (" + diff + " ms)", null, true);
return; return;
} else if (_log.shouldLog(Log.DEBUG)) { } else if (_log.shouldLog(Log.DEBUG)) {
@ -572,7 +573,9 @@ public class EstablishState {
if (diff >= Router.CLOCK_FUDGE_FACTOR) { if (diff >= Router.CLOCK_FUDGE_FACTOR) {
_context.statManager().addRateData("ntcp.invalidInboundSkew", diff, 0); _context.statManager().addRateData("ntcp.invalidInboundSkew", diff, 0);
_transport.markReachable(alice.calculateHash(), true); _transport.markReachable(alice.calculateHash(), true);
_context.shitlist().shitlistRouter(alice.calculateHash(), "Clock skew of " + diff + " ms"); _context.shitlist().shitlistRouter(DataHelper.formatDuration(diff),
alice.calculateHash(),
_x("Excessive clock skew: {0}"));
fail("Clocks too skewed (" + diff + " ms)", null, true); fail("Clocks too skewed (" + diff + " ms)", null, true);
return; return;
} else if (_log.shouldLog(Log.DEBUG)) { } else if (_log.shouldLog(Log.DEBUG)) {
@ -923,4 +926,15 @@ public class EstablishState {
e.printStackTrace(); e.printStackTrace();
} }
} }
/**
* Mark a string for extraction by xgettext and translation.
* Use this only in static initializers.
* It does not translate!
* @return s
*/
private static final String _x(String s) {
return s;
}
} }

View File

@ -2059,7 +2059,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
} }
} }
private static final String KEY = "<h3>Definitions:</h3><div class=\"configure\">" + private static final String KEY = "<h3>Definitions</h3><div class=\"configure\">" +
"<p><b id=\"def.peer\">Peer</b>: the remote peer.<br>\n" + "<p><b id=\"def.peer\">Peer</b>: the remote peer.<br>\n" +
"<b id=\"def.dir\">Dir</b>: v means they offer to introduce us, ^ means we offer to introduce them.<br>\n" + "<b id=\"def.dir\">Dir</b>: v means they offer to introduce us, ^ means we offer to introduce them.<br>\n" +
"<b id=\"def.idle\">Idle</b>: the idle time is how long since a packet has been received or sent.<br>\n" + "<b id=\"def.idle\">Idle</b>: the idle time is how long since a packet has been received or sent.<br>\n" +