feat(acl): add reason field to ACL logging for decision tracking

Add a reason parameter throughout the ACL system to track and log why
each IP was allowed or denied. This provides better visibility into
ACL decisions by recording specific reasons such as "allowed by
allow_local rule", "blocked by deny rule: [rule]", or "deny by default".

Changes include:
- Add reason field to checkCache and ipLog structs
- Update LogACL interface and implementations to accept reason
- Generate descriptive reasons for all ACL decision paths
- Include reason in console log output
This commit is contained in:
yusing
2026-02-15 17:20:54 +08:00
parent 0acedb034a
commit 898002a38e
7 changed files with 40 additions and 28 deletions

View File

@@ -116,7 +116,7 @@ func TestMultiAccessLoggerLogACL(t *testing.T) {
Str: "192.168.1.1",
}
logger.LogACL(info, false)
logger.LogACL(info, false, "test reason")
logger.Flush()
expect.Equal(t, writer1.NumLines(), 1)
@@ -252,7 +252,7 @@ func TestMultiAccessLoggerMixedOperations(t *testing.T) {
cfg2 := DefaultACLLoggerConfig()
cfg2.LogAllowed = true
aclLogger := NewMultiAccessLogger(testTask, cfg2, writers)
aclLogger.LogACL(info, false)
aclLogger.LogACL(info, false, "test reason")
logger.Flush()