i2ptunnel: Reduce severity of access filter errors (Gitlab #483)

So they don't prevent the tunnel from starting
Log tweaks
This commit is contained in:
zzz
2024-06-20 11:21:42 -04:00
parent d4f580ee39
commit b573fe461f
3 changed files with 17 additions and 5 deletions

View File

@@ -234,7 +234,10 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
try {
_filter = FilterFactory.createFilter(context, filterDefinition);
} catch (IOException | InvalidDefinitionException bad) {
throw new IllegalArgumentException("Bad filter definition file: " + bad.getMessage(), bad);
String msg = "Bad filter definition file: " + filterDefinition + " - filtering disabled: " + bad.getMessage();
_log.error(msg, bad);
l.log(msg);
_filter = null;
}
}

View File

@@ -236,7 +236,7 @@ class AccessFilter implements StatefulConnectionFilter {
syncer.schedule(SYNC_INTERVAL);
} catch (IOException bad) {
Log log = context.logManager().getLog(AccessFilter.class);
log.log(Log.CRIT, "syncing access list failed", bad);
log.error("syncing access list failed", bad);
}
}
});

View File

@@ -8,7 +8,9 @@ import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import net.i2p.I2PAppContext;
import net.i2p.data.Hash;
import net.i2p.util.Log;
/**
* An element of filter definition that reads hashes of remote destinations
@@ -55,7 +57,16 @@ class FileFilterDefinitionElement extends FilterDefinitionElement {
reader = new BufferedReader(new FileReader(file));
String b32;
while((b32 = reader.readLine()) != null) {
Hash hash = fromBase32(b32);
if (b32.length() == 0)
continue;
Hash hash;
try {
hash = fromBase32(b32);
} catch (InvalidDefinitionException bad32) {
Log log = I2PAppContext.getGlobalContext().logManager().getLog(FileFilterDefinitionElement.class);
log.error("Invalid access list entry \"" + b32 + "\" in " + file, bad32);
continue;
}
if (map.containsKey(hash))
continue;
DestTracker newTracker = new DestTracker(hash, threshold);
@@ -64,8 +75,6 @@ class FileFilterDefinitionElement extends FilterDefinitionElement {
lastLoaded.put(hash, newTracker);
}
}
} catch (InvalidDefinitionException bad32) {
throw new IOException("invalid access list entry", bad32);
} finally {
if (reader != null) {
try { reader.close(); } catch (IOException ignored) {}