mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-12 05:09:41 +08:00
- 后端 ConnectionConfig 增加代理配置并完成规范化处理 - 普通 TCP 数据源通过本地转发接入代理 - MongoDB 使用 Dialer 支持代理连接(含 SRV) - 前端连接配置新增代理 UI、字段清洗与数据回填 - refs #122
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package proxy
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"GoNavi-Wails/internal/connection"
|
|
)
|
|
|
|
func TestNormalizeConfigSupportsSocks5hAlias(t *testing.T) {
|
|
cfg, err := NormalizeConfig(connection.ProxyConfig{
|
|
Type: "SOCKS5H",
|
|
Host: "127.0.0.1",
|
|
Port: 1080,
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("NormalizeConfig returned error: %v", err)
|
|
}
|
|
if cfg.Type != "socks5" {
|
|
t.Fatalf("expected normalized proxy type socks5, got %s", cfg.Type)
|
|
}
|
|
}
|
|
|
|
func TestForwarderCacheKeyIncludesCredentialFingerprint(t *testing.T) {
|
|
base := connection.ProxyConfig{
|
|
Type: "socks5",
|
|
Host: "127.0.0.1",
|
|
Port: 1080,
|
|
User: "tester",
|
|
Password: "first-password",
|
|
}
|
|
other := base
|
|
other.Password = "second-password"
|
|
|
|
keyA := forwarderCacheKey(base, "db.internal", 3306)
|
|
keyB := forwarderCacheKey(other, "db.internal", 3306)
|
|
|
|
if keyA == keyB {
|
|
t.Fatalf("expected different cache key for different credentials")
|
|
}
|
|
if strings.Contains(keyA, base.Password) || strings.Contains(keyB, other.Password) {
|
|
t.Fatalf("cache key should not contain raw password")
|
|
}
|
|
}
|