optimize code

This commit is contained in:
yuzuki999 2022-06-06 15:29:01 +08:00
parent 3848198630
commit 21bd807e99

View File

@ -225,6 +225,9 @@ 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) {
return nil, nil
}
node := &NodeInfo{V2ray: &V2rayConfig{}} node := &NodeInfo{V2ray: &V2rayConfig{}}
err := json.Unmarshal(body, node.V2ray) err := json.Unmarshal(body, node.V2ray)
if err != nil { if err != nil {
@ -236,16 +239,15 @@ func (c *Client) ParseV2rayNodeResponse(body []byte, notParseNode, parseRule boo
if err != nil { if err != nil {
log.Println(err) log.Println(err)
} }
if notParseNode {
return nil, nil
}
} }
node.V2ray.Routing = nil node.V2ray.Routing = nil
if notParseNode {
return nil, nil
}
node.SpeedLimit = uint64(c.SpeedLimit * 1000000 / 8) node.SpeedLimit = uint64(c.SpeedLimit * 1000000 / 8)
node.DeviceLimit = c.DeviceLimit node.DeviceLimit = c.DeviceLimit
node.NodeType = c.NodeType node.NodeType = c.NodeType
node.NodeId = c.NodeID node.NodeId = c.NodeID
if c.EnableXTLS { if c.EnableXTLS {
node.TLSType = "xtls" node.TLSType = "xtls"
} else { } else {