- 公网反代:Nginx 状态卡片(版本 / 运行状态 / 配置校验 / 端口监听) - 部署设置第一、二梯队(HTTPS 开关、安全头、限流、连接数、仅中国大陆 IP) - 隧道检测兼容 frps v0.68 / v0.71(V2 与旧版端点) - 恢复被清空的 internal/frp/store.go、internal/api/ddns_handler.go、web/src/views/DdnsView.vue
26 lines
618 B
Go
26 lines
618 B
Go
package proxy
|
|
|
|
import "testing"
|
|
|
|
func TestRuleEndpointsUsesListenPort(t *testing.T) {
|
|
rule := Rule{
|
|
ListenPort: 6893,
|
|
Hosts: []Host{
|
|
{Hostname: "xxx.com"},
|
|
{Hostname: "xxx.com", ListenPort: intPtr(8081)},
|
|
},
|
|
}
|
|
endpoints := rule.Endpoints()
|
|
if len(endpoints) != 2 {
|
|
t.Fatalf("expected 2 endpoints, got %d", len(endpoints))
|
|
}
|
|
if endpoints[0].Hostname != "xxx.com" || endpoints[0].Port != 6893 {
|
|
t.Fatalf("unexpected first endpoint: %+v", endpoints[0])
|
|
}
|
|
if endpoints[1].Port != 8081 {
|
|
t.Fatalf("expected custom port 8081, got %d", endpoints[1].Port)
|
|
}
|
|
}
|
|
|
|
func intPtr(v int) *int { return &v }
|