MCPcopy Create free account
hub / github.com/SamNet-dev/snix / runWizardScans

Function runWizardScans

cmd/snix/wizard.go:214–258  ·  view source on GitHub ↗

runWizardScans runs the IP + SNI scanners concurrently and prints live progress. Returns the raw results for the caller to rank.

(out io.Writer)

Source from the content-addressed store, hash-verified

212// runWizardScans runs the IP + SNI scanners concurrently and prints live
213// progress. Returns the raw results for the caller to rank.
214func 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

Callers 1

runWizardFunction · 0.85

Calls 2

ProbeIPsFunction · 0.92
ProbeSNIsFunction · 0.92

Tested by

no test coverage detected