mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 04:30:08 +00:00
support protocol rule
This commit is contained in:
@@ -4,18 +4,16 @@ import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
log "github.com/sirupsen/logrus"
|
||||
coreConf "github.com/xtls/xray-core/infra/conf"
|
||||
"os"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Yuzuki616/V2bX/common/crypt"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
log "github.com/sirupsen/logrus"
|
||||
coreConf "github.com/xtls/xray-core/infra/conf"
|
||||
)
|
||||
|
||||
type CommonNodeRsp struct {
|
||||
@@ -58,7 +56,7 @@ type HysteriaNodeRsp struct {
|
||||
type NodeInfo struct {
|
||||
Id int
|
||||
Type string
|
||||
Rules []*regexp.Regexp
|
||||
Rules Rules
|
||||
Host string
|
||||
Port int
|
||||
Network string
|
||||
@@ -75,6 +73,11 @@ type NodeInfo struct {
|
||||
PullInterval time.Duration
|
||||
}
|
||||
|
||||
type Rules struct {
|
||||
Regexp []string
|
||||
Protocol []string
|
||||
}
|
||||
|
||||
type V2rayExtraConfig struct {
|
||||
EnableVless string `json:"EnableVless"`
|
||||
VlessFlow string `json:"VlessFlow"`
|
||||
@@ -131,7 +134,13 @@ func (c *Client) GetNodeInfo() (node *NodeInfo, err error) {
|
||||
switch common.Routes[i].Action {
|
||||
case "block":
|
||||
for _, v := range matchs {
|
||||
node.Rules = append(node.Rules, regexp.MustCompile(v))
|
||||
if strings.HasPrefix(v, "protocol:") {
|
||||
// protocol
|
||||
node.Rules.Protocol = append(node.Rules.Protocol, strings.TrimPrefix(v, "protocol:"))
|
||||
} else {
|
||||
// domain
|
||||
node.Rules.Regexp = append(node.Rules.Regexp, strings.TrimPrefix(v, "regexp:"))
|
||||
}
|
||||
}
|
||||
case "dns":
|
||||
if matchs[0] != "main" {
|
||||
|
||||
Reference in New Issue
Block a user