Get the destination address of a (possibly relay) multiaddr as a string

@param {Multiaddr} addr
@returns {String}
349449
function getDestination (addr) {
  const protos = addr.protoNames().reverse()
  const splitProto = protos.find(p => RelayProtos.includes(p))
  addr = addr.toString()
  if (!splitProto) return addr
  return addr.slice(addr.lastIndexOf(splitProto) + splitProto.length)
}
777389
function getB58String (peer) {
    let b58Id = null
    if (multiaddr.isMultiaddr(peer)) {
      const relayMa = multiaddr(peer)
      b58Id = relayMa.getPeerId()
    } else if (PeerInfo.isPeerInfo(peer)) {
      b58Id = peer.id.toB58String()
    }

    return b58Id
  }
1170305
public static String getRemoteAddress() {
    InetAddress addr = getRemoteIp();
    return (addr == null) ? null : addr.getHostAddress();
  }
1325170
function createChannel(addr) {
  return amqp.connect(genAddr(addr)).then(conn => {
    return conn.createChannel().then(ch => {
      connections.push(conn);

      return [conn, ch];
    });
  }, debugError);
}
513863
public Location getLocation(String str) {
        InetAddress addr;
        try {
            addr = InetAddress.getByName(str);
        } catch (UnknownHostException e) {
            return null;
        }

        return getLocation(addr);
    }
351929
def get_by_addr(self, address):
        
        addr = address
        if isinstance(address, str) and len(address) == 34:
            addr = Helper.AddrStrToScriptHash(address)

        if not isinstance(addr, UInt160):
            raise Exception("Incorrect address format")

        addrlist_snapshot = self.db.prefixed_db(NotificationPrefix.PREFIX_ADDR).snapshot()
        results = []

        for val in addrlist_snapshot.iterator(prefix=bytes(addr.Data), include_key=False):
            if len(val) > 4:
                try:
                    event = SmartContractEvent.FromByteArray(val)
                    results.append(event)
                except Exception as e:
                    logger.error("could not parse event: %s %s" % (e, val))
        return results
840592
function  WriteIpAddr (buffer, offset, ipstring) {
    var addr= ipstring.split('.');
    buffer.writeUInt8(parseInt(addr[3]), offset);
    buffer.writeUInt8(parseInt(addr[2]), offset + 1);
    buffer.writeUInt8(parseInt(addr[1]), offset + 2);
    buffer.writeUInt8(parseInt(addr[0]), offset + 3);
}
1035937
def address(addr):
    

    if ':' in addr:
        # Using rpartition here means we should be able to support
        # IPv6, but only with a strict syntax
        host, _sep, port = addr.rpartition(':')

        # Convert the port to a number
        try:
            port = int(port)
        except ValueError:
            raise ValueError("invalid port number %r" % port)

        addr = (host, port)

    return addr
16864
function getSocketAddressFromURLSafeHostname(hostname) {
    return __awaiter(this, void 0, void 0, function* () {
        // IPv4 addresses are fine
        if (net_1.isIPv4(hostname))
            return hostname;
        // IPv6 addresses are wrapped in [], which need to be removed
        if (/^\[.+\]$/.test(hostname)) {
            const potentialIPv6 = hostname.slice(1, -1);
            if (net_1.isIPv6(potentialIPv6))
                return potentialIPv6;
        }
        // This is a hostname, look it up
        try {
            const address = yield lookupAsync(hostname);
            // We found an address
            if (address)
                return address;
        }
        catch (e) {
            // Lookup failed, continue working with the hostname
        }
        return hostname;
    });
}
1116794
function bl_addr() {
    var normal = sint(0, 22, 1); // un-split address
    return function(value, labels) {
      var v = normal(value, labels);
      return ((v>>11)&0x7FF)<<16 | (v&0x7FF);
    };
  }
1209336
function getAddress(loopback, opt_family) {
  var family = opt_family || 'IPv4';
  var addresses = [];

  var interfaces;
  if (loopback) {
    var lo = getLoInterface();
    interfaces = lo ? [lo] : null;
  }
  interfaces = interfaces || os.networkInterfaces();
  for (var key in interfaces) {
    interfaces[key].forEach(function(ipAddress) {
      if (ipAddress.family === family &&
          ipAddress.internal === loopback) {
        addresses.push(ipAddress.address);
      }
    });
  }
  return addresses[0];
}
537191
public static InetAddress getByAddress(String host, byte[] addr, int scopeId)
        throws UnknownHostException {
        if (host != null && host.length() > 0 && host.charAt(0) == '[') {
            if (host.charAt(host.length()-1) == ']') {
                host = host.substring(1, host.length() -1);
            }
        }
        if (addr != null) {
            if (addr.length == Inet4Address.INADDRSZ) {
                return new Inet4Address(host, addr);
            } else if (addr.length == Inet6Address.INADDRSZ) {
                byte[] newAddr
                    = IPAddressUtil.convertFromIPv4MappedAddress(addr);
                if (newAddr != null) {
                    return new Inet4Address(host, newAddr);
                } else {
                    return new Inet6Address(host, addr, scopeId);
                }
            }
        }
        throw new UnknownHostException("addr is of illegal length");
    }
1112427
function ourAddresses (peerInfo) {
  const ourPeerId = peerInfo.id.toB58String()
  return peerInfo.multiaddrs.toArray()
    .reduce((ourAddrs, addr) => {
      const peerId = addr.getPeerId()
      addr = addr.toString()
      const otherAddr = peerId
        ? addr.slice(0, addr.lastIndexOf(`/ipfs/${peerId}`))
        : `${addr}/ipfs/${ourPeerId}`
      return ourAddrs.concat([addr, otherAddr])
    }, [])
    .filter(a => Boolean(a))
    .concat(`/ipfs/${ourPeerId}`)
}
568547
public static boolean isLocalAddress(final InetAddress addr)
	{
		if (addr.isLoopbackAddress())
		{
			return true;
		}

		try
		{
			Enumeration<NetworkInterface> nics = NetworkInterface.getNetworkInterfaces();

			while (nics.hasMoreElements())
			{
				Enumeration<InetAddress> addrs = nics.nextElement().getInetAddresses();

				while (addrs.hasMoreElements())
				{
					if (addrs.nextElement().equals(addr))
					{
						return true; // Search successful
					}
				}
			}
		}
		catch (SocketException e)
		{
			log.debug(e.getMessage(), e);
		}

		log.debug("[FileHelper] {isLocalAddress} not local: " + addr.getHostAddress());

		// Search failed
		return false;
	}
920021
function obsAngleAddr() {
        return opts.strict ? null : wrap('obs-angle-addr', and(
            invis(opt(cfws)),
            literal('<'),
            obsRoute,
            addrSpec,
            literal('>'),
            invis(opt(cfws))
        )());
    }
212523
public static InetAddress
    getByAddress(String addr) throws UnknownHostException {
        byte[] bytes;
        bytes = toByteArray(addr, IPv4);
        if (bytes != null)
            return InetAddress.getByAddress(bytes);
        bytes = toByteArray(addr, IPv6);
        if (bytes != null)
            return InetAddress.getByAddress(bytes);
        throw new UnknownHostException("Invalid address: " + addr);
    }
913715
def my_address_string(self):
        
        addr = getattr(self, 'client_address', ('', None))[0]

        # If listed in proxy_ips, use the X-Forwarded-For header, if present.
        if addr in self.proxy_ips:
            return self.headers.getheader('x-forwarded-for', addr)
        return addr