MCPcopy Create free account
hub / github.com/coder/coder / pingWithType

Method pingWithType

tailnet/conn.go:577–595  ·  view source on GitHub ↗
(ctx context.Context, ip netip.Addr, pt tailcfg.PingType)

Source from the content-addressed store, hash-verified

575}
576
577func (c *Conn) pingWithType(ctx context.Context, ip netip.Addr, pt tailcfg.PingType) (time.Duration, bool, *ipnstate.PingResult, error) {
578 errCh := make(chan error, 1)
579 prChan := make(chan *ipnstate.PingResult, 1)
580 go c.wireguardEngine.Ping(ip, pt, func(pr *ipnstate.PingResult) {
581 if pr.Err != "" {
582 errCh <- xerrors.New(pr.Err)
583 return
584 }
585 prChan <- pr
586 })
587 select {
588 case err := <-errCh:
589 return 0, false, nil, err
590 case <-ctx.Done():
591 return 0, false, nil, ctx.Err()
592 case pr := <-prChan:
593 return time.Duration(pr.LatencySeconds * float64(time.Second)), pr.Endpoint != "", pr, nil
594 }
595}
596
597// DERPMap returns the currently set DERP mapping.
598func (c *Conn) DERPMap() *tailcfg.DERPMap {

Callers 2

PingMethod · 0.95
AwaitReachableMethod · 0.95

Implementers 1

fakeConnvpn/tunnel_internal_test.go

Calls 5

ErrMethod · 0.80
DurationMethod · 0.80
PingMethod · 0.65
NewMethod · 0.65
DoneMethod · 0.45

Tested by

no test coverage detected