diff --git a/lib/cli.js b/lib/cli.js index 424b64da..e4ee9b21 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -58,6 +58,8 @@ program , 'ADB port (defaults to 5037)' , Number , 5037) + .option('-R, --allow-remote' + , 'Whether to allow remote devices to be set up') .option('--screen-ws-url-pattern ' , 'screen WebSocket URL pattern' , String @@ -83,6 +85,7 @@ program , filter: function(device) { return serials.length === 0 || serials.indexOf(device.id) !== -1 } + , allowRemote: options.allowRemote , fork: function(device, ports) { var fork = require('child_process').fork return fork(__filename, [ @@ -885,6 +888,8 @@ program , 'ADB port (defaults to 5037)' , Number , 5037) + .option('-R, --allow-remote' + , 'Whether to allow remote devices to be set up') .option('--user-profile-url ' , 'URL to external user profile page' , String) @@ -949,7 +954,9 @@ program , util.format('http://localhost:%d/', options.poorxyPort) , '--adb-host', options.adbHost , '--adb-port', options.adbPort - ].concat(cliutil.allUnknownArgs(args))) + ] + .concat(options.allowRemote ? ['--allow-remote'] : []) + .concat(cliutil.allUnknownArgs(args))) // auth , procutil.fork(__filename, [ diff --git a/lib/units/provider/index.js b/lib/units/provider/index.js index 23261afb..981875a0 100644 --- a/lib/units/provider/index.js +++ b/lib/units/provider/index.js @@ -117,6 +117,12 @@ module.exports = function(options) { return device.id === '????????????' } + // Check whether the device is remote (i.e. if we're connecting to + // an IP address (or hostname) and port pair). + function isRemoteDevice(device) { + return device.id.indexOf(':') !== -1 + } + // Helper for ignoring unwanted devices function filterDevice(listener) { return function(device) { @@ -124,6 +130,13 @@ module.exports = function(options) { log.warn('ADB lists a weird device: "%s"', device.id) return false } + if (!options.allowRemote && isRemoteDevice(device)) { + log.info( + 'Filtered out remote device "%s", use --allow-remote to override' + , device.id + ) + return false + } if (options.filter && !options.filter(device)) { log.info('Filtered out device "%s"', device.id) return false