From d9971b2181f36c0cf1cfd83a5a759ccc33db5c2b Mon Sep 17 00:00:00 2001 From: Senis John Date: Sat, 28 Oct 2023 13:19:17 +0800 Subject: [PATCH] Initialize server port in sspanel This commit initializes the server port in sspanel.go if the userListResponse is not empty. This adds a level of preventative measure to ensure port is not left uninitialized. --- api/sspanel/sspanel.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/sspanel/sspanel.go b/api/sspanel/sspanel.go index 1179c999..9a4880e4 100644 --- a/api/sspanel/sspanel.go +++ b/api/sspanel/sspanel.go @@ -519,6 +519,11 @@ func (c *APIClient) ParseSSNodeResponse(nodeInfoResponse *NodeInfoResponse) (*ap return nil, fmt.Errorf("unmarshal %s failed: %s", reflect.TypeOf(userListResponse), err) } + // init server port + if len(*userListResponse) != 0 { + port = (*userListResponse)[0].Port + } + if c.SpeedLimit > 0 { speedLimit = uint64((c.SpeedLimit * 1000000) / 8) } else {