This commit is contained in:
parent
ac3bbaf7bf
commit
7471fd8e3d
@ -24,7 +24,7 @@ RUN BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ") && \
|
|||||||
go build -ldflags="-s -w -X 'github.com/perfect-panel/server/pkg/constant.Version=${VERSION}' -X 'github.com/perfect-panel/server/pkg/constant.BuildTime=${BUILD_TIME}'" -o /app/ppanel ppanel.go
|
go build -ldflags="-s -w -X 'github.com/perfect-panel/server/pkg/constant.Version=${VERSION}' -X 'github.com/perfect-panel/server/pkg/constant.BuildTime=${BUILD_TIME}'" -o /app/ppanel ppanel.go
|
||||||
|
|
||||||
# Final minimal image
|
# Final minimal image
|
||||||
FROM scratch
|
FROM alpine:latest
|
||||||
|
|
||||||
# Copy CA certificates and timezone data
|
# Copy CA certificates and timezone data
|
||||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
|
|||||||
@ -36,3 +36,15 @@ Redis:
|
|||||||
Administrator:
|
Administrator:
|
||||||
Password: password
|
Password: password
|
||||||
Email: admin@ppanel.dev
|
Email: admin@ppanel.dev
|
||||||
|
Email:
|
||||||
|
Enable: true
|
||||||
|
Platform: smtp
|
||||||
|
PlatformConfig: '{"host":"smtp.gmail.com","port":465,"user":"devneeds52@gmail.com","pass":"bqxn hurw ckxt ookj","from":"devneeds52@gmail.com","ssl":true}'
|
||||||
|
EnableVerify: true
|
||||||
|
EnableNotify: true
|
||||||
|
EnableDomainSuffix: false
|
||||||
|
DomainSuffixList: ""
|
||||||
|
VerifyEmailTemplate: ""
|
||||||
|
ExpirationEmailTemplate: ""
|
||||||
|
MaintenanceEmailTemplate: ""
|
||||||
|
TrafficExceedEmailTemplate: ""
|
||||||
@ -3,11 +3,6 @@ package common
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
|
||||||
"net"
|
|
||||||
"net/http"
|
|
||||||
"slices"
|
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/perfect-panel/server/internal/config"
|
"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()))
|
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())
|
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "get server_addr failed: %v", err.Error())
|
||||||
}
|
}
|
||||||
type apireq struct {
|
|
||||||
query string
|
country := 0
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
protocolDict := make(map[string]void)
|
protocolDict := make(map[string]void)
|
||||||
var protocol []string
|
var protocol []string
|
||||||
l.svcCtx.DB.Model(&server.Server{}).Where("enable = true").Pluck("protocol", &protocol)
|
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{
|
resp = &types.GetStatResponse{
|
||||||
User: u,
|
User: u,
|
||||||
Node: n,
|
Node: n,
|
||||||
Country: int64(len(country)),
|
Country: int64(country),
|
||||||
Protocol: protocol,
|
Protocol: protocol,
|
||||||
OnlineDevice: l.svcCtx.DeviceManager.GetOnlineDeviceCount(),
|
OnlineDevice: l.svcCtx.DeviceManager.GetOnlineDeviceCount(),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,8 +66,6 @@ func (m *customTicketModel) QueryTicketList(ctx context.Context, page, size int,
|
|||||||
}
|
}
|
||||||
if status != nil {
|
if status != nil {
|
||||||
query = query.Where("status = ?", status)
|
query = query.Where("status = ?", status)
|
||||||
} else {
|
|
||||||
query = query.Where("status != ?", 4)
|
|
||||||
}
|
}
|
||||||
if issueType != nil {
|
if issueType != nil {
|
||||||
query = query.Where("issue_type = ?", issueType)
|
query = query.Where("issue_type = ?", issueType)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user