mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-01-22 09:58:14 -05:00
fix get node info and node rule error
This commit is contained in:
parent
9b78155786
commit
b607b8eb4a
@ -78,7 +78,7 @@ func New(apiConfig *Config) API {
|
||||
})
|
||||
// Read local rule list
|
||||
localRuleList := readLocalRuleList(apiConfig.RuleListPath)
|
||||
apiClient := &Client{
|
||||
return &Client{
|
||||
client: client,
|
||||
NodeID: apiConfig.NodeID,
|
||||
Key: apiConfig.Key,
|
||||
@ -91,5 +91,4 @@ func New(apiConfig *Config) API {
|
||||
DeviceLimit: apiConfig.DeviceLimit,
|
||||
LocalRuleList: localRuleList,
|
||||
}
|
||||
return apiClient
|
||||
}
|
||||
|
37
api/node.go
37
api/node.go
@ -124,25 +124,34 @@ func (c *Client) GetNodeInfo() (nodeInfo *NodeInfo, err error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
i := bytes.Index(res.Body(), []byte("outbo"))
|
||||
md := md52.Sum(res.Body()[:i])
|
||||
nodeIsNotChange := false
|
||||
if c.NodeInfoRspMd5 != [16]byte{} {
|
||||
if c.NodeInfoRspMd5 == md {
|
||||
nodeIsNotChange = true
|
||||
}
|
||||
}
|
||||
c.NodeInfoRspMd5 = md
|
||||
c.access.Lock()
|
||||
defer c.access.Unlock()
|
||||
switch c.NodeType {
|
||||
case "V2ray":
|
||||
md2 := md52.Sum(res.Body()[i:])
|
||||
nodeInfo, err = c.ParseV2rayNodeResponse(res.Body(), nodeIsNotChange, c.NodeRuleRspMd5 != md2)
|
||||
case "Trojan":
|
||||
if nodeIsNotChange {
|
||||
return nil, nil
|
||||
i := bytes.Index(res.Body(), []byte("outbo"))
|
||||
md := md52.Sum(res.Body()[:i])
|
||||
nodeIsNotChange := true
|
||||
if c.NodeInfoRspMd5 != [16]byte{} {
|
||||
if c.NodeInfoRspMd5 != md {
|
||||
nodeIsNotChange = false
|
||||
c.NodeInfoRspMd5 = md
|
||||
}
|
||||
}
|
||||
md2 := md52.Sum(res.Body()[i:])
|
||||
ruleIsChange := false
|
||||
if c.NodeRuleRspMd5 != md2 {
|
||||
ruleIsChange = true
|
||||
c.NodeRuleRspMd5 = md2
|
||||
}
|
||||
nodeInfo, err = c.ParseV2rayNodeResponse(res.Body(), nodeIsNotChange, ruleIsChange)
|
||||
case "Trojan":
|
||||
md := md52.Sum(res.Body())
|
||||
if c.NodeInfoRspMd5 != [16]byte{} {
|
||||
if c.NodeInfoRspMd5 == md {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
c.NodeInfoRspMd5 = md
|
||||
nodeInfo, err = c.ParseTrojanNodeResponse(res.Body())
|
||||
}
|
||||
return nodeInfo, nil
|
||||
|
@ -125,8 +125,8 @@ func (l *Limiter) GetUserBucket(tag string, email string, ip string) (limiter *r
|
||||
inboundInfo := value.(*InboundInfo)
|
||||
nodeLimit := inboundInfo.NodeSpeedLimit
|
||||
var userLimit uint64 = 0
|
||||
var deviceLimit int = 0
|
||||
var uid int = 0
|
||||
var deviceLimit = 0
|
||||
var uid = 0
|
||||
if v, ok := inboundInfo.UserInfo.Load(email); ok {
|
||||
u := v.(UserInfo)
|
||||
uid = u.UID
|
||||
|
Loading…
Reference in New Issue
Block a user