public class BanLogger extends Object
This allows analysis of ban patterns without parsing router.log.
| Constructor and Description |
|---|
BanLogger()No-arg constructor for deferred initialization. |
BanLogger(RouterContext context)Constructor with context for immediate initialization. |
| Modifier and Type | Method and Description |
|---|---|
void | archiveIfNeeded()Archive the current log when closing. |
void | close()Close the log writer and archive if there are entries. |
void | flush()Flush the log writer. |
static BanLogger | getInstance()Get the singleton instance of BanLogger. |
File | getLogFile()Get the log file path. |
void | initialize(RouterContext context)Initialize the logger. |
static boolean | isInitialized()Check if the logger is initialized. |
void | logBan(Hash hash,
RouterContext context,
String reason,
long durationMs)Log a ban by hash with RouterContext (IP will be looked up from banlist). |
void | logBan(Hash hash,
String ip,
String reason,
long durationMs)Log a ban by hash with IP address. |
void | logBan(Hash hash,
String ip,
String reason,
long durationMs,
RouterInfo ri)Log a ban with RouterInfo for direct caps extraction. |
void | logBan(String ip,
String reason,
long durationMs)Log a ban by IP only (ignores hash). |
void | logBanForever(Hash hash,
RouterContext context,
String reason)Log a permanent ban with RouterContext. |
void | logBanForever(Hash hash,
String ip,
String reason)Log a permanent ban (forever). |
void | logBanForever(Hash hash,
String ip,
String reason,
RouterInfo ri)Log a permanent ban with RouterInfo for direct caps extraction. |
void | logBanForever(String ip,
String reason)Log a permanent ban by IP only. |
void | logBanIPOnly(String ip,
String reason,
long durationMs)Log a ban by IP only (no router hash available). |
static void | shutdown()Shutdown the ban logger — close the writer and release resources. |
public BanLogger()
public BanLogger(RouterContext context)
context - the router contextpublic void archiveIfNeeded()
public void close()
public void flush()
public static BanLogger getInstance()
public File getLogFile()
public void initialize(RouterContext context)
context - the router contextpublic static boolean isInitialized()
public void logBan(Hash hash, RouterContext context, String reason, long durationMs)
hash - Router hash (may be null)context - Router context for IP lookupreason - Reason for the bandurationMs - Ban duration in milliseconds, or 0 for permanentpublic void logBan(Hash hash, String ip, String reason, long durationMs)
hash - Router hash (may be null)ip - IP address with port (format: "1.2.3.4:5678" or "ipv6:port")reason - Reason for the bandurationMs - Ban duration in milliseconds, or 0 for permanentpublic void logBan(Hash hash, String ip, String reason, long durationMs, RouterInfo ri)
hash - Router hash (may be null)ip - IP address with port (format: "1.2.3.4:5678" or "ipv6:port")reason - Reason for the bandurationMs - Ban duration in milliseconds, or 0 for permanentri - RouterInfo to extract capabilities from (may be null)public void logBan(String ip, String reason, long durationMs)
ip - IP address with port (format: "1.2.3.4:5678" or "ipv6:port")reason - Reason for the bandurationMs - Ban duration in milliseconds, or 0 for permanentpublic void logBanForever(Hash hash, RouterContext context, String reason)
hash - Router hash (may be null)context - Router context for IP lookupreason - Reason for the banpublic void logBanForever(Hash hash, String ip, String reason)
hash - Router hash (may be null)ip - IP address with port (format: "1.2.3.4:5678" or "ipv6:port")reason - Reason for the banpublic void logBanForever(Hash hash, String ip, String reason, RouterInfo ri)
hash - Router hash (may be null)ip - IP address with port (format: "1.2.3.4:5678" or "ipv6:port")reason - Reason for the banri - RouterInfo to extract capabilities from (may be null)public void logBanForever(String ip, String reason)
ip - IP address with port (format: "1.2.3.4:5678" or "ipv6:port")reason - Reason for the banpublic void logBanIPOnly(String ip, String reason, long durationMs)
ip - IP address with port (format: "1.2.3.4:5678" or "ipv6:port")reason - Reason for the bandurationMs - Ban duration in milliseconds, or 0 for permanentpublic static void shutdown()