prober: support creating multiple probes in ForEachAddr

So that we can e.g. check TLS on multiple ports for a given IP.

Updates tailscale/corp#16367

Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Change-Id: I81d840a4c88138de1cbb2032b917741c009470e6
This commit is contained in:
Andrew Dunham
2024-04-04 12:47:37 -04:00
parent ac574d875c
commit 7d7d159824
3 changed files with 26 additions and 22 deletions

View File

@@ -39,14 +39,15 @@ func ExampleForEachAddr() {
}
// This function is called every time we discover a new IP address to check.
makeTLSProbe := func(addr netip.Addr) *prober.Probe {
makeTLSProbe := func(addr netip.Addr) []*prober.Probe {
pf := prober.TLSWithIP(*hostname, netip.AddrPortFrom(addr, 443))
if *verbose {
logger := logger.WithPrefix(log.Printf, fmt.Sprintf("[tls %s]: ", addr))
pf = probeLogWrapper(logger, pf)
}
return p.Run(fmt.Sprintf("website/%s/tls", addr), every30s, nil, pf)
probe := p.Run(fmt.Sprintf("website/%s/tls", addr), every30s, nil, pf)
return []*prober.Probe{probe}
}
// Determine whether to use IPv4 or IPv6 based on whether we can create