ScanTLS 执行TLS扫描
(host Host, resultChan chan<- ScanResult, geo *Geo)
| 14 | |
| 15 | // ScanTLS 执行TLS扫描 |
| 16 | func ScanTLS(host Host, resultChan chan<- ScanResult, geo *Geo) { |
| 17 | var ips []net.IP |
| 18 | var err error |
| 19 | |
| 20 | // 根据主机类型获取IP地址 |
| 21 | switch host.Type { |
| 22 | case HostTypeIP: |
| 23 | ips = []net.IP{host.IP} |
| 24 | case HostTypeDomain: |
| 25 | ips, err = ResolveDomain(host.Origin) |
| 26 | if err != nil { |
| 27 | resultChan <- ScanResult{ |
| 28 | IP: "", |
| 29 | Origin: host.Origin, |
| 30 | Port: config.Port, |
| 31 | Error: fmt.Sprintf("域名解析失败: %v", err), |
| 32 | } |
| 33 | return |
| 34 | } |
| 35 | default: |
| 36 | resultChan <- ScanResult{ |
| 37 | IP: "", |
| 38 | Origin: host.Origin, |
| 39 | Port: config.Port, |
| 40 | Error: "不支持的主机类型", |
| 41 | } |
| 42 | return |
| 43 | } |
| 44 | |
| 45 | // 扫描每个IP |
| 46 | for _, ip := range ips { |
| 47 | scanSingleIP(ip, host.Origin, resultChan, geo) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // scanSingleIP 扫描单个IP地址 |
| 52 | func scanSingleIP(ip net.IP, origin string, resultChan chan<- ScanResult, geo *Geo) { |
no test coverage detected