文件 v1.0.0

Redis Key

本頁列出 go-ip-sentry 寫入 Redis 的所有 key、型別、TTL 與寫入時機,方便排查與手動清除。

所有 key 都沒有前綴,建議使用獨立 DB 編號(Redis.DB)。{sid} 為 Session ID(不含簽章),{fp} 為裝置指紋,{minute} 為 Unix 分鐘。

名單

Key 型別 TTL 寫入
allow:{ip} string(IPItem JSON) 無 Allow.Add、啟動載入
deny:{ip} string(IPItem JSON) 無 Deny.Add、啟動載入
block:{ip} string(IPItem JSON) 封鎖時長 Block.Add
block:count:{ip} counter 1 小時(首次) 封鎖期間每個請求

計數與關聯

Key 型別 TTL 寫入
frequency:{ip}:{minute} counter 2 分鐘 每次 Check/LoginFailure/NotFound404
session:ip:{sid} set 1 小時(每次刷新) 評分
ip:device:{ip} set 1 小時(每次刷新) 評分
device:fp:{fp} set 1 小時(每次刷新) 評分
fp:session:{minute}:{fp} set 1 分鐘 評分
login:failure:{sid} counter 1 小時(首次) LoginFailure
notfound:404:{sid} counter 1 小時(首次) NotFound404

行為

Key 型別 TTL 寫入
interval:last:{sid} string(毫秒) 1 小時 評分
interval:{sid} list(最多 10 筆) 1 小時 評分
session:start:{sid} string(毫秒) 15 分鐘(每次刷新) 評分

地理

Key 型別 TTL 寫入
geo:ip:{ip} string(Location JSON) 24 小時 GeoLite2 查詢
geo:locations:{sid} list(最多 10 筆) 24 小時 評分(啟用 GeoLite2 時)

常用操作

redis-cli -n 2 DEL block:192.0.2.33
redis-cli -n 2 DEL allow:203.0.113.10
redis-cli -n 2 GET block:192.0.2.33
redis-cli -n 2 SCARD ip:device:203.0.113.5

刪除 allow:/deny: key 後還需移除名單檔中的項目並重啟,見 Allow 與 Deny 名單。

EN