mirror of
https://github.com/tailscale/tailscale.git
synced 2025-03-27 19:43:01 +00:00

Previously, the prober was stateless, and probe needed to be called manually whenever additional probes were required. This adds a stateful prober, which can theoretically reuse clients between runs and have smarter strategies for delays between retries, which may be crucial depending on how slow UPnP is. Signed-off-by: julianknodt <julianknodt@gmail.com>
27 lines
599 B
Go
27 lines
599 B
Go
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package portmapper
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"strconv"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestClientProber(t *testing.T) {
|
|
if v, _ := strconv.ParseBool(os.Getenv("HIT_NETWORK")); !v {
|
|
t.Skip("skipping test without HIT_NETWORK=1")
|
|
}
|
|
c := NewClient(t.Logf)
|
|
ctx := context.Background()
|
|
prober := c.NewProber(ctx)
|
|
time.Sleep(3 * time.Second)
|
|
prober.Stop()
|
|
res, err := prober.CurrentStatus()
|
|
t.Logf("Got: %+v, %v", res, err)
|
|
}
|