Skip to content

Commit 495d501

Browse files
committed
Work around mildly flaky Frida proxy IP testing script
1 parent ae16ec2 commit 495d501

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/interceptors/frida/frida-android-integration.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,10 @@ export async function interceptAndroidFridaTarget(
236236
console.log(`Intercepting ${appId} via Android Frida on ${hostId}...`);
237237
const deviceClient = adbClient.getDevice(hostId);
238238

239-
await createPersistentReverseTunnel(deviceClient, proxyPort, proxyPort)
240-
.catch(() => {}); // If we can't tunnel that's OK - we'll use wifi/etc instead
239+
// We try to tunnel the proxy over ADB, but if we can't then that's OK - we'll use wifi/etc instead
240+
const tunnelCreated = await createPersistentReverseTunnel(deviceClient, proxyPort, proxyPort)
241+
.then(() => true)
242+
.catch(() => false)
241243

242244
const fridaStream = await getFridaStream(hostId, deviceClient);
243245

@@ -255,6 +257,13 @@ export async function interceptAndroidFridaTarget(
255257
'127.0.0.1',
256258
...EMULATOR_HOST_IPS,
257259
]
260+
}).catch((e) => {
261+
console.warn(`Failed to select proxy address for ${appId} on ${hostId}: ${e.message ?? e}`);
262+
263+
// This can be flaky in some weird cases - when all else fails, we always fallback to the
264+
// ADB reverse tunnel if that's available
265+
if (tunnelCreated) return '127.0.0.1'
266+
else throw e;
258267
});
259268

260269
const interceptionScript = await buildAndroidFridaScript(

0 commit comments

Comments
 (0)