Get the active tunnels for a local forwarding listener.

@param addressToBind
@param portToBind
@return ActiveTunnel[]
@throws IOException
359469
public ActiveTunnel[] getLocalForwardingTunnels(String addressToBind,
			int portToBind) throws IOException {
		return getLocalForwardingTunnels(generateKey(addressToBind, portToBind));
	}
1066443
public final List<SIDestinationAddress> getReverseRoutingPath() {
        List<String> fNames = (List<String>) getHdr2().getField(JsHdr2Access.REVERSEROUTINGPATH_DESTINATIONNAME);
        List<byte[]> fMEs = (List<byte[]>) getHdr2().getField(JsHdr2Access.REVERSEROUTINGPATH_MEID);
        byte[] fLos = (byte[]) getHdr2().getField(JsHdr2Access.REVERSEROUTINGPATHLOCALONLY);
        List<String> fBuses = (List<String>) getHdr2().getField(JsHdr2Access.REVERSEROUTINGPATH_BUSNAME);
        return new RoutingPathList(fNames, fLos, fMEs, fBuses);
    }
99484
public ActiveTunnel[] getX11ForwardingTunnels() throws IOException {
		if (incomingtunnels.containsKey(X11_KEY)) {
			Vector<ActiveTunnel> v = incomingtunnels.get(X11_KEY);
			ActiveTunnel[] t = new ActiveTunnel[v.size()];
			v.copyInto(t);

			return t;
		}
		return new ActiveTunnel[] {};
	}
1046637
@Override
   public String[] getServers() {
      Collection<SocketAddress> addresses = channelFactory.getServers();
      return addresses.stream().map(SocketAddress::toString).toArray(String[]::new);
   }
213379
public static String[] getByInternalAPI() {
        try {
            Class<?> resolverConfiguration =
                    Class.forName("sun.net.dns.ResolverConfiguration");
            Method open = resolverConfiguration.getMethod("open");
            Method getNameservers = resolverConfiguration.getMethod("nameservers");
            Object instance = open.invoke(null);
            List nameservers = (List) getNameservers.invoke(instance);
            if (nameservers == null || nameservers.size() == 0) {
                return null;
            }
            String[] ret = new String[nameservers.size()];
            int i = 0;
            for (Object dns : nameservers) {
                ret[i++] = (String) dns;
            }
            return ret;
        } catch (Exception e) {
            // we might trigger some problems this way
            e.printStackTrace();
        }
        return null;
    }
293493
function getBroadcastAddresses() {
    // enumerate interfaces
    var net = os.networkInterfaces();
    var broadcastAddresses = Object.keys(net)
        // flatten the array structure
        .map(function (k) { return net[k]; })
        .reduce(function (prev, cur) { return prev.concat.apply(prev, cur); }, [])
        // only use external IPv4 ones
        .filter(function (add) { return !add.internal && add.family === "IPv4"; })
        // extract address and subnet as number array
        .map(function (k) { return ({
        address: k.address.split(".").map(function (num) { return +num; }),
        netmask: k.netmask.split(".").map(function (num) { return +num; }),
    }); })
        // broadcast is address OR (not netmask)
        .map(function (add) {
        return add.address.map(function (val, i) { return (val | ~add.netmask[i]) & 0xff; });
    })
        // ignore unconnected ones
        .filter(function (add) { return add[0] !== 169; })
        // turn the address into a string again
        .map(function (a) { return a[0] + "." + a[1] + "." + a[2] + "." + a[3]; });
    return broadcastAddresses;
}
1239431
def _get_binding_keys(self, port, host):
        """"""
        binding_keys = list()
        switch_binding = port[portbindings.PROFILE].get(
            'local_link_information', None)
        if switch_binding:
            for binding in switch_binding:
                switch_id = binding.get('switch_id')
                port_id = binding.get('port_id')
                binding_keys.append((port['id'], (switch_id, port_id)))
        else:
            binding_keys.append((port['id'], host))
        return binding_keys
869917
public List<HostAddress> connectedHosts() {
    List<HostAddress> usedHost = new ArrayList<>();

    if (isMasterHostFail()) {
      Protocol masterProtocol = waitNewMasterProtocol.get();
      if (masterProtocol != null) {
        usedHost.add(masterProtocol.getHostAddress());
      }
    } else {
      usedHost.add(masterProtocol.getHostAddress());
    }

    if (isSecondaryHostFail()) {
      Protocol secondProtocol = waitNewSecondaryProtocol.get();
      if (secondProtocol != null) {
        usedHost.add(secondProtocol.getHostAddress());
      }
    } else {
      usedHost.add(secondaryProtocol.getHostAddress());
    }

    return usedHost;
  }
405304
public static Set<InetAddress> resolveLocalAddresses() {
        Set<InetAddress> addrs = new HashSet<InetAddress>();
        Enumeration<NetworkInterface> ns = null;
        try {
            ns = NetworkInterface.getNetworkInterfaces();
        } catch (SocketException e) {
            // ignored...
        }
        while (ns != null && ns.hasMoreElements()) {
            NetworkInterface n = ns.nextElement();
            Enumeration<InetAddress> is = n.getInetAddresses();
            while (is.hasMoreElements()) {
                InetAddress i = is.nextElement();
                if (!i.isLoopbackAddress() && !i.isLinkLocalAddress() && !i.isMulticastAddress()
                        && !isSpecialIp(i.getHostAddress())) addrs.add(i);
            }
        }
        return addrs;
    }
276242
public function bindTo($ipToBinp =null){
        switch($this->transportMethod){
            case "stream":
                $this->defaultOptions['stream_context']['socket'] = ['bindto' => $ipToBinp.':0'];
                break;
            case "curl":
                $this->defaultOptions['curl'] = [CURLOPT_INTERFACE => $ipToBinp];
            default:
                break;
        }
        return $this->initClient();
    }
1188403
private String[] queryInternal(Domain domain) throws IOException {
        Record[] records = null;
        if (domain.hostsFirst) {
            String[] ret = hosts.query(domain.domain);
            if (ret != null && ret.length != 0) {
                return ret;
            }
        }
        synchronized (cache) {
            if (Network.isNetworkChanged()) {
                cache.clear();
                synchronized (resolvers) {
                    index = 0;
                }
            } else {
                records = cache.get(domain.domain);
                if (records != null && records.length != 0) {
                    if (!records[0].isExpired()) {
                        rotate(records);
                        return records2Ip(records);
                    } else {
                        records = null;
                    }
                }
            }
        }

        IOException lastE = null;
        int firstOk = index;
        for (int i = 0; i < resolvers.length; i++) {
            int pos = (firstOk + i) % resolvers.length;
            String ip = Network.getIp();
            try {
                records = resolvers[pos].resolve(domain);
            } catch (DomainNotOwn e) {
                continue;
            } catch (IOException e) {
                lastE = e;
                e.printStackTrace();
            } catch (Exception e) {
                lastE = new IOException(e);
                e.printStackTrace();
            }
            String ip2 = Network.getIp();
            if ((records == null || records.length == 0) && ip.equals(ip2)) {
                synchronized (resolvers) {
                    if (index == firstOk) {
                        index++;
                        if (index == resolvers.length) {
                            index = 0;
                        }
                    }
                }
            } else {
                break;
            }
        }

        if (records == null || records.length == 0) {
            if (!domain.hostsFirst) {
                String[] rs = hosts.query(domain.domain);
                if (rs != null && rs.length != 0) {
                    return rs;
                }
            }
            if (lastE != null) {
                throw lastE;
            }
            throw new UnknownHostException(domain.domain);
        }
        records = trimCname(records);
        if (records.length == 0) {
            throw new UnknownHostException("no A records");
        }
        synchronized (cache) {
            cache.put(domain.domain, records);
        }
        return records2Ip(records);
    }
643542
public IPRangeNode findAddr(InetAddress addr) {

	for (IPRangeNode c: this.list) {

	    IPRangeNode result = c.findAddr(addr);

	    if (result != null) return result;
	}

	return null;
    }
1256189
static InetAddress getNIFirstAddress(int niIndex) throws SocketException {
        if (niIndex > 0) {
            NetworkInterface networkInterface = NetworkInterface.getByIndex(niIndex);
            Enumeration<InetAddress> addressesEnum = networkInterface.getInetAddresses();
            if (addressesEnum.hasMoreElements()) {
                return addressesEnum.nextElement();
            }
        }
        return InetAddress.anyLocalAddress();
    }
1257124
public java.util.List<RouteFilterPrefix> getRequestedAllowedPrefixesToDirectConnectGateway() {
        if (requestedAllowedPrefixesToDirectConnectGateway == null) {
            requestedAllowedPrefixesToDirectConnectGateway = new com.amazonaws.internal.SdkInternalList<RouteFilterPrefix>();
        }
        return requestedAllowedPrefixesToDirectConnectGateway;
    }
365625
private List<ServerAddress> convertToServerAddresses(Set<String> addresses)  {
        return addresses.stream()
                        .map(this::stringToServerAddress)
                        .filter(Objects::nonNull)
                        .collect(Collectors.toList());
    }
1334242
public <T> Link<T> get(final SocketAddress remoteAddr) {
    final LinkReference linkRef = this.addrToLinkRefMap.get(remoteAddr);
    return linkRef != null ? (Link<T>) linkRef.getLink() : null;
  }
137161
public void bindLocal(DatagramChannel channel, int port) throws IOException {
        // select port if wildcarded
        if (port == PORT_ANY) {
            port = localPortManager.next();
        }

        // try bind
        IOException ex = null;
        for (int q = 0; q < 100; q++) {
            try {
                channel.bind(new InetSocketAddress(localBindAddress, port));
                ex = null;
                break;
            } catch (IOException e) {
                ex = e;
                logger.info("Failed trying to bind " + localBindAddress + ":" + port);
                port = localPortManager.next();
            }
        }

        if (ex != null) {
            throw ex;
        }
    }