mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-02-02 06:48:14 -05:00
support v2board 1.7.2 rules
This commit is contained in:
parent
97779326d6
commit
0beba17baa
@ -4,6 +4,7 @@ import (
|
||||
"github.com/goccy/go-json"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type NodeInfo struct {
|
||||
@ -21,9 +22,9 @@ type NodeInfo struct {
|
||||
localNodeConfig `json:"-"`
|
||||
}
|
||||
type Route struct {
|
||||
Id int `json:"id"`
|
||||
Match string `json:"match"`
|
||||
Action string `json:"action"`
|
||||
Id int `json:"id"`
|
||||
Match interface{} `json:"match"`
|
||||
Action string `json:"action"`
|
||||
//ActionValue interface{} `json:"action_value"`
|
||||
}
|
||||
type BaseConfig struct {
|
||||
@ -61,10 +62,18 @@ func (c *Client) GetNodeInfo() (nodeInfo *NodeInfo, err error) {
|
||||
nodeInfo.NodeType = c.NodeType
|
||||
for i := range nodeInfo.Routes { // parse rules from routes
|
||||
if nodeInfo.Routes[i].Action == "block" {
|
||||
nodeInfo.Rules = append(nodeInfo.Rules, DestinationRule{
|
||||
ID: nodeInfo.Routes[i].Id,
|
||||
Pattern: regexp.MustCompile(nodeInfo.Routes[i].Match),
|
||||
})
|
||||
var matchs []string
|
||||
if _, ok := nodeInfo.Routes[i].Match.(string); ok {
|
||||
matchs = strings.Split(nodeInfo.Routes[i].Match.(string), ",")
|
||||
} else {
|
||||
matchs = nodeInfo.Routes[i].Match.([]string)
|
||||
}
|
||||
for _, v := range matchs {
|
||||
nodeInfo.Rules = append(nodeInfo.Rules, DestinationRule{
|
||||
ID: nodeInfo.Routes[i].Id,
|
||||
Pattern: regexp.MustCompile(v),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
nodeInfo.Routes = nil
|
||||
|
Loading…
Reference in New Issue
Block a user