No 127.0.0.1 is IPv4 and ::1 is IPv6 both are localhost but they are not “the same”
::1/128 is localhost with full subnet mask, so that is ::1 as address with 128 prefix len
127.0.0.1/8 is the full 127.0.0.0-127.255.255.255 range and not just the address.
Reading the comment ignoring link-local (as in fe80::/10) seems to be the goal, I would absolutely accept the premise that ::1 is not a valid global address. so should ? discover_process_ipv6 ignore link-local and localhost IPs on interfaces?
The OP asked about the localhost IPs, but the comment on isValid which according to OP return false, only mentions “link-locals” , not localhosts, so there might be some inconsistencies here.
I totally agree that they probably should be rejected, but reading OP they are not for IPv4, and the comment is not clear in the OP snippet.
OP linked the wrong bit of code. Under the context of the IPv6 module (of which they are showing code from an old version), locahost should always be rejected.
Here is a look at the isValid function:
public static function isValid($ipv6, $exclude_reserved = false)
{
$filter = FILTER_FLAG_IPV6;
if ($exclude_reserved) {
$filter |= FILTER_FLAG_NO_RES_RANGE | FILTER_FLAG_GLOBAL_RANGE;
}
return filter_var($ipv6, FILTER_VALIDATE_IP, $filter) !== false;
}
As you can see $exclude_reserved also requires it to be a global IP, which is exactly what we want for the IPv6 Addresses module.
The only issue is that the comments/option name are slightly misleading.