mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +02:00
Ignore remote devices by default, use -R or --allow-remote to override.
This commit is contained in:
parent
a996d97681
commit
55d27364a2
2 changed files with 21 additions and 1 deletions
|
@ -58,6 +58,8 @@ program
|
||||||
, 'ADB port (defaults to 5037)'
|
, 'ADB port (defaults to 5037)'
|
||||||
, Number
|
, Number
|
||||||
, 5037)
|
, 5037)
|
||||||
|
.option('-R, --allow-remote'
|
||||||
|
, 'Whether to allow remote devices to be set up')
|
||||||
.option('--screen-ws-url-pattern <pattern>'
|
.option('--screen-ws-url-pattern <pattern>'
|
||||||
, 'screen WebSocket URL pattern'
|
, 'screen WebSocket URL pattern'
|
||||||
, String
|
, String
|
||||||
|
@ -83,6 +85,7 @@ program
|
||||||
, filter: function(device) {
|
, filter: function(device) {
|
||||||
return serials.length === 0 || serials.indexOf(device.id) !== -1
|
return serials.length === 0 || serials.indexOf(device.id) !== -1
|
||||||
}
|
}
|
||||||
|
, allowRemote: options.allowRemote
|
||||||
, fork: function(device, ports) {
|
, fork: function(device, ports) {
|
||||||
var fork = require('child_process').fork
|
var fork = require('child_process').fork
|
||||||
return fork(__filename, [
|
return fork(__filename, [
|
||||||
|
@ -885,6 +888,8 @@ program
|
||||||
, 'ADB port (defaults to 5037)'
|
, 'ADB port (defaults to 5037)'
|
||||||
, Number
|
, Number
|
||||||
, 5037)
|
, 5037)
|
||||||
|
.option('-R, --allow-remote'
|
||||||
|
, 'Whether to allow remote devices to be set up')
|
||||||
.option('--user-profile-url <url>'
|
.option('--user-profile-url <url>'
|
||||||
, 'URL to external user profile page'
|
, 'URL to external user profile page'
|
||||||
, String)
|
, String)
|
||||||
|
@ -949,7 +954,9 @@ program
|
||||||
, util.format('http://localhost:%d/', options.poorxyPort)
|
, util.format('http://localhost:%d/', options.poorxyPort)
|
||||||
, '--adb-host', options.adbHost
|
, '--adb-host', options.adbHost
|
||||||
, '--adb-port', options.adbPort
|
, '--adb-port', options.adbPort
|
||||||
].concat(cliutil.allUnknownArgs(args)))
|
]
|
||||||
|
.concat(options.allowRemote ? ['--allow-remote'] : [])
|
||||||
|
.concat(cliutil.allUnknownArgs(args)))
|
||||||
|
|
||||||
// auth
|
// auth
|
||||||
, procutil.fork(__filename, [
|
, procutil.fork(__filename, [
|
||||||
|
|
|
@ -117,6 +117,12 @@ module.exports = function(options) {
|
||||||
return device.id === '????????????'
|
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
|
// Helper for ignoring unwanted devices
|
||||||
function filterDevice(listener) {
|
function filterDevice(listener) {
|
||||||
return function(device) {
|
return function(device) {
|
||||||
|
@ -124,6 +130,13 @@ module.exports = function(options) {
|
||||||
log.warn('ADB lists a weird device: "%s"', device.id)
|
log.warn('ADB lists a weird device: "%s"', device.id)
|
||||||
return false
|
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)) {
|
if (options.filter && !options.filter(device)) {
|
||||||
log.info('Filtered out device "%s"', device.id)
|
log.info('Filtered out device "%s"', device.id)
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue