mirror of
https://github.com/XrayR-project/XrayR.git
synced 2025-06-08 13:29:54 +00:00
update: Add support NewV2board api block rules
This commit is contained in:
parent
e774d5c822
commit
676365b13b
@ -248,20 +248,18 @@ func (c *APIClient) ReportUserTraffic(userTraffic *[]api.UserTraffic) error {
|
|||||||
// GetNodeRule implements the API interface
|
// GetNodeRule implements the API interface
|
||||||
func (c *APIClient) GetNodeRule() (*[]api.DetectRule, error) {
|
func (c *APIClient) GetNodeRule() (*[]api.DetectRule, error) {
|
||||||
ruleList := c.LocalRuleList
|
ruleList := c.LocalRuleList
|
||||||
if c.NodeType != "V2ray" {
|
|
||||||
return &ruleList, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// V2board only support the rule for v2ray
|
nodeInfoResponse := c.resp.Load().(*simplejson.Json)
|
||||||
nodeInfoResponse := c.resp.Load().(*simplejson.Json) // todo waiting v2board send configuration
|
for i, rule := range nodeInfoResponse.Get("routes").MustArray() {
|
||||||
for i, rule := range nodeInfoResponse.Get("rules").MustStringArray() {
|
r := rule.(map[string]any)
|
||||||
rule = strings.TrimPrefix(rule, "regexp:")
|
if r["action"] == "block" {
|
||||||
ruleListItem := api.DetectRule{
|
ruleListItem := api.DetectRule{
|
||||||
ID: i,
|
ID: i,
|
||||||
Pattern: regexp.MustCompile(rule),
|
Pattern: regexp.MustCompile(r["match"].(string)),
|
||||||
}
|
}
|
||||||
ruleList = append(ruleList, ruleListItem)
|
ruleList = append(ruleList, ruleListItem)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &ruleList, nil
|
return &ruleList, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user