smeserver-lemonldap-ng/root/etc/e-smith/templates/var/lib/lemonldap-ng/conf/lmConf/025localnet

46 lines
1005 B
Plaintext

{
my $reg = '$ipAddr =~ /^';
# Build a regexp to check if the client IP
# is part of a local network
# Then, we can easily use this macro to restrict
# access to local networks on some applications
my @net = ();
foreach my $net ($n->networks){
my $addr = $net->key;
my $mask = $net->prop('Mask') || '255.255.255.255';
foreach (esmith::util::computeAllLocalNetworkPrefixes($addr,$mask)){
push @net, "($_)";
}
}
$reg .= join('|', @net);
$reg .= '/';
$reg =~ s/\./\\\./g;
$conf->{'macros'}->{'localAccess'} = '(' . $reg . ") ? '1':'0'";
$reg = '$ipAddr =~ /^';
@net = ();
# Do the same for extenal SSL access
foreach my $net (split(/[;,]/,(${'httpd-admin'}{'ValidFrom'} || ''))){
my ($addr,$mask) = split(/\//,$net);
foreach (esmith::util::computeAllLocalNetworkPrefixes($addr,$mask)){
push @net, "($_)";
}
}
$reg .= join('|', @net);
$reg .= '/';
$reg =~ s/\./\\\./g;
$conf->{'macros'}->{'externalSSLAccess'} = '(' . $reg . ") ? '1':'0'";
$OUT = '';
}