@param string $ip6

@return string
422890
public static function ip6($ip6)
    {
        if (false === filter_var($ip6, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
            throw new InputValidationException('invalid "ip6"');
        }

        // normalize the IPv6 address
        return inet_ntop(inet_pton($ip6));
    }
1295561
public static function serializeIPv6($address)
    {
        $output = inet_ntop(call_user_func_array('pack', array_merge(['n*'], $address)));
        return strpos($output, '.') !== false
            ? '::ffff:' . strtolower(dechex($address[6]) . ':' . dechex($address[7]))
            : $output;
    }
1134446
def _explode_shorthand_ip_string(self):
        
        if isinstance(self, IPv6Network):
            ip_str = str(self.network_address)
        elif isinstance(self, IPv6Interface):
            ip_str = str(self.ip)
        else:
            ip_str = str(self)

        ip_int = self._ip_int_from_string(ip_str)
        hex_str = '%032x' % ip_int
        parts = [hex_str[x:x+4] for x in range(0, 32, 4)]
        if isinstance(self, (_BaseNetwork, IPv6Interface)):
            return '%s/%d' % (':'.join(parts), self._prefixlen)
        return ':'.join(parts)
584847
public function getHostsForIp($ip)
    {
        // check binary representation of IP to avoid string case and short notation
        $ip = @inet_pton($ip);
        if ($ip === false) {
            return array();
        }

        $names = array();
        foreach (preg_split('/\r?\n/', $this->contents) as $line) {
            $parts = preg_split('/\s+/', $line, null, PREG_SPLIT_NO_EMPTY);
            $addr = array_shift($parts);

            // remove IPv6 zone ID (`fe80::1%lo0` => `fe80:1`)
            if (strpos($addr, ':') !== false && ($pos = strpos($addr, '%')) !== false) {
                $addr = substr($addr, 0, $pos);
            }

            if (@inet_pton($addr) === $ip) {
                foreach ($parts as $part) {
                    $names[] = $part;
                }
            }
        }

        return $names;
    }
271630
public static function reverseIpv4(string $ip): string
    {
        $octets = array_reverse(explode('.', $ip));

        return implode('.', $octets).'.in-addr.arpa.';
    }
1353065
def list_cidr_ips_ipv6(cidr):
    '''
    
    '''
    ips = netaddr.IPNetwork(cidr)
    return [six.text_type(ip.ipv6()) for ip in list(ips)]
453298
public static function ipToNetAddress($ip)
	{
		$parts = explode('.', $ip);
		$address = '1#';

		foreach ($parts as $int)
		{
			$tmp = dechex($int);

			if (strlen($tmp) != 2)
			{
				$tmp = '0' . $tmp;
			}

			$address .= '\\' . $tmp;
		}

		return $address;
	}
788005
public static function IPv6Bin2Hex($bin) {
			// use PHP-function if PHP was compiled with IPv6-support
		if (defined('AF_INET6')) {
			$hex = inet_ntop($bin);
		} else {
			$hex = unpack("H*" , $bin);
			$hex = chunk_split($hex[1], 4, ':');
				// strip last colon (from chunk_split)
			$hex = substr($hex, 0, -1);
				// IPv6 is now in normalized form
				// compress it for easier handling and to match result from inet_ntop()
			$hex = self::compressIPv6($hex);
		}
		return $hex;

	}
265649
public function getName(): string
    {
        $string = $this->getStringUri();
        if ($this->isSecure()) {
            $string .= ' (TLS)';
        }
        $string .= ' DC ';
        $string .= $this->getDc();
        $string .= ', via ';
        $string .= $this->getIpv6() ? 'ipv6' : 'ipv4';
        $string .= ' using ';
        foreach (array_reverse($this->nextStreams) as $k => $stream) {
            if ($k) {
                $string .= ' => ';
            }
            $string .= preg_replace('/.*\\\\/', '', $stream[0]);
            if ($stream[1]) {
                $string .= ' ('.json_encode($stream[1]).')';
            }
        }

        return $string;
    }
1164245
public function getIpv4Attribute() : ?string
    {
        $ip = $this->getAttributeFromArray('user_ipv4');

        return $ip !== null ? long2ip($ip) : null;
    }
261216
private function cidr6Match($ip, $range) {
        // Split CIDR on /
        list($subnet, $mask) = explode('/', $range);

        // Convert IP's to their in_addr representations
        $ip = inet_pton($ip);
        $subnet = inet_pton($subnet);

        // Convert the mask
        $mask = $this->getBinaryMask((int) $mask);

        return ($ip & $mask) === $subnet;
    }
230076
public static function compressIPv6($address) {
			// use PHP-function if PHP was compiled with IPv6-support
		if (defined('AF_INET6')) {
			$bin = inet_pton($address);
			$address = inet_ntop($bin);
		} else {
			$address = self::normalizeIPv6($address);

				// append one colon for easier handling
				// will be removed later
			$address .= ':';

				// according to IPv6-notation the longest match
				// of a package of '0000:' may be replaced with ':'
				// (resulting in something like '1234::abcd')
			for ($counter = 8; $counter > 1; $counter--) {
				$search = str_repeat('0000:', $counter);
				if (($pos = strpos($address, $search)) !== FALSE) {
					$address = substr($address, 0, $pos) . ':' . substr($address, $pos + ($counter*5));
					break;
				}
			}

				// up to 3 zeros in the first part may be removed
			$address = preg_replace('/^0{1,3}/', '', $address);
				// up to 3 zeros at the beginning of other parts may be removed
			$address = preg_replace('/:0{1,3}/', ':', $address);

				// strip last colon (from chunk_split)
			$address = substr($address, 0, -1);
		}
		return $address;
	}
1096382
protected function resolveIpAddress(): string
    {
        $ipAddressResolver = Config::get('audit.resolver.ip_address');

        if (is_subclass_of($ipAddressResolver, IpAddressResolver::class)) {
            return call_user_func([$ipAddressResolver, 'resolve']);
        }

        throw new AuditingException('Invalid IpAddressResolver implementation');
    }
125372
public static boolean isIPv4orIPv6Address(String _ipAddress) {
        return IPV4_PATTERN.matcher(_ipAddress).matches() || IPV6_PATTERN.matcher(_ipAddress).matches();
    }
1267084
public static function isIpV6Address($value): bool
    {
        if (!static::isStringCastable($value)) {
            return false;
        }

        return filter_var((string) $value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false;
    }
837244
protected function dlstatsIPv6ExpandNotation($Ip)
	{
		if (strpos($Ip, '::') !== false)
			$Ip = str_replace('::', str_repeat(':0', 8 - substr_count($Ip, ':')) . ':', $Ip);
		if (strpos($Ip, ':') === 0)
			$Ip = '0' . $Ip;
		return $Ip;
	}
530279
public function visitIpv6AddressFormatConstraint(StringValue\Ipv6AddressFormatConstraint $constraint)
    {
        if (!$this->formatValidationEnabled()) {
            return $this->createResult();
        }

        $value = $this->currentValue();
        if (
            !$value instanceof Value\StringValue ||
            $this->ipv6AddressValidator()->isValid($value->value())
        ) {
            return $this->createResult();
        }

        return $this->createSingleIssueResult($constraint);
    }