mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-24 20:21:52 +08:00
feat: 统一服务缓存 + 指纹驱动插件匹配
将 webServiceCache 扩展为通用 serviceCache,所有指纹识别结果 统一缓存,插件匹配时端口不命中则回退到服务名称匹配。 删除多余的 service_cache.go,复用已有的 ServiceInfo 体系。 补充 nil 防御、Explicit 标记、大量单元/集成/回归测试。
This commit is contained in:
+17
-2
@@ -52,16 +52,31 @@ func getGlobalDialer(timeout time.Duration) (proxy.Dialer, error) {
|
||||
|
||||
// parseProxyURL 解析代理URL,提取地址和认证信息
|
||||
func parseProxyURL(proxyURL, fallback string) (host, username, password string) {
|
||||
if !strings.Contains(proxyURL, "://") {
|
||||
if host, username, password, ok := parseProxyURLCandidate("http://" + proxyURL); ok {
|
||||
return host, username, password
|
||||
}
|
||||
}
|
||||
if host, username, password, ok := parseProxyURLCandidate(proxyURL); ok {
|
||||
return host, username, password
|
||||
}
|
||||
return fallback, "", ""
|
||||
}
|
||||
|
||||
func parseProxyURLCandidate(proxyURL string) (host, username, password string, ok bool) {
|
||||
parsedURL, err := url.Parse(proxyURL)
|
||||
if err != nil {
|
||||
return fallback, "", ""
|
||||
return "", "", "", false
|
||||
}
|
||||
host = parsedURL.Host
|
||||
if host == "" {
|
||||
return "", "", "", false
|
||||
}
|
||||
if parsedURL.User != nil {
|
||||
username = parsedURL.User.Username()
|
||||
password, _ = parsedURL.User.Password()
|
||||
}
|
||||
return
|
||||
return host, username, password, true
|
||||
}
|
||||
|
||||
// createProxyConfig 根据全局设置创建代理配置
|
||||
|
||||
Reference in New Issue
Block a user