mirror of
https://github.com/webmin/webmin.git
synced 2026-05-04 22:30:33 +01:00
Compare fully qualified IPv6 addresses
This commit is contained in:
@@ -403,5 +403,32 @@ else {
|
||||
}
|
||||
}
|
||||
|
||||
# canonicalize_ip6(address)
|
||||
# Converts an address to its full long form. Ie. 2001:db8:0:f101::20 to
|
||||
# 2001:0db8:0000:f101:0000:0000:0000:0020
|
||||
sub canonicalize_ip6
|
||||
{
|
||||
my ($addr) = @_;
|
||||
return $addr if (!&check_ip6address($addr));
|
||||
my @w = split(/:/, $addr);
|
||||
my $idx = &indexof("", @w);
|
||||
if ($idx >= 0) {
|
||||
# Expand ::
|
||||
my $mis = 8 - scalar(@w);
|
||||
my @nw = @w[0..$idx];
|
||||
for(my $i=0; $i<$mis; $i++) {
|
||||
push(@nw, 0);
|
||||
}
|
||||
push(@nw, @w[$idx+1 .. $#w]);
|
||||
@w = @nw;
|
||||
}
|
||||
foreach my $w (@w) {
|
||||
while(length($w) < 4) {
|
||||
$w = "0".$w;
|
||||
}
|
||||
}
|
||||
return lc(join(":", @w));
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
@@ -61,13 +61,14 @@ if (@ips && &foreign_installed("net")) {
|
||||
foreach $a (&net::active_interfaces()) {
|
||||
$onsystem{$a->{'address'}} = $a;
|
||||
foreach $ip6 (@{$a->{'address6'}}) {
|
||||
$onsystem{$ip6} = $a;
|
||||
$onsystem{&canonicalize_ip6($ip6)} = $a;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (%onsystem) {
|
||||
foreach $ip (@ips) {
|
||||
$onsystem{$ip} || &error(&text('bind_eonsystem', $ip));
|
||||
$onsystem{&canonicalize_ip6($ip)} ||
|
||||
&error(&text('bind_eonsystem', $ip));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user