feat(watchdog): add exception handling and webhook integration

- Implement exception handling in TCP client to process error messages
- Add webhook functionality to send notifications for exceptions
- Introduce utility functions for string parsing
- Update config with webhook template
This commit is contained in:
2026-04-28 15:46:31 +08:00
parent ac51641e93
commit 0890c8136f
4 changed files with 116 additions and 3 deletions
+33
View File
@@ -6,6 +6,7 @@ import (
"net/http"
"strconv"
"time"
"strings"
"super-frpc/database"
"super-frpc/global"
@@ -128,3 +129,35 @@ func LogRequest(r *http.Request, userID int) {
func IntToString(i int) string {
return strconv.Itoa(i)
}
func GetTextMiddle(text, left, right string) string {
start := 0
if left != "" {
idx := strings.Index(text, left)
if idx == -1 {
return ""
}
start = idx + len(left)
}
if right == "" {
if start > len(text) {
return ""
}
return text[start:]
}
endIdx := strings.Index(text[start:], right)
if endIdx == -1 {
return ""
}
return text[start : start+endIdx]
}
func GetCmdType(source string) string {
return GetTextMiddle(source, "[", "]")
}
func GetCmdParams(source string, param string) string {
return GetTextMiddle(source, "<"+param+">", "</"+param+">")
}