Add support to CIDR notation in network-alias file. Thanks to Thibaud Aubert for the feature request.
This commit is contained in:
parent
f06f9fc6aa
commit
cbfaefa52e
|
@ -597,7 +597,12 @@ sub _parseData
|
||||||
# Replace network by his aliases if any
|
# Replace network by his aliases if any
|
||||||
my $network = '';
|
my $network = '';
|
||||||
foreach my $r (keys %{$self->{NetworkAlias}}) {
|
foreach my $r (keys %{$self->{NetworkAlias}}) {
|
||||||
if ($client =~ /^$r/) {
|
if ($r =~ /^\d+\.\d+\.\d+\.\d+\/\d+$/) {
|
||||||
|
if (&check_ip($client, $r)) {
|
||||||
|
$network = $self->{NetworkAlias}->{$r};
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
} elsif ($client =~ /^$r/) {
|
||||||
$network = $self->{NetworkAlias}->{$r};
|
$network = $self->{NetworkAlias}->{$r};
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
|
@ -1833,9 +1838,14 @@ sub _print_network_stat
|
||||||
my $show = $net;
|
my $show = $net;
|
||||||
if ($net =~ /^(\d+\.\d+\.\d+)/) {
|
if ($net =~ /^(\d+\.\d+\.\d+)/) {
|
||||||
$show = "$1.0";
|
$show = "$1.0";
|
||||||
foreach my $n (keys %{$self->{NetworkAlias}}) {
|
foreach my $r (keys %{$self->{NetworkAlias}}) {
|
||||||
if ($show =~ /$self->{NetworkAlias}->{$n}/) {
|
if ($r =~ /^\d+\.\d+\.\d+\.\d+\/\d+$/) {
|
||||||
$show = $n;
|
if (&check_ip($net, $r)) {
|
||||||
|
$show = $self->{NetworkAlias}->{$r};
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
} elsif ($show =~ /$r/) {
|
||||||
|
$show = $self->{NetworkAlias}->{$r};
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2966,7 +2976,10 @@ sub parse_network_aliases
|
||||||
my @rg = split(/(?<!\{\d)[\s,;\t](?!\d+\})/, $data[1]);
|
my @rg = split(/(?<!\{\d)[\s,;\t](?!\d+\})/, $data[1]);
|
||||||
foreach my $r (@rg) {
|
foreach my $r (@rg) {
|
||||||
$r =~ s/^\^//;
|
$r =~ s/^\^//;
|
||||||
&check_regex($r, "$file at line $i");
|
# If this is not a cidr notation
|
||||||
|
if ($r !~ /^\d+\.\d+\.\d+\.\d+\/\d+$/) {
|
||||||
|
&check_regex($r, "$file at line $i");
|
||||||
|
}
|
||||||
$alias{"$r"} = $data[0];
|
$alias{"$r"} = $data[0];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Squid Analyzer Network Alias configuration file
|
# Squid Analyzer Network Alias configuration file
|
||||||
# FORMAT : NETWORK_NAME NETWORK_REGEX1,NETWORK_REGEX2,...
|
# FORMAT: NETWORK_NAME NETWORK_REGEX1,NETWORK_REGEX2,...
|
||||||
# Field separator must be one or more tabulation. See examples below.
|
# Field separator must be one or more tabulation.
|
||||||
|
# You can also use the CIDR notation:
|
||||||
|
# FORMAT: NETWORK_NAME xxx.xxx.xxx.xxx/n
|
||||||
|
#
|
||||||
|
# See examples below.
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
#Home Network 192\.168\.1\.
|
#Home Network 192\.168\.1\.
|
||||||
#Associated Networks ^10\.169\.[2-4]\.,^10\.169\.[7-9]\.
|
#Associated Networks ^10\.169\.[2-4]\.,^10\.169\.[7-9]\.
|
||||||
#ClassB Network ^10\.172\.
|
#ClassB Network 10.172.0.0/16
|
||||||
|
#ClassC Network 192.168.1.0/24
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue