Files
SamWaf/model/sharedb.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

35 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
import (
"SamWaf/customtype"
"SamWaf/model/baseorm"
"strings"
)
/*
*
分库
*/
type ShareDb struct {
baseorm.BaseOrm
DbLogicType string `gorm:"size:50" json:"db_logic_type"` //数据库逻辑类型 默认:"log"
StartTime customtype.JsonTime `json:"start_time"` //开始时间
EndTime customtype.JsonTime `json:"end_time"` //结束时间
FileName string `gorm:"size:255" json:"file_name"` //文件名:SQLite 下为 .db 文件名;MySQL 下为表名(无后缀)
Cnt int64 `json:"cnt"` //当前数量
PeriodKey string `gorm:"size:16" json:"period_key"` //周期键(月,如 202609)。按体积切出来的旧分片为空
}
// IsPeriodShard 返回 true 表示这是按时间周期切出来的分区(M3),
// false 表示按行数/体积切出来的旧分片——两者的时间范围都记在 StartTime/EndTime 里,
// 区别只在「名字能不能算出周期」以及界面上怎么标。
func (s ShareDb) IsPeriodShard() bool {
return s.PeriodKey != ""
}
// IsTableShard 在 MySQL/SQL Server 模式下返回 true(FileName 存的是表名而非文件名)
func (s ShareDb) IsTableShard() bool {
suffix := ".db"
return !strings.HasSuffix(s.FileName, suffix)
}