mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-02-08 17:18:13 -05:00
fix get node info,fix trojan builder
This commit is contained in:
parent
21bd807e99
commit
5c7356a8da
16
api/node.go
16
api/node.go
@ -63,7 +63,7 @@ type NodeInfo struct {
|
|||||||
TLSType string
|
TLSType string
|
||||||
EnableVless bool
|
EnableVless bool
|
||||||
EnableTls bool
|
EnableTls bool
|
||||||
EnableSS2022 bool
|
//EnableSS2022 bool
|
||||||
V2ray *V2rayConfig
|
V2ray *V2rayConfig
|
||||||
Trojan *TrojanConfig
|
Trojan *TrojanConfig
|
||||||
SS *SSConfig
|
SS *SSConfig
|
||||||
@ -130,10 +130,13 @@ func (c *Client) GetNodeInfo() (nodeInfo *NodeInfo, err error) {
|
|||||||
case "V2ray":
|
case "V2ray":
|
||||||
i := bytes.Index(res.Body(), []byte("outbo"))
|
i := bytes.Index(res.Body(), []byte("outbo"))
|
||||||
md := md52.Sum(res.Body()[:i])
|
md := md52.Sum(res.Body()[:i])
|
||||||
nodeIsNotChange := true
|
nodeNotIsChange := true
|
||||||
if c.NodeInfoRspMd5 != [16]byte{} {
|
if c.NodeInfoRspMd5 == [16]byte{} {
|
||||||
|
nodeNotIsChange = false
|
||||||
|
c.NodeInfoRspMd5 = md
|
||||||
|
} else {
|
||||||
if c.NodeInfoRspMd5 != md {
|
if c.NodeInfoRspMd5 != md {
|
||||||
nodeIsNotChange = false
|
nodeNotIsChange = false
|
||||||
c.NodeInfoRspMd5 = md
|
c.NodeInfoRspMd5 = md
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,7 +146,7 @@ func (c *Client) GetNodeInfo() (nodeInfo *NodeInfo, err error) {
|
|||||||
ruleIsChange = true
|
ruleIsChange = true
|
||||||
c.NodeRuleRspMd5 = md2
|
c.NodeRuleRspMd5 = md2
|
||||||
}
|
}
|
||||||
nodeInfo, err = c.ParseV2rayNodeResponse(res.Body(), nodeIsNotChange, ruleIsChange)
|
nodeInfo, err = c.ParseV2rayNodeResponse(res.Body(), nodeNotIsChange, ruleIsChange)
|
||||||
case "Trojan":
|
case "Trojan":
|
||||||
md := md52.Sum(res.Body())
|
md := md52.Sum(res.Body())
|
||||||
if c.NodeInfoRspMd5 != [16]byte{} {
|
if c.NodeInfoRspMd5 != [16]byte{} {
|
||||||
@ -189,6 +192,7 @@ func (c *Client) ParseTrojanNodeResponse(body []byte) (*NodeInfo, error) {
|
|||||||
node.DeviceLimit = c.DeviceLimit
|
node.DeviceLimit = c.DeviceLimit
|
||||||
node.NodeId = c.NodeID
|
node.NodeId = c.NodeID
|
||||||
node.NodeType = c.NodeType
|
node.NodeType = c.NodeType
|
||||||
|
node.Trojan.TransportProtocol = "tcp"
|
||||||
return node, nil
|
return node, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +229,7 @@ func (c *Client) ParseSSNodeResponse() (*NodeInfo, error) {
|
|||||||
|
|
||||||
// ParseV2rayNodeResponse parse the response for the given nodeinfor format
|
// ParseV2rayNodeResponse parse the response for the given nodeinfor format
|
||||||
func (c *Client) ParseV2rayNodeResponse(body []byte, notParseNode, parseRule bool) (*NodeInfo, error) {
|
func (c *Client) ParseV2rayNodeResponse(body []byte, notParseNode, parseRule bool) (*NodeInfo, error) {
|
||||||
if notParseNode && (!parseRule) {
|
if notParseNode && !parseRule {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
node := &NodeInfo{V2ray: &V2rayConfig{}}
|
node := &NodeInfo{V2ray: &V2rayConfig{}}
|
||||||
|
@ -133,7 +133,7 @@ func (c *Controller) nodeInfoMonitor() (err error) {
|
|||||||
var nodeInfoChanged = false
|
var nodeInfoChanged = false
|
||||||
// If nodeInfo changed
|
// If nodeInfo changed
|
||||||
if newNodeInfo != nil {
|
if newNodeInfo != nil {
|
||||||
if !reflect.DeepEqual(c.nodeInfo, newNodeInfo) {
|
if c.nodeInfo.SS == nil || !reflect.DeepEqual(c.nodeInfo.SS, newNodeInfo.SS) {
|
||||||
// Remove old tag
|
// Remove old tag
|
||||||
oldtag := c.Tag
|
oldtag := c.Tag
|
||||||
err := c.removeOldTag(oldtag)
|
err := c.removeOldTag(oldtag)
|
||||||
|
@ -65,7 +65,7 @@ func InboundBuilder(config *Config, nodeInfo *api.NodeInfo, tag string) (*core.I
|
|||||||
nodeInfo.V2ray.Inbounds[0].PortList = &conf.PortList{
|
nodeInfo.V2ray.Inbounds[0].PortList = &conf.PortList{
|
||||||
Range: []conf.PortRange{{From: uint32(nodeInfo.Trojan.LocalPort), To: uint32(nodeInfo.Trojan.LocalPort)}},
|
Range: []conf.PortRange{{From: uint32(nodeInfo.Trojan.LocalPort), To: uint32(nodeInfo.Trojan.LocalPort)}},
|
||||||
}
|
}
|
||||||
t := conf.TransportProtocol(nodeInfo.SS.TransportProtocol)
|
t := conf.TransportProtocol(nodeInfo.Trojan.TransportProtocol)
|
||||||
nodeInfo.V2ray.Inbounds[0].StreamSetting = &conf.StreamConfig{Network: &t}
|
nodeInfo.V2ray.Inbounds[0].StreamSetting = &conf.StreamConfig{Network: &t}
|
||||||
} else if nodeInfo.NodeType == "Shadowsocks" {
|
} else if nodeInfo.NodeType == "Shadowsocks" {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -77,7 +77,7 @@ func (c *Controller) buildTrojanUsers(userInfo *[]api.UserInfo) (users []*protoc
|
|||||||
users = make([]*protocol.User, len(*userInfo))
|
users = make([]*protocol.User, len(*userInfo))
|
||||||
for i, user := range *userInfo {
|
for i, user := range *userInfo {
|
||||||
trojanAccount := &trojan.Account{
|
trojanAccount := &trojan.Account{
|
||||||
Password: user.V2rayUser.Uuid,
|
Password: user.TrojanUser.Password,
|
||||||
Flow: "xtls-rprx-direct",
|
Flow: "xtls-rprx-direct",
|
||||||
}
|
}
|
||||||
users[i] = &protocol.User{
|
users[i] = &protocol.User{
|
||||||
@ -91,7 +91,7 @@ func (c *Controller) buildTrojanUsers(userInfo *[]api.UserInfo) (users []*protoc
|
|||||||
|
|
||||||
func (c *Controller) buildTrojanUser(userInfo *api.UserInfo) (user *protocol.User) {
|
func (c *Controller) buildTrojanUser(userInfo *api.UserInfo) (user *protocol.User) {
|
||||||
trojanAccount := &trojan.Account{
|
trojanAccount := &trojan.Account{
|
||||||
Password: userInfo.V2rayUser.Uuid,
|
Password: userInfo.TrojanUser.Password,
|
||||||
Flow: "xtls-rprx-direct",
|
Flow: "xtls-rprx-direct",
|
||||||
}
|
}
|
||||||
user = &protocol.User{
|
user = &protocol.User{
|
||||||
|
Loading…
Reference in New Issue
Block a user