mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 04:30:08 +00:00
remove local rule, update xray-core to 1.8.4
This commit is contained in:
@@ -65,8 +65,8 @@ type VAllssNode struct {
|
||||
ServerName string `json:"server_name"`
|
||||
|
||||
// vless only
|
||||
Flow string `json:"flow"`
|
||||
RealityConfig RealityConfig
|
||||
Flow string `json:"flow"`
|
||||
RealityConfig RealityConfig `json:"-"`
|
||||
}
|
||||
|
||||
type TlsSettings struct {
|
||||
@@ -77,7 +77,6 @@ type TlsSettings struct {
|
||||
}
|
||||
|
||||
type RealityConfig struct {
|
||||
Dest string `json:"Dest"`
|
||||
Xver uint64 `json:"Xver"`
|
||||
MinClientVer string `json:"MinClientVer"`
|
||||
MaxClientVer string `json:"MaxClientVer"`
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
package panel
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/InazumaV/V2bX/conf"
|
||||
"github.com/go-resty/resty/v2"
|
||||
)
|
||||
@@ -17,14 +16,13 @@ import (
|
||||
// Panel is the interface for different panel's api.
|
||||
|
||||
type Client struct {
|
||||
client *resty.Client
|
||||
APIHost string
|
||||
Token string
|
||||
NodeType string
|
||||
NodeId int
|
||||
LocalRuleList []*regexp.Regexp
|
||||
nodeEtag string
|
||||
userEtag string
|
||||
client *resty.Client
|
||||
APIHost string
|
||||
Token string
|
||||
NodeType string
|
||||
NodeId int
|
||||
nodeEtag string
|
||||
userEtag string
|
||||
}
|
||||
|
||||
func New(c *conf.ApiConfig) (*Client, error) {
|
||||
@@ -36,10 +34,11 @@ func New(c *conf.ApiConfig) (*Client, error) {
|
||||
client.SetTimeout(5 * time.Second)
|
||||
}
|
||||
client.OnError(func(req *resty.Request, err error) {
|
||||
if v, ok := err.(*resty.ResponseError); ok {
|
||||
var v *resty.ResponseError
|
||||
if errors.As(err, &v) {
|
||||
// v.Response contains the last response from the server
|
||||
// v.Err contains the original error
|
||||
log.Print(v.Err)
|
||||
logrus.Error(v.Err)
|
||||
}
|
||||
})
|
||||
client.SetBaseURL(c.APIHost)
|
||||
@@ -63,39 +62,11 @@ func New(c *conf.ApiConfig) (*Client, error) {
|
||||
"node_id": strconv.Itoa(c.NodeID),
|
||||
"token": c.Key,
|
||||
})
|
||||
// Read local rule list
|
||||
localRuleList := readLocalRuleList(c.RuleListPath)
|
||||
return &Client{
|
||||
client: client,
|
||||
Token: c.Key,
|
||||
APIHost: c.APIHost,
|
||||
NodeType: c.NodeType,
|
||||
NodeId: c.NodeID,
|
||||
LocalRuleList: localRuleList,
|
||||
client: client,
|
||||
Token: c.Key,
|
||||
APIHost: c.APIHost,
|
||||
NodeType: c.NodeType,
|
||||
NodeId: c.NodeID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// readLocalRuleList reads the local rule list file
|
||||
func readLocalRuleList(path string) (LocalRuleList []*regexp.Regexp) {
|
||||
LocalRuleList = make([]*regexp.Regexp, 0)
|
||||
if path != "" {
|
||||
// open the file
|
||||
file, err := os.Open(path)
|
||||
//handle errors while opening
|
||||
if err != nil {
|
||||
log.Printf("Error when opening file: %s", err)
|
||||
return
|
||||
}
|
||||
fileScanner := bufio.NewScanner(file)
|
||||
// read line by line
|
||||
for fileScanner.Scan() {
|
||||
LocalRuleList = append(LocalRuleList, regexp.MustCompile(fileScanner.Text()))
|
||||
}
|
||||
// handle first encountered error while reading
|
||||
if err := fileScanner.Err(); err != nil {
|
||||
log.Fatalf("Error while reading file: %s", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user