@@ -111,7 +111,7 @@ func (h *auto) DialBind(network, local, remote string) (protect.Conn, error) {
111
111
return h .dial (network , local , remote )
112
112
}
113
113
114
- func (h * auto ) dial (network , local , remote string ) (protect.Conn , error ) {
114
+ func (h * auto ) dial (network , laddr , raddr string ) (protect.Conn , error ) {
115
115
if h .status .Load () == END {
116
116
return nil , errProxyStopped
117
117
}
@@ -140,13 +140,13 @@ func (h *auto) dial(network, local, remote string) (protect.Conn, error) {
140
140
all = []protect.RDialer {pro , warp , amz , sep }
141
141
}
142
142
// TODO: pinning IPs
143
- return dialAny (all , network , local , remote )
143
+ return dialAny (all , network , laddr , raddr )
144
144
}
145
145
146
- previdx , recent := h .exp .Get (remote )
146
+ previdx , recent := h .exp .Get (raddr )
147
147
148
148
c , who , err := core .Race (
149
- network + ".dial-auto." + remote ,
149
+ network + ".dial-auto." + raddr ,
150
150
tlsHandshakeTimeout ,
151
151
func (ctx context.Context ) (protect.Conn , error ) {
152
152
const myidx = 0
@@ -167,9 +167,9 @@ func (h *auto) dial(network, local, remote string) (protect.Conn, error) {
167
167
return nil , errNotPinned
168
168
}
169
169
// ip pinned to this proxy
170
- h .dialIfHealthy (exit , network , local , remote )
170
+ h .dialIfHealthy (exit , network , laddr , raddr )
171
171
}
172
- return h .dialIfReachable (exit , network , local , remote )
172
+ return h .dialIfReachable (exit , network , laddr , raddr )
173
173
}, func (ctx context.Context ) (protect.Conn , error ) {
174
174
const myidx = 1
175
175
if pro == nil {
@@ -180,7 +180,7 @@ func (h *auto) dial(network, local, remote string) (protect.Conn, error) {
180
180
return nil , errNotPinned
181
181
}
182
182
// ip pinned to this proxy
183
- h .dialIfHealthy (pro , network , local , remote )
183
+ h .dialIfHealthy (pro , network , laddr , raddr )
184
184
}
185
185
186
186
// wait only if exit was used
@@ -191,7 +191,7 @@ func (h *auto) dial(network, local, remote string) (protect.Conn, error) {
191
191
case <- time .After (shortdelay * myidx ): // 100ms
192
192
}
193
193
}
194
- return h .dialIfHealthy (pro , network , local , remote )
194
+ return h .dialIfHealthy (pro , network , laddr , raddr )
195
195
}, func (ctx context.Context ) (protect.Conn , error ) {
196
196
const myidx = 2
197
197
if warp == nil {
@@ -202,15 +202,15 @@ func (h *auto) dial(network, local, remote string) (protect.Conn, error) {
202
202
return nil , errNotPinned
203
203
}
204
204
// ip pinned to this proxy
205
- return h .dialIfHealthy (warp , network , local , remote )
205
+ return h .dialIfHealthy (warp , network , laddr , raddr )
206
206
}
207
207
208
208
select {
209
209
case <- ctx .Done ():
210
210
return nil , ctx .Err ()
211
211
case <- time .After (shortdelay * myidx ): // 200ms
212
212
}
213
- return h .dialIfHealthy (warp , network , local , remote )
213
+ return h .dialIfHealthy (warp , network , laddr , raddr )
214
214
}, func (ctx context.Context ) (protect.Conn , error ) {
215
215
const myidx = 3
216
216
if exit64 == nil {
@@ -224,15 +224,15 @@ func (h *auto) dial(network, local, remote string) (protect.Conn, error) {
224
224
return nil , errNotPinned
225
225
}
226
226
// ip pinned to this proxy
227
- return h .dialIfHealthy (exit64 , network , local , remote )
227
+ return h .dialIfHealthy (exit64 , network , laddr , raddr )
228
228
}
229
229
230
230
select {
231
231
case <- ctx .Done ():
232
232
return nil , ctx .Err ()
233
233
case <- time .After (shortdelay * myidx ): // 300ms
234
234
}
235
- return h .dialIfHealthy (exit64 , network , local , remote )
235
+ return h .dialIfHealthy (exit64 , network , laddr , raddr )
236
236
}, func (ctx context.Context ) (protect.Conn , error ) {
237
237
const myidx = 4
238
238
if amz == nil {
@@ -243,15 +243,15 @@ func (h *auto) dial(network, local, remote string) (protect.Conn, error) {
243
243
return nil , errNotPinned
244
244
}
245
245
// ip pinned to this proxy
246
- return h .dialIfHealthy (amz , network , local , remote )
246
+ return h .dialIfHealthy (amz , network , laddr , raddr )
247
247
}
248
248
249
249
select {
250
250
case <- ctx .Done ():
251
251
return nil , ctx .Err ()
252
252
case <- time .After (shortdelay * myidx ): // 400ms
253
253
}
254
- return h .dialIfHealthy (amz , network , local , remote )
254
+ return h .dialIfHealthy (amz , network , laddr , raddr )
255
255
}, func (ctx context.Context ) (protect.Conn , error ) {
256
256
const myidx = 5
257
257
if sep == nil {
@@ -262,27 +262,27 @@ func (h *auto) dial(network, local, remote string) (protect.Conn, error) {
262
262
return nil , errNotPinned
263
263
}
264
264
// ip pinned to this proxy
265
- return h .dialIfHealthy (sep , network , local , remote )
265
+ return h .dialIfHealthy (sep , network , laddr , raddr )
266
266
}
267
267
268
268
select {
269
269
case <- ctx .Done ():
270
270
return nil , ctx .Err ()
271
271
case <- time .After (shortdelay * myidx ): // 500ms
272
272
}
273
- return h .dialIfHealthy (sep , network , local , remote )
273
+ return h .dialIfHealthy (sep , network , laddr , raddr )
274
274
},
275
275
)
276
276
277
277
defer localDialStatus (h .status , err )
278
278
if err != nil {
279
- h .exp .Del (remote )
279
+ h .exp .Del (raddr )
280
280
} else {
281
- h .exp .Put (remote , who )
281
+ h .exp .Put (raddr , who )
282
282
}
283
283
maybeKeepAlive (c )
284
284
logei (err )("proxy: auto: w(%d) pin(%t/%d), dial(%s) %s; err? %v" ,
285
- who , recent , previdx , network , remote , err )
285
+ who , recent , previdx , network , raddr , err )
286
286
return c , err
287
287
}
288
288
0 commit comments