How to use the netaddr.valid_ipv6 function in netaddr

To help you get started, we’ve selected a few netaddr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github noris-network / koris / koris / cloud / View on Github external
def associate_floating_ip(self, loadbalancer):
        """Associates a Floating IP with the LoadBalancer"""
        valid_ip = valid_ipv4(self.floatingip) or valid_ipv6(self.floatingip)
        if not valid_ip:
            LOGGER.error("'%s' is not a valid IP address", self.floatingip)
        if self._existing_floating_ip == self.floatingip:
            return self._existing_floating_ip

        fip =
        # Assign IP to LB
            fip =, port_id=loadbalancer.vip_port_id)
        except OSNotFound:
            LOGGER.error("The resource {} cannot be associated".format(self.floatingip))

        LOGGER.success("Loadbalancer external IP: %s",
github silverwind / cidr-tools / legacy / View on Github external
def netlist(nets):
  v4nets = []
  v6nets = []
  for net in nets:
    ipNetwork = netaddr.IPNetwork(net)
    parts = str(ipNetwork).split("/")
    ip = parts[0]
    mask = parts[1]
    if netaddr.valid_ipv4(ip) and int(mask) <= 32:
    elif netaddr.valid_ipv6(ip) and int(mask) <= 128:
  return v4nets, v6nets
github zdresearch / OWASP-Honeypot / core / View on Github external
pull_object = select.poll()
    pull_object.register(process.stdout, select.POLLIN)
    # while True, read tshark output
        while True:
            if pull_object.poll(0):
                line = process.stdout.readline()
                # check if new IP and Port printed
                if len(line) > 0:
                    # split the IP and Port
                        ip, port = str(line.rsplit()[0].decode()), int(line.rsplit()[1])
                    except Exception as _:
                        ip, port = None, None
                    # check if event shows an IP
                    if (netaddr.valid_ipv4(ip) or netaddr.valid_ipv6(ip)) \
                            and ip not in ignore_ip_addresses \
                            and port not in ignore_ports:  # ignored ip addresses and ports in python - fix later
                        # check if the port is in selected module
                        if port in honeypot_ports:
github openstack / neutron / neutron / agent / linux / View on Github external
def _format_address_for_dnsmasq(address):
        # (dzyu) Check if it is legal ipv6 address, if so, need wrap
        # it with '[]' to let dnsmasq to distinguish MAC address from
        # IPv6 address.
        if netaddr.valid_ipv6(address):
            return '[%s]' % address
        return address
github mozilla / MozDef / cron / View on Github external
def isIPv6(ip):
        return netaddr.valid_ipv6(ip)
        return False
github openstack / python-tripleoclient / tripleoclient / View on Github external
def is_valid_ip(ip):
    """Return True if the IP is either v4 or v6

    Return False if invalid.
    return netaddr.valid_ipv4(ip) or netaddr.valid_ipv6(ip)
github smicallef / spiderfoot / View on Github external
def validIP6(self, address):
        return netaddr.valid_ipv6(address)
github openstack / tacker / tacker / vnfm / monitor_drivers / http_ping / View on Github external
def _is_pingable(self, mgmt_ip='', retry=5, timeout=5, port=80, **kwargs):
        """Checks whether the server is reachable by using urllib.

        Waits for connectivity for `timeout` seconds,
        and if connection refused, it will retry `retry`
        :param mgmt_ip: IP to check
        :param retry: times to reconnect if connection refused
        :param timeout: seconds to wait for connection
        :param port: port number to check connectivity
        :return: bool - True or False depending on pingability.
        url = 'http://' + mgmt_ip + ':' + str(port)
        if netaddr.valid_ipv6(mgmt_ip):
            url = 'http://[' + mgmt_ip + ']:' + str(port)

        for retry_index in range(int(retry)):
                urlreq.urlopen(url, timeout=timeout)
                return True
            except urlerr.URLError:
                LOG.warning('Unable to reach to the url %s', url)
        return 'failure'
github SUSE / DeepSea / srv / modules / runners / View on Github external
def format_addr(addr):
        Format IP address when used for URLs
        if url:
            if netaddr.valid_ipv6(addr) is True:
                return "[{}]".format(addr)
        return addr