feat: new action process

This commit is contained in:
Roi Feng
2025-02-13 22:20:53 -05:00
parent c7e9a69f8b
commit aea36d463b
7 changed files with 123 additions and 74 deletions

22
internal/check/IPBlock.go Normal file
View File

@ -0,0 +1,22 @@
package check
import (
"net"
"server_torii/internal/action"
"server_torii/internal/config"
"server_torii/internal/dataType"
)
func IPBlockList(reqData dataType.UserRequest, ruleSet *config.RuleSet, decision *action.Decision) {
remoteIP := reqData.RemoteIP
trie := ruleSet.IPBlockTrie
ip := net.ParseIP(remoteIP)
if ip == nil {
return
}
if trie.Search(ip) {
decision.SetCode(action.Done, "403")
} else {
decision.Set(action.Continue)
}
}