mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 12:40:11 +00:00
fix block routes
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/goccy/go-json"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type NodeInfo struct {
|
||||
@@ -60,12 +61,13 @@ func (c *Client) GetNodeInfo() (nodeInfo *NodeInfo, err error) {
|
||||
nodeInfo.NodeId = c.NodeId
|
||||
nodeInfo.NodeType = c.NodeType
|
||||
for i := range nodeInfo.Routes { // parse rules from routes
|
||||
r := &nodeInfo.Routes[i]
|
||||
if r.Action == "block" {
|
||||
nodeInfo.Rules = append(nodeInfo.Rules, DestinationRule{
|
||||
ID: r.Id,
|
||||
Pattern: regexp.MustCompile(r.Match),
|
||||
})
|
||||
if nodeInfo.Routes[i].Action == "block" {
|
||||
for _, v := range strings.Split(nodeInfo.Routes[i].Match, ",") {
|
||||
nodeInfo.Rules = append(nodeInfo.Rules, DestinationRule{
|
||||
ID: nodeInfo.Routes[i].Id,
|
||||
Pattern: regexp.MustCompile(v),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
nodeInfo.Routes = nil
|
||||
|
||||
Reference in New Issue
Block a user