ci
Build docker and publish / linux (1.24.3) (push) Has been cancelled

This commit is contained in:
2025-09-26 18:37:43 -07:00
parent ac3bbaf7bf
commit 7471fd8e3d
4 changed files with 18 additions and 51 deletions
+4 -47
View File
@@ -3,11 +3,6 @@ package common
import (
"context"
"encoding/json"
"io"
"net"
"net/http"
"slices"
"strings"
"time"
"github.com/perfect-panel/server/internal/config"
@@ -68,47 +63,9 @@ func (l *GetStatLogic) GetStat() (resp *types.GetStatResponse, err error) {
l.Logger.Error("[GetStatLogic] get server_addr failed: ", logger.Field("error", err.Error()))
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "get server_addr failed: %v", err.Error())
}
type apireq struct {
query string
fields string
}
type apiret struct {
CountryCode string `json:"countryCode"`
}
//map as dict
type void struct{}
var v void
country := make(map[string]void)
for c := range slices.Chunk(nodeaddr, 100) {
var batchreq []apireq
for _, addr := range c {
isAddr := net.ParseIP(addr)
if isAddr == nil {
ip, err := net.LookupIP(addr)
if err == nil && len(ip) > 0 {
batchreq = append(batchreq, apireq{query: ip[0].String(), fields: "countryCode"})
}
} else {
batchreq = append(batchreq, apireq{query: addr, fields: "countryCode"})
}
}
req, _ := json.Marshal(batchreq)
ret, err := http.Post("http://ip-api.com/batch", "application/json", strings.NewReader(string(req)))
if err == nil {
retBytes, err := io.ReadAll(ret.Body)
if err == nil {
var retStruct []apiret
err := json.Unmarshal(retBytes, &retStruct)
if err == nil {
for _, dat := range retStruct {
if dat.CountryCode != "" {
country[dat.CountryCode] = v
}
}
}
}
}
}
country := 0
protocolDict := make(map[string]void)
var protocol []string
l.svcCtx.DB.Model(&server.Server{}).Where("enable = true").Pluck("protocol", &protocol)
@@ -122,7 +79,7 @@ func (l *GetStatLogic) GetStat() (resp *types.GetStatResponse, err error) {
resp = &types.GetStatResponse{
User: u,
Node: n,
Country: int64(len(country)),
Country: int64(country),
Protocol: protocol,
OnlineDevice: l.svcCtx.DeviceManager.GetOnlineDeviceCount(),
}