1
1
import _ from 'lodash' ;
2
- import * as os from 'os' ;
3
2
import { DeviceClient } from '@devicefarmer/adbkit' ;
4
3
5
4
import { Interceptor } from '..' ;
@@ -24,6 +23,7 @@ import {
24
23
} from './adb-commands' ;
25
24
import { streamLatestApk , clearAllApks } from './fetch-apk' ;
26
25
import { parseCert , getCertificateFingerprint , getCertificateSubjectHash } from '../../certificates' ;
26
+ import { getReachableInterfaces } from '../../util/network' ;
27
27
28
28
function urlSafeBase64 ( content : string ) {
29
29
return Buffer . from ( content , 'utf8' ) . toString ( 'base64' )
@@ -98,17 +98,9 @@ export class AndroidAdbInterceptor implements Interceptor {
98
98
'10.0.3.2' , // Genymotion localhost ip
99
99
] . concat (
100
100
// Every other external network ip
101
- _ . flatMap ( os . networkInterfaces ( ) , ( addresses , iface ) =>
102
- ( addresses || [ ] )
103
- . filter ( a =>
104
- ! a . internal && // Loopback interfaces
105
- a . family === "IPv4" && // Android VPN app supports IPv4 only
106
- iface !== 'docker0' && // Docker default bridge interface
107
- ! iface . startsWith ( 'br-' ) && // More docker bridge interfaces
108
- ! iface . startsWith ( 'veth' ) // Virtual interfaces for each docker container
109
- )
110
- . map ( a => a . address )
111
- )
101
+ getReachableInterfaces ( ) . filter ( a =>
102
+ a . family === "IPv4" // Android VPN app supports IPv4 only
103
+ ) . map ( a => a . address )
112
104
) ,
113
105
port : proxyPort ,
114
106
localTunnelPort : proxyPort ,
0 commit comments