仪表盘:新增「公网穿透」卡与运行状态「公网反代」行(新增 GET /api/frpmulti/routes/summary 逐台聚合);「性能」面板(今日异常/平均响应)与「流量 Top 5」;新增一行三卡「系统资源 / 中国 IP 段 / 通知通道」,系统资源来自新增跨平台采集 internal/sysinfo 仪表盘:「服务」卡不再写死「正常」,按 Fonu/Nginx/DDNS/证书四项实际状态聚合;/api/status 每 15 秒刷新并按页面可见性暂停轮询;删除死样式 公网反代:部署漂移清单(未部署/孤儿配置/未生效/内容不一致)+ 重新部署全部(逐条下发、单条失败不中断) 公网 Agent:端口矩阵补端口含义;frps 启动一致性核对;证书徽标补证书来源 FRP:frpc 版本探测失败时回落按二进制目录名推导,并逐台服务端探测 文档:新增 docs/agent-capability-plan.md(agent 能力扩展方案);VERSION 提升到 1.2.3
43 lines
1.3 KiB
Go
43 lines
1.3 KiB
Go
package frp
|
|
|
|
import "testing"
|
|
|
|
func TestProxyPassTarget(t *testing.T) {
|
|
content := "server {\n listen 443 ssl;\n location / {\n proxy_pass http://127.0.0.1:8080;\n }\n}\n"
|
|
if got := proxyPassTarget(content); got != "http://127.0.0.1:8080" {
|
|
t.Fatalf("unexpected target: %q", got)
|
|
}
|
|
if got := proxyPassTarget("server {\n listen 80;\n}\n"); got != "" {
|
|
t.Fatalf("expected empty target, got %q", got)
|
|
}
|
|
}
|
|
|
|
func TestNormalizeUpstream(t *testing.T) {
|
|
cases := map[string]string{
|
|
"http://127.0.0.1:8080": "127.0.0.1:8080",
|
|
"https://127.0.0.1:8443/": "127.0.0.1:8443",
|
|
"127.0.0.1:8080": "127.0.0.1:8080",
|
|
}
|
|
for input, want := range cases {
|
|
if got := normalizeUpstream(input); got != want {
|
|
t.Fatalf("normalizeUpstream(%q) = %q,期望 %q", input, got, want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestDeployableProxy(t *testing.T) {
|
|
deployable := Proxy{Enabled: true, Type: "http", CustomDomains: []string{"a.com"}}
|
|
if !deployableProxy(deployable) {
|
|
t.Fatal("启用的 http 规则且有自定义域名,应可部署")
|
|
}
|
|
for _, proxy := range []Proxy{
|
|
{Enabled: false, Type: "http", CustomDomains: []string{"a.com"}},
|
|
{Enabled: true, Type: "tcp", CustomDomains: []string{"a.com"}},
|
|
{Enabled: true, Type: "http"},
|
|
} {
|
|
if deployableProxy(proxy) {
|
|
t.Fatalf("不应判定为可部署:%+v", proxy)
|
|
}
|
|
}
|
|
}
|