mirror of
https://github.com/chaitin/SafeLine.git
synced 2026-01-31 13:53:33 +08:00
feat: blacklist
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -5,4 +5,5 @@
|
||||
*.tar.gz
|
||||
build.sh
|
||||
compose.yml
|
||||
__pycache__
|
||||
__pycache__
|
||||
.cursor
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
package api
|
||||
|
||||
type PolicyRuleAction int
|
||||
|
||||
const (
|
||||
PolicyRuleActionAllow PolicyRuleAction = iota
|
||||
PolicyRuleActionDeny
|
||||
PolicyRuleActionMax
|
||||
)
|
||||
|
||||
type Key = string
|
||||
|
||||
const (
|
||||
|
||||
@@ -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{})
|
||||
}
|
||||
|
||||
@@ -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{
|
||||
{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user