CI / verify (push) Canceled after 0s
Docker Release / build-and-push (amd64, linux/amd64) (push) Canceled after 0s
Docker Release / build-and-push (arm64, linux/arm64) (push) Canceled after 0s
GitHub Release / release (push) Canceled after 0s
Docker Release / create-manifest (push) Canceled after 0s
- 「公网服务端」新增 Nginx 启停控制(Agent 0.15.2,停止带二次确认) - frps 启动失败不再误报成功,并增强启动诊断 - frps vhost 端口禁止 80/443,避免与 VPS 上 Nginx 冲突 - 旧服务端配置的 tcp_mux / login_fail_exit 默认值补齐 - 新增安全审查、页面布局方案与场景操作文档
54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestLoadNginxDefaultPorts(t *testing.T) {
|
|
t.Setenv("HAVLINE_NGINX_HTTP_PORT", "18080")
|
|
t.Setenv("HAVLINE_NGINX_HTTPS_PORT", "9443")
|
|
|
|
cfg := Load()
|
|
if cfg.NginxDefaultHTTPPort != 18080 {
|
|
t.Fatalf("http port %d", cfg.NginxDefaultHTTPPort)
|
|
}
|
|
if cfg.NginxDefaultHTTPSPort != 9443 {
|
|
t.Fatalf("https port %d", cfg.NginxDefaultHTTPSPort)
|
|
}
|
|
if cfg.DefaultListenPort(false) != 18080 {
|
|
t.Fatalf("default http listen %d", cfg.DefaultListenPort(false))
|
|
}
|
|
if cfg.DefaultListenPort(true) != 9443 {
|
|
t.Fatalf("default https listen %d", cfg.DefaultListenPort(true))
|
|
}
|
|
}
|
|
|
|
func TestLoadNginxDefaultPortsFallback(t *testing.T) {
|
|
os.Unsetenv("HAVLINE_NGINX_HTTP_PORT")
|
|
os.Unsetenv("HAVLINE_NGINX_HTTPS_PORT")
|
|
|
|
cfg := Load()
|
|
if cfg.NginxDefaultHTTPPort != 80 || cfg.NginxDefaultHTTPSPort != 443 {
|
|
t.Fatalf("ports %d %d", cfg.NginxDefaultHTTPPort, cfg.NginxDefaultHTTPSPort)
|
|
}
|
|
}
|
|
|
|
func TestLoadUpdaterTokenFile(t *testing.T) {
|
|
t.Setenv("HAVLINE_UPDATER_TOKEN_FILE", "/tmp/havline-updater.token")
|
|
|
|
cfg := Load()
|
|
if cfg.UpdaterTokenFile != "/tmp/havline-updater.token" {
|
|
t.Fatalf("updater token file %q", cfg.UpdaterTokenFile)
|
|
}
|
|
}
|
|
|
|
func TestSSHKnownHostsPathForServer(t *testing.T) {
|
|
cfg := Config{DataDir: "/data"}
|
|
want := filepath.Join("/data", "ssh_known_hosts", "server-3")
|
|
if got := cfg.SSHKnownHostsPathForServer(3); got != want {
|
|
t.Fatalf("per-server known_hosts path %q", got)
|
|
}
|
|
}
|