From 21bd807e99a8699ce5bea3565b523005cc5c6125 Mon Sep 17 00:00:00 2001 From: yuzuki999 Date: Mon, 6 Jun 2022 15:29:01 +0800 Subject: [PATCH] optimize code --- api/node.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/api/node.go b/api/node.go index fab9156..27835ae 100644 --- a/api/node.go +++ b/api/node.go @@ -225,6 +225,9 @@ func (c *Client) ParseSSNodeResponse() (*NodeInfo, error) { // ParseV2rayNodeResponse parse the response for the given nodeinfor format func (c *Client) ParseV2rayNodeResponse(body []byte, notParseNode, parseRule bool) (*NodeInfo, error) { + if notParseNode && (!parseRule) { + return nil, nil + } node := &NodeInfo{V2ray: &V2rayConfig{}} err := json.Unmarshal(body, node.V2ray) if err != nil { @@ -236,16 +239,15 @@ func (c *Client) ParseV2rayNodeResponse(body []byte, notParseNode, parseRule boo if err != nil { log.Println(err) } + if notParseNode { + return nil, nil + } } node.V2ray.Routing = nil - if notParseNode { - return nil, nil - } node.SpeedLimit = uint64(c.SpeedLimit * 1000000 / 8) node.DeviceLimit = c.DeviceLimit node.NodeType = c.NodeType node.NodeId = c.NodeID - if c.EnableXTLS { node.TLSType = "xtls" } else {