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:
@@ -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+">")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user