feat: 上游 1.0.3-1.0.5 同步第 1-8 项(v1.2.2)
剪贴板:新增 web/src/utils/clipboard.ts,5 处调用点支持非 HTTPS 环境(对齐 1.0.4) 日志中心:新增「FRP 日志」Tab,解析 frpc 日志为 时间/级别/来源/消息(对齐 1.0.3) 通知:单通道密文解密失败不再拖垮整份配置(对齐 1.0.5);容器补 TZ + tzdata(对齐 1.0.4);Telegram 代理自动补 http:// 并校验 scheme(对齐 1.0.3) 反向代理:复制不再追加「-复制」(对齐 1.0.5);监听占用校验合并表单规则与手动 Nginx 配置两张表(迁移 024 + endpoints 解析器),冲突提示写明占用规则;改端口的并发冲突改为可读提示 FRP:frps 弹窗补「VPS 防火墙放行 TCP 远程端口」提示(对齐 1.0.3);反代配置弹窗补齐内容区内边距与来源说明 文档:新增 docs/upstream-sync-plan.md(逐版本对照 + 第 5 项详细整理);VERSION 与 CHANGELOG 记 v1.2.2
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package nginx
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestParseServerEndpoints(t *testing.T) {
|
||||
content := `server {
|
||||
listen 8011;
|
||||
listen [::]:8011;
|
||||
server_name a.com b.com;
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
}
|
||||
}
|
||||
|
||||
# 注释行不参与解析
|
||||
server {
|
||||
listen 127.0.0.1:8017 ssl;
|
||||
server_name *.c.com ~^regex\.com$ _;
|
||||
}
|
||||
`
|
||||
endpoints := ParseServerEndpoints(content)
|
||||
want := []struct {
|
||||
host string
|
||||
port int
|
||||
}{
|
||||
{"a.com", 8011},
|
||||
{"b.com", 8011},
|
||||
{"*.c.com", 8017},
|
||||
}
|
||||
if len(endpoints) != len(want) {
|
||||
t.Fatalf("expected %d endpoints, got %d (%+v)", len(want), len(endpoints), endpoints)
|
||||
}
|
||||
for i, expect := range want {
|
||||
if endpoints[i].Hostname != expect.host || endpoints[i].Port != expect.port {
|
||||
t.Fatalf("endpoint %d = %s:%d, want %s:%d", i, endpoints[i].Hostname, endpoints[i].Port, expect.host, expect.port)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseServerEndpointsDefaultsToPort80(t *testing.T) {
|
||||
endpoints := ParseServerEndpoints("server {\n server_name d.com;\n return 444;\n}\n")
|
||||
if len(endpoints) != 1 || endpoints[0].Hostname != "d.com" || endpoints[0].Port != 80 {
|
||||
t.Fatalf("expected d.com:80, got %+v", endpoints)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseServerEndpointsIgnoresUnparseable(t *testing.T) {
|
||||
content := `include /etc/nginx/snippets/extra.conf;
|
||||
server {
|
||||
listen unix:/run/fonu.sock;
|
||||
server_name $host;
|
||||
}
|
||||
`
|
||||
if endpoints := ParseServerEndpoints(content); len(endpoints) != 0 {
|
||||
t.Fatalf("expected no endpoints, got %+v", endpoints)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user