ifconfig.js
function parse_status_block(block) {
  var match;

  var parsed = {
    interface: block.match(/^([^\s]+)/)[1]
  };

  if ((match = block.match(/Link encap:\s*([^\s]+)/))) {
    parsed.link = match[1].toLowerCase();
  }

  if ((match = block.match(/HWaddr\s+([^\s]+)/))) {
    parsed.address = match[1].toLowerCase();
  }

  if ((match = block.match(/inet6\s+addr:\s*([^\s]+)/))) {
    parsed.ipv6_address = match[1];
  }

  if ((match = block.match(/inet\s+addr:\s*([^\s]+)/))) {
    parsed.ipv4_address = match[1];
  }

  if ((match = block.match(/Bcast:\s*([^\s]+)/))) {
    parsed.ipv4_broadcast = match[1];
  }

  if ((match = block.match(/Mask:\s*([^\s]+)/))) {
    parsed.ipv4_subnet_mask = match[1];
  }

  if ((match = block.match(/UP/))) {
    parsed.up = true;
  }

  if ((match = block.match(/BROADCAST/))) {
    parsed.broadcast = true;
  }

  if ((match = block.match(/RUNNING/))) {
    parsed.running = true;
  }

  if ((match = block.match(/MULTICAST/))) {
    parsed.multicast = true;
  }

  if ((match = block.match(/LOOPBACK/))) {
    parsed.loopback = true;
  }

  return parsed;
}
function parse_status_block(block) {
  var match;

  var parsed = {
    interface: block.match(/^([^\s]+)/)[1]
  };

  if ((match = block.match(/Link encap:\s*([^\s]+)/))) {
    parsed.link = match[1].toLowerCase();
  }

  if ((match = block.match(/HWaddr\s+([^\s]+)/))) {
    parsed.address = match[1].toLowerCase();
  }

  if ((match = block.match(/inet6\s+addr:\s*([^\s]+)/))) {
    parsed.ipv6_address = match[1];
  }

  if ((match = block.match(/inet\s+addr:\s*([^\s]+)/))) {
    parsed.ipv4_address = match[1];
  }

  if ((match = block.match(/Bcast:\s*([^\s]+)/))) {
    parsed.ipv4_broadcast = match[1];
  }

  if ((match = block.match(/Mask:\s*([^\s]+)/))) {
    parsed.ipv4_subnet_mask = match[1];
  }

  if ((match = block.match(/UP/))) {
    parsed.up = true;
  }

  if ((match = block.match(/BROADCAST/))) {
    parsed.broadcast = true;
  }

  if ((match = block.match(/RUNNING/))) {
    parsed.running = true;
  }

  if ((match = block.match(/MULTICAST/))) {
    parsed.multicast = true;
  }

  if ((match = block.match(/LOOPBACK/))) {
    parsed.loopback = true;
  }

  return parsed;
}
function parse_status_block ( block ) { var match ; var parsed = { interface : block . match ( / ^([^\s]+) / ) [ 1 ] } ; if ( ( match = block . match ( / Link encap:\s*([^\s]+) / ) ) ) { parsed . link = match [ 1 ] . toLowerCase ( ) ; } if ( ( match = block . match ( / HWaddr\s+([^\s]+) / ) ) ) { parsed . address = match [ 1 ] . toLowerCase ( ) ; } if ( ( match = block . match ( / inet6\s+addr:\s*([^\s]+) / ) ) ) { parsed . ipv6_address = match [ 1 ] ; } if ( ( match = block . match ( / inet\s+addr:\s*([^\s]+) / ) ) ) { parsed . ipv4_address = match [ 1 ] ; } if ( ( match = block . match ( / Bcast:\s*([^\s]+) / ) ) ) { parsed . ipv4_broadcast = match [ 1 ] ; } if ( ( match = block . match ( / Mask:\s*([^\s]+) / ) ) ) { parsed . ipv4_subnet_mask = match [ 1 ] ; } if ( ( match = block . match ( / UP / ) ) ) { parsed . up = true ; } if ( ( match = block . match ( / BROADCAST / ) ) ) { parsed . broadcast = true ; } if ( ( match = block . match ( / RUNNING / ) ) ) { parsed . running = true ; } if ( ( match = block . match ( / MULTICAST / ) ) ) { parsed . multicast = true ; } if ( ( match = block . match ( / LOOPBACK / ) ) ) { parsed . loopback = true ; } return parsed ; }
Parses the status for a single network interface.

@private
@static
@category ifconfig
@param {string} block The section of stdout for the interface.
@returns {object} The parsed network interface status.
Parses the status for a single network interface .