File tree Expand file tree Collapse file tree 2 files changed +4
-20
lines changed Expand file tree Collapse file tree 2 files changed +4
-20
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {
14
14
launchAndroidHost ,
15
15
setupAndroidHost
16
16
} from './frida-android-integration' ;
17
+ import { combineParallelCalls } from '@httptoolkit/util' ;
17
18
18
19
export class FridaAndroidInterceptor implements Interceptor {
19
20
@@ -26,16 +27,7 @@ export class FridaAndroidInterceptor implements Interceptor {
26
27
private config : HtkConfig
27
28
) { }
28
29
29
- private _fridaTargetsPromise : Promise < Array < FridaHost > > | undefined ;
30
- async getFridaHosts ( ) : Promise < Array < FridaHost > > {
31
- if ( ! this . _fridaTargetsPromise ) {
32
- // We cache the targets lookup whilst it's active, so that concurrent calls
33
- // all just run one lookup and return the same result.
34
- this . _fridaTargetsPromise = getAndroidFridaHosts ( this . adbClient )
35
- . finally ( ( ) => { this . _fridaTargetsPromise = undefined ; } ) ;
36
- }
37
- return await this . _fridaTargetsPromise ;
38
- }
30
+ getFridaHosts = combineParallelCalls ( ( ) => getAndroidFridaHosts ( this . adbClient ) ) ;
39
31
40
32
async isActivable ( ) : Promise < boolean > {
41
33
return ( await this . getFridaHosts ( ) ) . length > 0 ;
Original file line number Diff line number Diff line change 1
1
import _ from 'lodash' ;
2
2
import { UsbmuxClient } from 'usbmux-client' ;
3
3
import * as FridaJs from 'frida-js' ;
4
+ import { combineParallelCalls } from '@httptoolkit/util' ;
4
5
5
6
import { Interceptor } from ".." ;
6
7
import { HtkConfig } from '../../config' ;
@@ -23,16 +24,7 @@ export class FridaIosInterceptor implements Interceptor {
23
24
private config : HtkConfig
24
25
) { }
25
26
26
- private _fridaTargetsPromise : Promise < Array < FridaHost > > | undefined ;
27
- async getFridaHosts ( ) : Promise < Array < FridaHost > > {
28
- if ( ! this . _fridaTargetsPromise ) {
29
- // We cache the targets lookup whilst it's active, so that concurrent calls
30
- // all just run one lookup and return the same result.
31
- this . _fridaTargetsPromise = getIosFridaHosts ( this . usbmuxClient )
32
- . finally ( ( ) => { this . _fridaTargetsPromise = undefined ; } ) ;
33
- }
34
- return await this . _fridaTargetsPromise ;
35
- }
27
+ getFridaHosts = combineParallelCalls ( ( ) => getIosFridaHosts ( this . usbmuxClient ) ) ;
36
28
37
29
async isActivable ( ) : Promise < boolean > {
38
30
return ( await this . getFridaHosts ( ) ) . length > 0 ;
You can’t perform that action at this time.
0 commit comments