Skip to content

Commit d9ba30c

Browse files
committed
ipn/auto: flaky proton absolutely last dialer to try
1 parent 3736a0d commit d9ba30c

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

intra/ipn/auto.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func (h *auto) dial(network, laddr, raddr string) (protect.Conn, error) {
136136
parallelDial := settings.AutoDialsParallel.Load()
137137

138138
if !parallelDial {
139-
rpns := []Proxy{exit, pro, warp, amz, exit64, sep}
139+
rpns := []Proxy{exit, warp, amz, exit64, sep, pro}
140140
healthy := core.Map(
141141
core.FilterLeft(
142142
rpns,
@@ -203,28 +203,6 @@ func (h *auto) dial(network, laddr, raddr string) (protect.Conn, error) {
203203
return h.dialIfReachable(exit, network, laddr, raddr)
204204
}, func(ctx context.Context) (protect.Conn, error) {
205205
const myidx = 1
206-
if pro == nil {
207-
return nil, proerr
208-
}
209-
if recent {
210-
if previdx != myidx {
211-
return nil, errNotPinned
212-
}
213-
// ip pinned to this proxy
214-
return h.dialAlways(pro, network, laddr, raddr)
215-
}
216-
217-
// wait only if exit was used
218-
if !remoteOnly {
219-
select {
220-
case <-ctx.Done():
221-
return nil, ctx.Err()
222-
case <-time.After(shortdelay * myidx): // 100ms
223-
}
224-
}
225-
return h.dialIfHealthy(pro, network, laddr, raddr)
226-
}, func(ctx context.Context) (protect.Conn, error) {
227-
const myidx = 2
228206
if warp == nil {
229207
return nil, waerr
230208
}
@@ -243,7 +221,7 @@ func (h *auto) dial(network, laddr, raddr string) (protect.Conn, error) {
243221
}
244222
return h.dialIfHealthy(warp, network, laddr, raddr)
245223
}, func(ctx context.Context) (protect.Conn, error) {
246-
const myidx = 3
224+
const myidx = 2
247225
if exit64 == nil {
248226
return nil, ex64err
249227
}
@@ -265,7 +243,7 @@ func (h *auto) dial(network, laddr, raddr string) (protect.Conn, error) {
265243
}
266244
return h.dialIfHealthy(exit64, network, laddr, raddr)
267245
}, func(ctx context.Context) (protect.Conn, error) {
268-
const myidx = 4
246+
const myidx = 3
269247
if amz == nil {
270248
return nil, amzerr
271249
}
@@ -284,7 +262,7 @@ func (h *auto) dial(network, laddr, raddr string) (protect.Conn, error) {
284262
}
285263
return h.dialIfHealthy(amz, network, laddr, raddr)
286264
}, func(ctx context.Context) (protect.Conn, error) {
287-
const myidx = 5
265+
const myidx = 4
288266
if sep == nil {
289267
return nil, seerr
290268
}
@@ -302,6 +280,28 @@ func (h *auto) dial(network, laddr, raddr string) (protect.Conn, error) {
302280
case <-time.After(shortdelay * myidx): // 500ms
303281
}
304282
return h.dialIfHealthy(sep, network, laddr, raddr)
283+
}, func(ctx context.Context) (protect.Conn, error) {
284+
const myidx = 5
285+
if pro == nil {
286+
return nil, proerr
287+
}
288+
if recent {
289+
if previdx != myidx {
290+
return nil, errNotPinned
291+
}
292+
// ip pinned to this proxy
293+
return h.dialAlways(pro, network, laddr, raddr)
294+
}
295+
296+
// wait only if exit was used
297+
if !remoteOnly {
298+
select {
299+
case <-ctx.Done():
300+
return nil, ctx.Err()
301+
case <-time.After(shortdelay * myidx): // 100ms
302+
}
303+
}
304+
return h.dialIfHealthy(pro, network, laddr, raddr)
305305
},
306306
)
307307

0 commit comments

Comments
 (0)