diff --git a/pkg/visor/init.go b/pkg/visor/init.go index 1b32978d99..09bdcd9564 100644 --- a/pkg/visor/init.go +++ b/pkg/visor/init.go @@ -512,9 +512,15 @@ func getRouteSetupHooks(ctx context.Context, v *Visor, log *logging.Logger) []ro return dmsgFallback() } // try to establish direct connection to rPK (single hop) using SUDPH or STCPR - errSlice := make([]error, 0, 2) + trySTCPR := false + trySUDPH := false + for _, trans := range transports { ntype := network.Type(trans) + if ntype == network.STCPR { + trySTCPR = true + continue + } // Wait until stun client is ready <-v.stunReady @@ -524,18 +530,27 @@ func getRouteSetupHooks(ctx context.Context, v *Visor, log *logging.Logger) []ro v.stunClient.NATType == stun.NATSymmetricUDPFirewall) { continue } + trySUDPH = true + } + + // trying to establish direct connection to rPK using STCPR + if trySTCPR { err := retrier.Do(ctx, func() error { - _, err := tm.SaveTransport(ctx, rPK, ntype, transport.LabelAutomatic) + _, err := tm.SaveTransport(ctx, rPK, network.STCPR, transport.LabelAutomatic) return err }) - if err != nil { - errSlice = append(errSlice, err) - } + return err } - if len(errSlice) != 2 { - return nil + // trying to establish direct connection to rPK using SUDPH + if trySUDPH { + err := retrier.Do(ctx, func() error { + _, err := tm.SaveTransport(ctx, rPK, network.SUDPH, transport.LabelAutomatic) + return err + }) + return err } - return errors.New(errSlice[0].Error()) + + return dmsgFallback() }, } }