[LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm
raeburn
raeburn at source.lon-capa.org
Sun Nov 28 13:43:37 EST 2021
raeburn Sun Nov 28 18:43:37 2021 EDT
Modified files:
/loncom/interface domainprefs.pm
Log:
- Bug 6914
- Sanity checking for IP address(es) and IP ranges, and store as
IP netblock(s) in CIDR notation.
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.392 loncom/interface/domainprefs.pm:1.393
--- loncom/interface/domainprefs.pm:1.392 Wed Nov 24 04:25:01 2021
+++ loncom/interface/domainprefs.pm Sun Nov 28 18:43:37 2021
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.392 2021/11/24 04:25:01 raeburn Exp $
+# $Id: domainprefs.pm,v 1.393 2021/11/28 18:43:37 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -7791,7 +7791,8 @@
'<tr'.$css_class.' id="wafproxyrow_'.$dom.'"'.$wafstyle.'>'.
'<td class="LC_left_item">'.&mt('Domain: [_1]','<b>'.$dom.'</b>').'<br /><br />'.
'<div id="wafproxyranges_'.$dom.'">'.&mt('Format for comma separated IP ranges').':<br />'.
- &mt('A.B.C.D/N or A.B.C.D-E.F.G.H').'</div></td>'.
+ &mt('A.B.C.D/N or A.B.C.D-E.F.G.H').'<br />'.
+ &mt('Range(s) stored in CIDR notation').'</div></td>'.
'<td class="LC_left_item"><table>'.
'<tr>'.
'<td valign="top">'.$lt{'remoteip'}.': '.
@@ -20509,18 +20510,17 @@
$possible =~ s/[\r\n]+/\s/g;
$possible =~ s/\s*-\s*/-/g;
$possible =~ s/\s+/,/g;
+ $possible =~ s/,+/,/g;
}
$count = 0;
if ($possible ne '') {
foreach my $poss (split(/\,/,$possible)) {
$count ++;
- if (&validate_ip_pattern($poss)) {
+ $poss = &validate_ip_pattern($poss);
+ if ($poss ne '') {
push(@ok,$poss);
}
}
- if (@ok) {
- $wafproxy{$item} = join(',', at ok);
- }
my $diff = $count - scalar(@ok);
if ($diff) {
push(@warnings,'<li>'.
@@ -20528,6 +20528,13 @@
$diff,$warn{$item}).
'</li>');
}
+ if (@ok) {
+ my @cidr_list;
+ foreach my $item (@ok) {
+ @cidr_list = &Net::CIDR::cidradd($item, at cidr_list);
+ }
+ $wafproxy{$item} = join(',', at cidr_list);
+ }
}
}
if ($wafproxy{$item} ne $currvalue{$item}) {
@@ -20719,12 +20726,17 @@
if ($pattern =~ /^([^-]+)\-([^-]+)$/) {
my ($start,$end) = ($1,$2);
if ((&Net::CIDR::cidrvalidate($start)) && (&Net::CIDR::cidrvalidate($end))) {
- return 1;
+ if (($start !~ m{/}) && ($end !~ m{/})) {
+ return $start.'-'.$end;
+ }
+ }
+ } elsif ($pattern ne '') {
+ $pattern = &Net::CIDR::cidrvalidate($pattern);
+ if ($pattern ne '') {
+ return $pattern;
}
- } elsif (&Net::CIDR::cidrvalidate($pattern)) {
- return 1;
}
- return
+ return;
}
sub modify_usersessions {
More information about the LON-CAPA-cvs
mailing list