runWizardScans runs the IP + SNI scanners concurrently and prints live progress. Returns the raw results for the caller to rank.
(out io.Writer)
| 212 | // runWizardScans runs the IP + SNI scanners concurrently and prints live |
| 213 | // progress. Returns the raw results for the caller to rank. |
| 214 | func runWizardScans(out io.Writer) ([]scanner.IPResult, []scanner.Result) { |
| 215 | ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) |
| 216 | defer cancel() |
| 217 | ipTarget := len(scanner.DefaultCloudflareIPs) |
| 218 | sniTarget := len(scanner.DefaultSNICandidates) |
| 219 | |
| 220 | ipCh := make(chan []scanner.IPResult, 1) |
| 221 | sniCh := make(chan []scanner.Result, 1) |
| 222 | |
| 223 | go func() { |
| 224 | ipCh <- scanner.ProbeIPs(ctx, scanner.DefaultCloudflareIPs, 443, 2*time.Second, 16, nil) |
| 225 | }() |
| 226 | go func() { |
| 227 | sniCh <- scanner.ProbeSNIs(ctx, scanner.DefaultSNICandidates, scanner.ProbeConfig{ |
| 228 | TargetIP: netip.MustParseAddr("1.1.1.1"), |
| 229 | TargetPort: 443, |
| 230 | ConnectTimeout: 4 * time.Second, |
| 231 | HandshakeTimeout: 4 * time.Second, |
| 232 | Concurrency: 16, |
| 233 | }, nil) |
| 234 | }() |
| 235 | |
| 236 | fmt.Fprintf(out, " ip probes: (%d candidates)\n", ipTarget) |
| 237 | fmt.Fprintf(out, " sni probes: (%d candidates against 1.1.1.1)\n", sniTarget) |
| 238 | fmt.Fprintln(out, " (takes up to ~10 seconds)") |
| 239 | |
| 240 | ips := <-ipCh |
| 241 | snis := <-sniCh |
| 242 | |
| 243 | okSNI := 0 |
| 244 | for _, r := range snis { |
| 245 | if r.Outcome == scanner.OutcomeOK { |
| 246 | okSNI++ |
| 247 | } |
| 248 | } |
| 249 | reachIP := 0 |
| 250 | for _, r := range ips { |
| 251 | if r.Reachable { |
| 252 | reachIP++ |
| 253 | } |
| 254 | } |
| 255 | fmt.Fprintf(out, " ✓ %d/%d SNI candidates OK, %d/%d IPs reachable\n", |
| 256 | okSNI, len(snis), reachIP, len(ips)) |
| 257 | return ips, snis |
| 258 | } |
| 259 | |
| 260 | // Helpers ---------------------------------------------------------------- |
| 261 |