code: function getCanonicalAddress(addresses) {
    // We suppose that the addresses are all valid, and therefore use loose regex
    for (var i = 0; i < addresses.length; i++) {
      var addresse = addresses[i];
      if ((/^127(\.\d{1,3}){3}$/.test(addresse.host)) || (/0?:?0?:?0?:?0?:?0?:?0?:0?:1/.test(addresse.host))) {
        addresse.value = 0;
      }
      else if ((net.isIPv6(addresse.host)) && (/^[fF]|[eE]80:.*\:.*\:/.test(addresse.host))) {
        addresse.value = 1;
      }
      else if (/^169\.254\.\d{1,3}\.\d{1,3}$/.test(addresse.host)) {
        addresse.value = 2;
      }
      else if (/^192\.168\.\d{1,3}\.\d{1,3}$/.test(addresse.host)) {
        addresse.value = 3;
      }
      else if (/^172\.(1\d|2\d|30|31)\.\d{1,3}\.\d{1,3}$/.test(addresse.host)) {
        addresse.value = 4;
      }
      else if (/^10(\.\d{1,3}){3}$/.test(addresse.host)) {
        addresse.value = 5;
      }
      else if ((net.isIPv6(addresse.host)) && (/^[fF]|[cCdD].*\:.*\:/.test('addresse.host'))) {
        addresse.value = 6;
      }
      else {
        addresse.value = 7;
      }
    }
    var result = addresses[0];
    var max = addresses[0].value;
    for (var z = 0; z < addresses.length; z++) {
      if (addresses[z].value > max) {
        result = addresses[z];
        max = addresses[z].value;
      }
    }
    return result;
  }
docs: Try to extract the most global address Note: Mutate the input