Files
SamWaf/wafqueue/message_queue_ws_test.go
T
samwafgo 64aaab16fa Feat log shared (#1007)
* fix: make archived log shard connections concurrency-safe and recoverable

* fix: build the WebSocket online table before its consumers start

* perf: cap stored payloads, index log lookups by IP and rule, batch IP tag writes

* fix: keep archived log shards readable when the live table gains a column

* feat: merge IP tag history when their database location changes

* refactor: move request payloads out of the access log into their own table

* feat: scope log database export to a time range and selected tiers

* feat: add an IP watchlist that full-captures watched IPs

* feat: split log storage into security events, access rows, and payload tiers

* feat: roll up requests per actor and path into daily analysis tables

* fix:actor key by ip

* feat: add a source and path analysis page over the daily rollups

* feat: exclude chosen source IPs from web log recording

* docs: add upgrade notes for the analysis page and log IP exclusion

* feat: derive the log partition from the time range and look up identifiers across all of them

* feat: add time partition verbs and the period naming they share

* feat: cut log archives per month and expire them by dropping partitions

* feat: manage log partitions, and answer why an IP has no logs

* fix: read archived SQLite log shards read-only and choose tiers by data

* fix: count the live log shard from access_log instead of a stale snapshot

* fix:export db bug

* fix: default backend keep-alive pool (512/128/90s) to stop connect-close churn under load

* chore: gen_swagger.bat outputs json only, syncs doc site, runs route test

* feat: pin web frontend version and embed it into the binary
2026-10-10 14:39:06 +08:00

23 lines
633 B
Go

package wafqueue
import (
"SamWaf/global"
"testing"
)
// 在线表未就绪时发通知不能 panic。
// 曾经的现象:消息消费协程早于 global.GWebSocket 赋值启动,启动期广播一次就对 nil 调方法,
// 协程崩溃后被 NeverExit 拉起,日志里留一段 nil pointer dereference 堆栈。
func TestSendToWebSocket_NilOnlineTable(t *testing.T) {
saved := global.GWebSocket
global.GWebSocket = nil
defer func() {
global.GWebSocket = saved
if r := recover(); r != nil {
t.Fatalf("在线表为 nil 时不应 panic: %v", r)
}
}()
sendToWebSocket("测试通知", "内容", nil, "Test")
}