This commit is contained in:
@@ -1 +1,9 @@
|
|||||||
package actions
|
package actions
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/d3m0k1d/BanForge/internal/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func SendEmail(action config.Action) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,19 @@
|
|||||||
package actions
|
package actions
|
||||||
|
|
||||||
type Action struct {
|
import "github.com/d3m0k1d/BanForge/internal/config"
|
||||||
Name string
|
|
||||||
Type string
|
type Executor struct {
|
||||||
Args []string
|
Action config.Action
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Executor) Execute() error {
|
||||||
|
switch e.Action.Type {
|
||||||
|
case "email":
|
||||||
|
return SendEmail(e.Action)
|
||||||
|
case "webhook":
|
||||||
|
return SendWebhook(e.Action)
|
||||||
|
case "script":
|
||||||
|
return RunScript(e.Action)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1,9 @@
|
|||||||
package actions
|
package actions
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/d3m0k1d/BanForge/internal/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RunScript(action config.Action) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,24 +1,9 @@
|
|||||||
package actions
|
package actions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"github.com/d3m0k1d/BanForge/internal/config"
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func SendWebhook(url string, data []byte) (int, error) {
|
func SendWebhook(action config.Action) error {
|
||||||
client := &http.Client{
|
return nil
|
||||||
Timeout: 30 * time.Second,
|
|
||||||
}
|
|
||||||
req, err := http.NewRequest("POST", url, bytes.NewReader(data))
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
|
||||||
// #nosec G704 validating by admin
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
return resp.StatusCode, nil
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user