feat: blacklist

This commit is contained in:
xbingW
2025-04-09 19:03:30 +08:00
parent f371d588a4
commit 14fb45f648
5 changed files with 29 additions and 3 deletions

3
.gitignore vendored
View File

@@ -5,4 +5,5 @@
*.tar.gz
build.sh
compose.yml
__pycache__
__pycache__
.cursor

View File

@@ -202,6 +202,19 @@ func APIName(ctx context.Context, req *RequestType) (ResultType, error) {
return resp.Data, nil
}
```
5. **Tool Registration (init.go)**
The tool registration file `internal/tools/init.go` is used to centrally manage all tool registrations
- Register all tools uniformly in the `init()` function
- Use the `AppendTool()` method for registration
- Example:
```go
// Register create application tool
AppendTool(&app.CreateApp{})
// Register create blacklist rule tool
AppendTool(&rule.CreateBlacklistRule{})
```
### Development Standards

View File

@@ -1,5 +1,13 @@
package api
type PolicyRuleAction int
const (
PolicyRuleActionAllow PolicyRuleAction = iota
PolicyRuleActionDeny
PolicyRuleActionMax
)
type Key = string
const (

View File

@@ -1,8 +1,11 @@
package tools
import "github.com/chaitin/SafeLine/mcp_server/internal/tools/app"
import (
"github.com/chaitin/SafeLine/mcp_server/internal/tools/app"
"github.com/chaitin/SafeLine/mcp_server/internal/tools/rule"
)
func init() {
AppendTool(&CalculateSum{})
AppendTool(&app.CreateApp{})
AppendTool(&rule.CreateBlacklistRule{})
}

View File

@@ -32,6 +32,7 @@ func (t *CreateBlacklistRule) Execute(ctx context.Context, params CreateBlacklis
Name: params.Name,
IP: params.IP,
IsEnabled: true,
Action: int(api.PolicyRuleActionDeny),
Pattern: [][]api.Pattern{
{
{