mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-09 03:50:27 +08:00
使用utils.CutPrefix代替strings.CutPrefix
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
|
"github.com/TeaOSLab/EdgeNode/internal/remotelogs"
|
||||||
"github.com/TeaOSLab/EdgeNode/internal/rpc"
|
"github.com/TeaOSLab/EdgeNode/internal/rpc"
|
||||||
"github.com/TeaOSLab/EdgeNode/internal/trackers"
|
"github.com/TeaOSLab/EdgeNode/internal/trackers"
|
||||||
|
"github.com/TeaOSLab/EdgeNode/internal/utils"
|
||||||
"github.com/TeaOSLab/EdgeNode/internal/waf"
|
"github.com/TeaOSLab/EdgeNode/internal/waf"
|
||||||
"github.com/iwind/TeaGo/Tea"
|
"github.com/iwind/TeaGo/Tea"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
@@ -298,7 +299,7 @@ func (this *Node) execUpdatingServersTask(rpcClient *rpc.RPCClient) error {
|
|||||||
|
|
||||||
// 删除IP名单
|
// 删除IP名单
|
||||||
func (this *Node) execDeleteIPList(taskType string) error {
|
func (this *Node) execDeleteIPList(taskType string) error {
|
||||||
optionsString, ok := strings.CutPrefix(taskType, "ipListDeleted@")
|
optionsString, ok := utils.CutPrefix(taskType, "ipListDeleted@")
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("invalid task type '" + taskType + "'")
|
return errors.New("invalid task type '" + taskType + "'")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,3 +56,16 @@ func EqualStrings(s1 []string, s2 []string) bool {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CutPrefix returns s without the provided leading prefix string
|
||||||
|
// and reports whether it found the prefix.
|
||||||
|
// If s doesn't start with prefix, CutPrefix returns s, false.
|
||||||
|
// If prefix is the empty string, CutPrefix returns s, true.
|
||||||
|
//
|
||||||
|
// copy from go source
|
||||||
|
func CutPrefix(s, prefix string) (after string, found bool) {
|
||||||
|
if !strings.HasPrefix(s, prefix) {
|
||||||
|
return s, false
|
||||||
|
}
|
||||||
|
return s[len(prefix):], true
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user