Invoke the same-named function on the network resource in WAPI,
 returning an array of available IP addresses.
 You may optionally specify how many IPs you want (num) and which ones to
 exclude from consideration (array of IPv4 address strings).
547521
def next_available_ip(num=1, exclude=[])
      post_body = {
        :num =>     num.to_i,
        :exclude => exclude
      }
      JSON.parse(connection.post(resource_uri + "?_function=next_available_ip", post_body).body)["ips"]
    end
38634
function normalizeNetAddress (array) {
  return array.map(function (options) {
    if (typeof options === 'string') return wrapIPv6Address(options)
    if (typeof options === 'number') return wrapIPv6Address(defaultHost, options)
    options.host = options.host || defaultHost
    options.port = options.port || defaultPort
    return wrapIPv6Address(options.host, options.port)
  })
}
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;
}
1364786
public static ipset_nsip_binding[] get(nitro_service service, String name) throws Exception{
		ipset_nsip_binding obj = new ipset_nsip_binding();
		obj.set_name(name);
		ipset_nsip_binding response[] = (ipset_nsip_binding[]) obj.get_resources(service);
		return response;
	}
1307622
public static Inet6Address getIPv4MappedIPv6Address(Inet4Address ip) {
        byte[] from = ip.getAddress();
        byte[] bytes = new byte[] {
                0x0,0x0,0x0,0x0,
                0x0,0x0,0x0,0x0,
                0x0,0x0,(byte)0xff,(byte)0xff,
                from[0],from[1],from[2],from[3]
        };

        return getInet6Address(bytes);
    }
836477
static String getLocalIPAddress() {
        String ipAddress = "";
        try {
            List<NetworkInterface> netInterfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
            for (NetworkInterface netInterface : netInterfaces) {
                List<InetAddress> addresses = Collections.list(netInterface.getInetAddresses());
                for (InetAddress address : addresses) {
                    if (!address.isLoopbackAddress()) {
                        String ip = address.getHostAddress();
                        boolean isIPv4 = ip.indexOf(':') < 0;
                        if (isIPv4) {
                            ipAddress = ip;
                            break;
                        }
                    }
                }
            }
        } catch (Throwable ignore) {
        }

        return ipAddress;
    }
102219
def _check_ip(ip: str) -> bool:
    
    address = ipaddress.IPv4Address(ip)
    return address in allowed_ips
161154
def get_by_ip(cls, ip):
        ''
        ret = cls.hosts_by_ip.get(ip)
        if ret is None:
            ret = cls.hosts_by_ip[ip] = [Host(ip)]
        return ret
9627
function(hostname, callback) {
  get_nodes(function(err,nodes) {
    if (err) return callback(err);

    var n = nodes.filter(function(node) {
      return node.name === hostname;
    });

    callback(null,(n.length === 1) ? n[0].ip_address : null);
  });
}
440357
public static Collection<InetAddress> getAllByName(String host, boolean allowIPv6) {
       Enumeration<NetworkInterface> networkInterfaces = cloneInterfaces(ResolutionUtils.networkInterfaces);
       List<String> resolvedAddresses = resolveDeviceAddress(host, networkInterfaces, allowIPv6);
       List<InetAddress> resolvedDeviceURIs = new ArrayList<>();
       List<InetAddress> resolvedHosts = resolvedDeviceURIs;
       for (String resolvedAddress : resolvedAddresses) {
           try {
               resolvedHosts.addAll(asList(InetAddress.getAllByName(resolvedAddress)));
           } catch (UnknownHostException e) {
               e.printStackTrace();
           }
       }
       return resolvedHosts;
   }
744047
async function ip(options = {}) {
  const {
    host = 'https://api.ipify.org',
  } = options
  const res = await rqt(host)
  return res
}
322970
def get_a(name=None, ipv4addr=None, allow_array=True, **api_opts):
    '''
    
    '''
    data = {}
    if name:
        data['name'] = name
    if ipv4addr:
        data['ipv4addr'] = ipv4addr
    r = get_object('record:a', data=data, **api_opts)
    if r and len(r) > 1 and not allow_array:
        raise Exception('More than one result, use allow_array to return the data')
    return r
915128
def create_api_network_ipv4(self):
        """"""

        return ApiNetworkIPv4(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
946638
def get_by_ip_hostname(self, ip_hostname):
        
        resources = self._client.get_all()

        resources_filtered = [x for x in resources if x['credentials']['ip_hostname'] == ip_hostname]

        if resources_filtered:
            return resources_filtered[0]
        else:
            return None
144903
public static ipv6 get(nitro_service service) throws Exception{
		ipv6 obj = new ipv6();
		ipv6[] response = (ipv6[])obj.get_resources(service);
		return response[0];
	}
873721
public String chooseIP(byte[] key) throws IOException {
        if (_ips == null || _ips.length == 0) {
            if (_server != null) {
                LOG.warn("ip list is not initialized, fallback to server");
                return _server;
            }
            throw new IOException("ip list is not initialized");
        }

        return _ips[Math.abs(Arrays.hashCode(key)) % _ips.length];
    }
584571
public static base_responses enable(nitro_service client, nsip resources[]) throws Exception {
		base_responses result = null;
		if (resources != null && resources.length > 0) {
			nsip enableresources[] = new nsip[resources.length];
			for (int i=0;i<resources.length;i++){
				enableresources[i] = new nsip();
				enableresources[i].ipaddress = resources[i].ipaddress;
				enableresources[i].td = resources[i].td;
			}
			result = perform_operation_bulk_request(client, enableresources,"enable");
		}
		return result;
	}