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

@@ -48,7 +48,7 @@ func TestForEachAddr(t *testing.T) {
mu sync.Mutex // protects following
registered []netip.Addr
)
newProbe := func(addr netip.Addr) *Probe {
newProbe := func(addr netip.Addr) []*Probe {
// Called to register a new prober
t.Logf("called to register new probe for %v", addr)
@@ -57,9 +57,10 @@ func TestForEachAddr(t *testing.T) {
registered = append(registered, addr)
// Return a probe that does nothing; we don't care about what this does.
return p.Run(fmt.Sprintf("website/%s", addr), probeInterval, nil, func(_ context.Context) error {
probe := p.Run(fmt.Sprintf("website/%s", addr), probeInterval, nil, func(_ context.Context) error {
return nil
})
return []*Probe{probe}
}
fep := makeForEachAddr("tailscale.com", newProbe, opts)