net/portprober.js
function findUnixPortRange() {
  var cmd;
  if (process.platform === 'sunos') {
    cmd =
        '/usr/sbin/ndd /dev/tcp tcp_smallest_anon_port tcp_largest_anon_port';
  } else if (fs.existsSync('/proc/sys/net/ipv4/ip_local_port_range')) {
    // Linux
    cmd = 'cat /proc/sys/net/ipv4/ip_local_port_range';
  } else {
    cmd = 'sysctl net.inet.ip.portrange.first net.inet.ip.portrange.last' +
        ' | sed -e "s/.*:\\s*//"';
  }

  return execute(cmd).then(function(stdout) {
    if (!stdout || !stdout.length) return DEFAULT_IANA_RANGE;
    var range = stdout.trim().split(/\s+/).map(Number);
    if (range.some(isNaN)) return DEFAULT_IANA_RANGE;
    return {min: range[0], max: range[1]};
  });
}
function findUnixPortRange() {
  var cmd;
  if (process.platform === 'sunos') {
    cmd =
        '/usr/sbin/ndd /dev/tcp tcp_smallest_anon_port tcp_largest_anon_port';
  } else if (fs.existsSync('/proc/sys/net/ipv4/ip_local_port_range')) {
    // Linux
    cmd = 'cat /proc/sys/net/ipv4/ip_local_port_range';
  } else {
    cmd = 'sysctl net.inet.ip.portrange.first net.inet.ip.portrange.last' +
        ' | sed -e "s/.*:\\s*//"';
  }

  return execute(cmd).then(function(stdout) {
    if (!stdout || !stdout.length) return DEFAULT_IANA_RANGE;
    var range = stdout.trim().split(/\s+/).map(Number);
    if (range.some(isNaN)) return DEFAULT_IANA_RANGE;
    return {min: range[0], max: range[1]};
  });
}
function findUnixPortRange ( ) { var cmd ; if ( process . platform === 'sunos' ) { cmd = '/usr/sbin/ndd /dev/tcp tcp_smallest_anon_port tcp_largest_anon_port' ; } else if ( fs . existsSync ( '/proc/sys/net/ipv4/ip_local_port_range' ) ) { // Linux cmd = 'cat /proc/sys/net/ipv4/ip_local_port_range' ; } else { cmd = 'sysctl net.inet.ip.portrange.first net.inet.ip.portrange.last' + ' | sed -e "s/.*:\\s*//"' ; } return execute ( cmd ) . then ( function ( stdout ) { if ( ! stdout || ! stdout . length ) return DEFAULT_IANA_RANGE ; var range = stdout . trim ( ) . split ( / \s+ / ) . map ( Number ) ; if ( range . some ( isNaN ) ) return DEFAULT_IANA_RANGE ; return { min : range [ 0 ] , max : range [ 1 ] } ; } ) ; }
Computes the ephemeral port range for a Unix-like system.
@return {!webdriver.promise.Promise.<{min: number, max: number}>} A promise
that will resolve with the ephemeral port range on the current system.
Computes the ephemeral port range for a Unix - like system .