mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-22 03:10:42 +08:00
将 webServiceCache 扩展为通用 serviceCache,所有指纹识别结果 统一缓存,插件匹配时端口不命中则回退到服务名称匹配。 删除多余的 service_cache.go,复用已有的 ServiceInfo 体系。 补充 nil 防御、Explicit 标记、大量单元/集成/回归测试。
25 lines
680 B
Go
25 lines
680 B
Go
package lib
|
|
|
|
import "testing"
|
|
|
|
func TestNormalizeHTTPProxyURL(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
in string
|
|
want string
|
|
}{
|
|
{name: "port shortcut", in: "8080", want: "http://127.0.0.1:8080"},
|
|
{name: "ipv4 host port", in: "127.0.0.1:8080", want: "http://127.0.0.1:8080"},
|
|
{name: "hostname port", in: "proxy.local:8080", want: "http://proxy.local:8080"},
|
|
{name: "bracketed ipv6 port", in: "[::1]:8080", want: "http://[::1]:8080"},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := normalizeHTTPProxyURL(tt.in); got != tt.want {
|
|
t.Fatalf("normalizeHTTPProxyURL(%q) = %q, want %q", tt.in, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|