forked from I2P_Developers/i2p.i2p
banlist
This commit is contained in:
@@ -94,7 +94,7 @@ public class I2Plistener implements Runnable {
|
||||
|
||||
}
|
||||
} catch (I2PException e) {
|
||||
// bad shit
|
||||
// bad stuff
|
||||
System.out.println("Exception " + e);
|
||||
}
|
||||
} finally {
|
||||
|
@@ -58,7 +58,7 @@ public class I2PSnarkUtil {
|
||||
private volatile I2PSocketManager _manager;
|
||||
private boolean _configured;
|
||||
private volatile boolean _connecting;
|
||||
private final Set<Hash> _shitlist;
|
||||
private final Set<Hash> _banlist;
|
||||
private int _maxUploaders;
|
||||
private int _maxUpBW;
|
||||
private int _maxConnections;
|
||||
@@ -86,7 +86,7 @@ public class I2PSnarkUtil {
|
||||
_opts = new HashMap();
|
||||
//setProxy("127.0.0.1", 4444);
|
||||
setI2CPConfig("127.0.0.1", 7654, null);
|
||||
_shitlist = new ConcurrentHashSet();
|
||||
_banlist = new ConcurrentHashSet();
|
||||
_maxUploaders = Snark.MAX_TOTAL_UPLOADERS;
|
||||
_maxUpBW = DEFAULT_MAX_UP_BW;
|
||||
_maxConnections = MAX_CONNECTIONS;
|
||||
@@ -283,7 +283,7 @@ public class I2PSnarkUtil {
|
||||
I2PSocketManager mgr = _manager;
|
||||
// FIXME this can cause race NPEs elsewhere
|
||||
_manager = null;
|
||||
_shitlist.clear();
|
||||
_banlist.clear();
|
||||
if (mgr != null) {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Disconnecting from I2P", new Exception("I did it"));
|
||||
@@ -306,24 +306,24 @@ public class I2PSnarkUtil {
|
||||
if (addr.equals(getMyDestination()))
|
||||
throw new IOException("Attempt to connect to myself");
|
||||
Hash dest = addr.calculateHash();
|
||||
if (_shitlist.contains(dest))
|
||||
throw new IOException("Not trying to contact " + dest.toBase64() + ", as they are shitlisted");
|
||||
if (_banlist.contains(dest))
|
||||
throw new IOException("Not trying to contact " + dest.toBase64() + ", as they are banlisted");
|
||||
try {
|
||||
I2PSocket rv = _manager.connect(addr);
|
||||
if (rv != null)
|
||||
_shitlist.remove(dest);
|
||||
_banlist.remove(dest);
|
||||
return rv;
|
||||
} catch (I2PException ie) {
|
||||
_shitlist.add(dest);
|
||||
_context.simpleScheduler().addEvent(new Unshitlist(dest), 10*60*1000);
|
||||
_banlist.add(dest);
|
||||
_context.simpleScheduler().addEvent(new Unbanlist(dest), 10*60*1000);
|
||||
throw new IOException("Unable to reach the peer " + peer + ": " + ie.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private class Unshitlist implements SimpleTimer.TimedEvent {
|
||||
private class Unbanlist implements SimpleTimer.TimedEvent {
|
||||
private Hash _dest;
|
||||
public Unshitlist(Hash dest) { _dest = dest; }
|
||||
public void timeReached() { _shitlist.remove(_dest); }
|
||||
public Unbanlist(Hash dest) { _dest = dest; }
|
||||
public void timeReached() { _banlist.remove(_dest); }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,15 +18,15 @@ import java.util.TreeMap;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.data.Hash;
|
||||
import net.i2p.router.RouterContext;
|
||||
import net.i2p.router.Shitlist;
|
||||
import net.i2p.router.Banlist;
|
||||
|
||||
/**
|
||||
* Moved from Shitlist.java
|
||||
* Moved from Banlist.java
|
||||
*/
|
||||
public class ShitlistRenderer {
|
||||
public class BanlistRenderer {
|
||||
private final RouterContext _context;
|
||||
|
||||
public ShitlistRenderer(RouterContext context) {
|
||||
public BanlistRenderer(RouterContext context) {
|
||||
_context = context;
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ public class ShitlistRenderer {
|
||||
StringBuilder buf = new StringBuilder(1024);
|
||||
// move to the jsp
|
||||
//buf.append("<h2>Banned Peers</h2>");
|
||||
Map<Hash, Shitlist.Entry> entries = new TreeMap(new HashComparator());
|
||||
Map<Hash, Banlist.Entry> entries = new TreeMap(new HashComparator());
|
||||
|
||||
entries.putAll(_context.shitlist().getEntries());
|
||||
entries.putAll(_context.banlist().getEntries());
|
||||
if (entries.isEmpty()) {
|
||||
buf.append("<i>").append(_("none")).append("</i>");
|
||||
out.write(buf.toString());
|
||||
@@ -51,9 +51,9 @@ public class ShitlistRenderer {
|
||||
|
||||
buf.append("<ul>");
|
||||
|
||||
for (Map.Entry<Hash, Shitlist.Entry> e : entries.entrySet()) {
|
||||
for (Map.Entry<Hash, Banlist.Entry> e : entries.entrySet()) {
|
||||
Hash key = e.getKey();
|
||||
Shitlist.Entry entry = e.getValue();
|
||||
Banlist.Entry entry = e.getValue();
|
||||
long expires = entry.expireOn-_context.clock().now();
|
||||
if (expires <= 0)
|
||||
continue;
|
@@ -20,7 +20,7 @@ public class ConfigPeerHandler extends FormHandler {
|
||||
} else if (_action.equals(_("Ban peer until restart"))) {
|
||||
Hash h = getHash();
|
||||
if (h != null) {
|
||||
_context.shitlist().shitlistRouterForever(h, _("Manually banned via {0}"), "<a href=\"configpeer\">configpeer</a>");
|
||||
_context.banlist().banlistRouterForever(h, _("Manually banned via {0}"), "<a href=\"configpeer\">configpeer</a>");
|
||||
addFormNotice(_("Peer") + " " + _peer + " " + _("banned until restart") );
|
||||
return;
|
||||
}
|
||||
@@ -28,8 +28,8 @@ public class ConfigPeerHandler extends FormHandler {
|
||||
} else if (_action.equals(_("Unban peer"))) {
|
||||
Hash h = getHash();
|
||||
if (h != null) {
|
||||
if (_context.shitlist().isShitlisted(h)) {
|
||||
_context.shitlist().unshitlistRouter(h);
|
||||
if (_context.banlist().isBanlisted(h)) {
|
||||
_context.banlist().unbanlistRouter(h);
|
||||
addFormNotice(_("Peer") + " " + _peer + " " + _("unbanned") );
|
||||
} else
|
||||
addFormNotice(_("Peer") + " " + _peer + " " + _("is not currently banned") );
|
||||
|
@@ -168,7 +168,7 @@ class ProfileOrganizerRenderer {
|
||||
}
|
||||
buf.append("</td><td align=\"right\">").append(num(prof.getIntegrationValue()));
|
||||
buf.append("</td><td align=\"center\">");
|
||||
if (_context.shitlist().isShitlisted(peer)) buf.append(_("Banned"));
|
||||
if (_context.banlist().isBanlisted(peer)) buf.append(_("Banned"));
|
||||
if (prof.getIsFailing()) buf.append(' ').append(_("Failing"));
|
||||
if (_context.commSystem().wasUnreachable(peer)) buf.append(' ').append(_("Unreachable"));
|
||||
Rate failed = prof.getTunnelHistory().getFailedRate().getRate(30*60*1000);
|
||||
|
@@ -46,7 +46,7 @@ public class ProfilesHelper extends HelperBase {
|
||||
renderNavBar();
|
||||
} catch (IOException ioe) {}
|
||||
if (_full == 3)
|
||||
getShitlistSummary();
|
||||
getBanlistSummary();
|
||||
else
|
||||
getProfileSummary();
|
||||
return "";
|
||||
@@ -64,9 +64,9 @@ public class ProfilesHelper extends HelperBase {
|
||||
}
|
||||
|
||||
/** @return empty string, writes directly to _out */
|
||||
public String getShitlistSummary() {
|
||||
public String getBanlistSummary() {
|
||||
try {
|
||||
ShitlistRenderer rend = new ShitlistRenderer(_context);
|
||||
BanlistRenderer rend = new BanlistRenderer(_context);
|
||||
rend.renderStatusHTML(_out);
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
|
@@ -282,11 +282,11 @@ public class SummaryHelper extends HelperBase {
|
||||
*
|
||||
*/
|
||||
/********
|
||||
public int getShitlistedPeers() {
|
||||
public int getBanlistedPeers() {
|
||||
if (_context == null)
|
||||
return 0;
|
||||
else
|
||||
return _context.shitlist().getRouterCount();
|
||||
return _context.banlist().getRouterCount();
|
||||
}
|
||||
********/
|
||||
|
||||
|
@@ -207,7 +207,7 @@
|
||||
<p>
|
||||
This setting causes your router identity to be regenerated every time your IP address
|
||||
changes. If you have a dynamic IP this option can speed up your reintegration into
|
||||
the network (since people will have shitlisted your old router identity), and, for
|
||||
the network (since people will have banned your old router identity), and, for
|
||||
very weak adversaries, help frustrate trivial
|
||||
<a href="http://www.i2p.net/how_threatmodel#intersection">intersection
|
||||
attacks</a> against the NetDB. Your different router identities would only be
|
||||
|
@@ -61,11 +61,11 @@
|
||||
<input type="text" size="8" name="capacity" value="<%=capacity%>" />
|
||||
<input type="submit" name="action" class="add" value="<%=intl._("Adjust peer bonuses")%>" /></p></div>
|
||||
</form>
|
||||
<a name="shitlist"> </a><h2><%=intl._("Banned Peers")%></h2>
|
||||
<a name="banlist"> </a><h2><%=intl._("Banned Peers")%></h2>
|
||||
<jsp:useBean class="net.i2p.router.web.ProfilesHelper" id="profilesHelper" scope="request" />
|
||||
<jsp:setProperty name="profilesHelper" property="contextId" value="<%=(String)session.getAttribute(\"i2p.contextId\")%>" />
|
||||
<% profilesHelper.storeWriter(out); %>
|
||||
<jsp:getProperty name="profilesHelper" property="shitlistSummary" />
|
||||
<jsp:getProperty name="profilesHelper" property="banlistSummary" />
|
||||
<div class="wideload"><h2><%=intl._("Banned IPs")%></h2>
|
||||
<jsp:getProperty name="peerhelper" property="blocklistSummary" />
|
||||
|
||||
|
@@ -974,7 +974,7 @@ class Connection {
|
||||
switch (_options.getInactivityAction()) {
|
||||
case ConnectionOptions.INACTIVITY_ACTION_NOOP:
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("Inactivity timer expired, but we aint doin' shit");
|
||||
_log.warn("Inactivity timer expired, not doing anything");
|
||||
break;
|
||||
case ConnectionOptions.INACTIVITY_ACTION_SEND:
|
||||
if (_closeSentOn <= 0 && _closeReceivedOn <= 0) {
|
||||
|
Reference in New Issue
Block a user