feat(server): P2 后端补字段 — 套餐价格 + 节点 host(#6 6B)
- 迁移 000014_plan_pricing(mysql+sqlite 双套):plans 加 price_cents/currency/ period,seed pro=2500 team=9900(¥25/¥99);ListPlans 返回价格字段。 - /v1/nodes 暴露 host+port(取自 node.Endpoint,无 schema 变更),供客户端实测 真实 per-client 延迟(服务端无法代知)。 - 修复 account.go 的 GetMe/weeklyGB 残留 MySQL 专属 UTC_DATE()/INTERVAL (#1 漏网):改 Go 端算日期传 ?,否则 SQLite 节点今日/周流量恒 0。 - sqlite 迁移 up/down 测试期望版本 13→14。 go build/vet 干净;sqlite 迁移 up/down + httpapi 测试通过。节点 tag 暂不加 (无真实数据,不造空字段;客户端将不显示伪造 tag)。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package httpapi
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -42,6 +43,9 @@ type nodeResponse struct {
|
||||
NameEN string `json:"name_en"`
|
||||
Tier string `json:"tier"` // "free" | "pro"
|
||||
Status string `json:"status"` // always "up" in this endpoint
|
||||
// host/port 暴露节点入口,供客户端实测真实延迟(per-client ping 服务端无法代知)。
|
||||
Host string `json:"host"`
|
||||
Port int `json:"port"`
|
||||
}
|
||||
|
||||
// ListNodes handles GET /v1/nodes.
|
||||
@@ -54,6 +58,11 @@ func (a *NodeAPI) ListNodes(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
resp := make([]nodeResponse, 0, len(nodeRows))
|
||||
for _, n := range nodeRows {
|
||||
host, portStr := splitHostPort(n.Endpoint)
|
||||
if host == "" {
|
||||
host = n.Endpoint
|
||||
}
|
||||
port, _ := strconv.Atoi(portStr)
|
||||
resp = append(resp, nodeResponse{
|
||||
ID: n.UUID,
|
||||
Region: n.Region,
|
||||
@@ -61,6 +70,8 @@ func (a *NodeAPI) ListNodes(w http.ResponseWriter, r *http.Request) {
|
||||
NameEN: n.NameEN,
|
||||
Tier: n.Tier,
|
||||
Status: n.Status,
|
||||
Host: host,
|
||||
Port: port,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user