MCPcopy Index your code
hub / github.com/tailscale/tailscale / makeHangDialer

Function makeHangDialer

wgengine/netstack/netstack_test.go:710–735  ·  view source on GitHub ↗

makeHangDialer returns a dialer that notifies the returned channel when a connection is dialed and then hangs until the test finishes.

(tb testing.TB)

Source from the content-addressed store, hash-verified

708// makeHangDialer returns a dialer that notifies the returned channel when a
709// connection is dialed and then hangs until the test finishes.
710func makeHangDialer(tb testing.TB) (netx.DialFunc, chan struct{}) {
711 done := make(chan struct{})
712 tb.Cleanup(func() {
713 close(done)
714 })
715
716 gotConn := make(chan struct{}, 1)
717 fn := func(ctx context.Context, network, address string) (net.Conn, error) {
718 // Signal that we have a new connection
719 tb.Logf("hangDialer: called with network=%q address=%q", network, address)
720 select {
721 case gotConn <- struct{}{}:
722 default:
723 }
724
725 // Hang until the test is done.
726 select {
727 case <-ctx.Done():
728 tb.Logf("context done")
729 case <-done:
730 tb.Logf("function completed")
731 }
732 return nil, fmt.Errorf("canceled")
733 }
734 return fn, gotConn
735}
736
737// TestTCPForwardLimits verifies that the limits on the TCP forwarder work in a
738// success case (i.e. when we don't hit the limit).

Calls 4

CleanupMethod · 0.65
LogfMethod · 0.65
DoneMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…