Skip to content

Commit

Permalink
treat negative expireInterval values as 0-or-disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
idk committed Jun 16, 2023
1 parent 5c3a650 commit 9982e3d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions router/java/src/net/i2p/router/Blocklist.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,25 @@ private Blocklist() {
private int expireInterval(){
String expireIntervalValue = _context.getProperty(PROP_BLOCKLIST_EXPIRE_INTERVAL, "0");
try{
Integer expireIntervalInt = 0;
if (expireIntervalValue.endsWith("s")) {
expireIntervalValue = expireIntervalValue.substring(0, expireIntervalValue.length() - 1);
return Integer.parseInt(expireIntervalValue) * 1000;
expireIntervalInt = Integer.parseInt(expireIntervalValue) * 1000;
}else if(expireIntervalValue.endsWith("m")){
expireIntervalValue = expireIntervalValue.substring(0, expireIntervalValue.length() - 1);
return Integer.parseInt(expireIntervalValue) * 60000;
expireIntervalInt = Integer.parseInt(expireIntervalValue) * 60000;
}else if(expireIntervalValue.endsWith("h")){
expireIntervalValue = expireIntervalValue.substring(0, expireIntervalValue.length() - 1);
return Integer.parseInt(expireIntervalValue) * 3600000;
expireIntervalInt = Integer.parseInt(expireIntervalValue) * 3600000;
}else if (expireIntervalValue.endsWith("d")) {
expireIntervalValue = expireIntervalValue.substring(0, expireIntervalValue.length() - 1);
return Integer.parseInt(expireIntervalValue) * 86400000;
expireIntervalInt = Integer.parseInt(expireIntervalValue) * 86400000;
}else{
return Integer.parseInt(expireIntervalValue);
expireIntervalInt = Integer.parseInt(expireIntervalValue);
}
if (expireIntervalInt < 0)
expireIntervalInt = 0;
return expireIntervalInt;
}catch(NumberFormatException nfe){
if (_log.shouldLog(_log.ERROR))
_log.error("format error in "+PROP_BLOCKLIST_EXPIRE_INTERVAL, nfe);
Expand Down

0 comments on commit 9982e3d

Please sign in to comment.