File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -277,23 +277,23 @@ export default function ({ app, mesh }) {
277277 . onStart ( ( ) =>
278278 ( ( i . exits && i . exits . length > 0 )
279279 ? Promise . resolve ( i . exits )
280- : mesh . discover ( ) . then ( list => list . map ( ep => ep . id ) )
281- ) . then ( exits => Promise . all (
280+ : mesh . discover ( ) . then ( list => list . filter ( ep => ep . online ) . map ( ep => ep . id ) )
281+ ) . then ( exits => Promise . any (
282282 exits . map (
283283 id => getOutbound ( id , protocol , name ) . then (
284- o => o ? { ep : id , ...o } : null
285- ) . catch ( ( ) => null )
284+ o => {
285+ if ( ! o ) throw null
286+ if ( ! canAccess ( o , app . endpoint . id , app . username ) ) throw null
287+ return id
288+ }
289+ )
286290 )
287- ) ) . then ( list => {
288- var ep = app . endpoint . id
289- var user = app . username
290- list = list . filter ( o => ( o && canAccess ( o , ep , user ) ) )
291- if ( list . length > 0 ) {
292- $selectedEP = list [ Math . floor ( Math . random ( ) * list . length ) ] . ep
293- app . log ( `Connect to ep ${ $selectedEP } for ${ protocol } /${ name } ` )
294- } else {
295- app . log ( `No exit found for ${ protocol } /${ name } ` )
296- }
291+ ) ) . then ( exit => {
292+ $selectedEP = exit
293+ app . log ( `Connect to ep ${ $selectedEP } for ${ protocol } /${ name } ` )
294+ return new Data
295+ } ) . catch ( ( ) => {
296+ app . log ( `No exit found for ${ protocol } /${ name } ` )
297297 return new Data
298298 } )
299299 )
You can’t perform that action at this time.
0 commit comments