@@ -43,8 +43,10 @@ export function tunnel(options: Record<string, string | number | null> = {}): {
4343 let url_rejector : ( reason : unknown ) => void = ( ) => undefined ;
4444 const url = new Promise < string > ( ( ...pair ) => ( [ url_resolver , url_rejector ] = pair ) ) ;
4545
46- const connection_regex =
47- / C o n n e c t i o n ( [ a - z 0 - 9 - ] + ) (?: .* ?) c o n n I n d e x = ( \d ) i p = ( [ 0 - 9 . ] + ) l o c a t i o n = ( [ A - Z ] + ) / ;
46+ const conn_regex = / c o n n e c t i o n [ = ] ( [ a - z 0 - 9 - ] + ) / i;
47+ const ip_regex = / i p = ( [ 0 - 9 . ] + ) / ;
48+ const location_regex = / l o c a t i o n = ( [ A - Z ] + ) / ;
49+ const index_regex = / c o n n I n d e x = ( \d ) / ;
4850 const connection_resolvers : ( ( value : Connection | PromiseLike < Connection > ) => void ) [ ] = [ ] ;
4951 const connection_rejectors : ( ( reason : unknown ) => void ) [ ] = [ ] ;
5052 const connections : Promise < Connection > [ ] = [ ] ;
@@ -62,10 +64,16 @@ export function tunnel(options: Record<string, string | number | null> = {}): {
6264 const url_match = str . match ( url_regex ) ;
6365 url_match && url_resolver ( url_match [ 1 ] ) ;
6466
65- const connection_match = str . match ( connection_regex ) ;
66- if ( connection_match ) {
67- const [ , id , idx , ip , location ] = connection_match ;
68- connection_resolvers [ + idx ] ( { id, ip, location } ) ;
67+ const conn_match = str . match ( conn_regex ) ;
68+ const ip_match = str . match ( ip_regex ) ;
69+ const location_match = str . match ( location_regex ) ;
70+ const index_match = str . match ( index_regex ) ;
71+ if ( conn_match && ip_match && location_match && index_match ) {
72+ const [ , id ] = conn_match ;
73+ const [ , ip ] = ip_match ;
74+ const [ , location ] = location_match ;
75+ const [ , idx ] = index_match ;
76+ connection_resolvers [ + idx ] ?.( { id, ip, location } ) ;
6977 }
7078 } ;
7179 child . stdout . on ( "data" , parser ) . on ( "error" , url_rejector ) ;
0 commit comments