diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/AccessCounter.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/AccessCounter.java index 4dddb1cf6..8056cf07f 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/AccessCounter.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/AccessCounter.java @@ -38,7 +38,7 @@ class AccessCounter { for (int i = 0; i <= accesses.size() - threshold.getConnections(); i++) { long start = accesses.get(i); - long end = start + threshold.getMinutes() * 60000; + long end = start + threshold.getSeconds() * 1000; if (accesses.get(i + threshold.getConnections() -1) <= end) return true; } diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/AccessFilter.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/AccessFilter.java index b8c3a3dfd..5958e270b 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/AccessFilter.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/AccessFilter.java @@ -156,7 +156,7 @@ class AccessFilter implements StatefulConnectionFilter { } private void purge() { - long olderThan = context.clock().now() - definition.getPurgeMinutes() * 60000; + long olderThan = context.clock().now() - definition.getPurgeSeconds() * 1000; synchronized(knownDests) { for (DestTracker tracker : knownDests.values()) { diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/DefinitionParser.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/DefinitionParser.java index d51129953..fdfb4c1a8 100644 --- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/DefinitionParser.java +++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/DefinitionParser.java @@ -43,16 +43,16 @@ class DefinitionParser { *
** A threshold is defined by the number of connection attempts a remote destination is - * permitted to perform over a specified number of minutes before a "breach" occurs. + * permitted to perform over a specified number of seconds before a "breach" occurs. * For example the following threshold definition "15/5" means that the same remote - * destination is allowed to make 14 connection attempts over a 5 minute period, If + * destination is allowed to make 14 connection attempts over a 5 second period, If * it makes one more attempt within the same period, the threshold will be breached. *
** The threshold format can be one of the following: *
*
* # by default there are no limits
@@ -176,12 +176,12 @@ class DefinitionParser {
try {
int connections = Integer.parseInt(split[0]);
- int minutes = Integer.parseInt(split[1]);
+ int seconds = Integer.parseInt(split[1]);
if (connections < 0)
throw new InvalidDefinitionException("Number of connections cannot be negative " + s);
- if (minutes < 1)
- throw new InvalidDefinitionException("Number of minutes must be at least 1 " + s);
- return new Threshold(connections, minutes);
+ if (seconds < 1)
+ throw new InvalidDefinitionException("Number of seconds must be at least 1 " + s);
+ return new Threshold(connections, seconds);
} catch (NumberFormatException bad) {
throw new InvalidDefinitionException("Invalid threshold", bad);
}
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/FilterDefinition.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/FilterDefinition.java
index 7a389ecb0..68d6336f5 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/FilterDefinition.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/FilterDefinition.java
@@ -12,7 +12,7 @@ class FilterDefinition {
private final Threshold defaultThreshold;
private final FilterDefinitionElement[] elements;
private final Recorder[] recorders;
- private final int purgeMinutes;
+ private final int purgeSeconds;
/**
* @param defaultThreshold threshold to apply to unknown remote destinations
@@ -26,13 +26,13 @@ class FilterDefinition {
this.elements = elements;
this.recorders = recorders;
- int maxMinutes = defaultThreshold.getMinutes();
+ int maxSeconds = defaultThreshold.getSeconds();
for (FilterDefinitionElement element : elements)
- maxMinutes = Math.max(maxMinutes, element.getThreshold().getMinutes());
+ maxSeconds = Math.max(maxSeconds, element.getThreshold().getSeconds());
for (Recorder recorder : recorders)
- maxMinutes = Math.max(maxMinutes, recorder.getThreshold().getMinutes());
+ maxSeconds = Math.max(maxSeconds, recorder.getThreshold().getSeconds());
- this.purgeMinutes = maxMinutes;
+ this.purgeSeconds = maxSeconds;
}
Threshold getDefaultThreshold() {
@@ -47,7 +47,7 @@ class FilterDefinition {
return recorders;
}
- int getPurgeMinutes() {
- return purgeMinutes;
+ int getPurgeSeconds() {
+ return purgeSeconds;
}
}
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/Threshold.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/Threshold.java
index f55a5f609..8b91601bf 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/Threshold.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/access/Threshold.java
@@ -3,7 +3,7 @@ package net.i2p.i2ptunnel.access;
/**
* Definition of a Threshold.
*
- * A Threshold is defined by a number of connections over a period of minutes
+ * A Threshold is defined by a number of connections over a period of seconds
*
* @since 0.9.40
*/
@@ -15,22 +15,22 @@ class Threshold {
static final Threshold DENY = new Threshold(0, 1);
private final int connections;
- private final int minutes;
+ private final int seconds;
- Threshold(int connections, int minutes) {
- if (minutes < 1)
- throw new IllegalArgumentException("Threshold must be defined over at least 1 minute");
+ Threshold(int connections, int seconds) {
+ if (seconds < 1)
+ throw new IllegalArgumentException("Threshold must be defined over at least 1 second");
if (connections < 0)
throw new IllegalArgumentException("Accesses cannot be negative");
this.connections = connections;
- this.minutes = minutes;
+ this.seconds = seconds;
}
int getConnections() {
return connections;
}
- int getMinutes() {
- return minutes;
+ int getSeconds() {
+ return seconds;
}
}