Skip to content

Commit

Permalink
remove loop in probe, add 5s timeout so callers can handle retries
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldwan committed Aug 13, 2021
1 parent 9f6e14e commit 302d2fc
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,18 +254,11 @@ func (s *Server) handleEstablish(c net.Conn, args []string) error {
func probeTunnel(tunnel *wg.Tunnel) error {
var err error

for i := 0; i < 3; i++ {
terminal.Debugf("Probing WireGuard connectivity, attempt %d\n", i)

ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)

_, err = tunnel.Resolver().LookupTXT(ctx, "_apps.internal")
cancel()
if err == nil {
break
}
}
terminal.Debugf("Probing WireGuard connectivity\n")

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
_, err = tunnel.Resolver().LookupTXT(ctx, "_apps.internal")
if err != nil {
return fmt.Errorf("probing look up apps: %w", err)
}
Expand Down

0 comments on commit 302d2fc

Please sign in to comment.