mirror of
https://github.com/XrayR-project/XrayR.git
synced 2025-06-10 06:19:55 +00:00
update: compatible with v2board v1.7.1 route rules
This commit is contained in:
parent
be940fdcea
commit
4c699d86f2
@ -263,10 +263,22 @@ func (c *APIClient) GetNodeRule() (*[]api.DetectRule, error) {
|
|||||||
for i, rule := range nodeInfoResponse.Get("routes").MustArray() {
|
for i, rule := range nodeInfoResponse.Get("routes").MustArray() {
|
||||||
r := rule.(map[string]any)
|
r := rule.(map[string]any)
|
||||||
if r["action"] == "block" {
|
if r["action"] == "block" {
|
||||||
for ii := range r["match"].([]any) {
|
// todo remove at 2023.6.1, compatible with 1.7.1
|
||||||
|
switch r["match"].(type) {
|
||||||
|
case []any:
|
||||||
|
var s []string
|
||||||
|
for i := range r["match"].([]any) {
|
||||||
|
s = append(s, r["match"].([]any)[i].(string))
|
||||||
|
}
|
||||||
ruleList = append(ruleList, api.DetectRule{
|
ruleList = append(ruleList, api.DetectRule{
|
||||||
ID: i,
|
ID: i,
|
||||||
Pattern: regexp.MustCompile(r["match"].([]any)[ii].(string)),
|
Pattern: regexp.MustCompile(strings.Join(s, "|")),
|
||||||
|
})
|
||||||
|
case string:
|
||||||
|
s := r["match"].(string)
|
||||||
|
ruleList = append(ruleList, api.DetectRule{
|
||||||
|
ID: i,
|
||||||
|
Pattern: regexp.MustCompile(strings.ReplaceAll(s, ",", "|")),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user