1 |
stephdl |
1.1 |
diff -Nur smeserver-qpsmtpd-2.4.0/root/etc/e-smith/templates/var/service/qpsmtpd/config/relayclients/60myAppliances smeserver-qpsmtpd-2.4.0.bz8704/root/etc/e-smith/templates/var/service/qpsmtpd/config/relayclients/60myAppliances |
2 |
|
|
--- smeserver-qpsmtpd-2.4.0/root/etc/e-smith/templates/var/service/qpsmtpd/config/relayclients/60myAppliances 1970-01-01 01:00:00.000000000 +0100 |
3 |
stephdl |
1.3 |
+++ smeserver-qpsmtpd-2.4.0.bz8704/root/etc/e-smith/templates/var/service/qpsmtpd/config/relayclients/60myAppliances 2014-12-04 00:41:19.363852378 +0100 |
4 |
stephdl |
1.2 |
@@ -0,0 +1,37 @@ |
5 |
stephdl |
1.1 |
+{ |
6 |
stephdl |
1.3 |
+ use esmith::util::network qw(isValidIP); |
7 |
|
|
+ use Net::IPv4Addr qw(ipv4_in_network ipv4_parse); |
8 |
stephdl |
1.1 |
+ |
9 |
stephdl |
1.3 |
+ my $relayclients = ${qpsmtpd}{UnauthenticatedRelayClients} || return; |
10 |
|
|
+ my @relayclients = split /[,:]/, $relayclients; |
11 |
stephdl |
1.2 |
+ |
12 |
stephdl |
1.3 |
+ my $ndb = esmith::NetworksDB->open_ro(); |
13 |
|
|
+ |
14 |
|
|
+ sub convert_to_cidr |
15 |
stephdl |
1.2 |
+ { |
16 |
stephdl |
1.3 |
+ $_ = shift; |
17 |
|
|
+ return "$_/32" unless m!/!; |
18 |
|
|
+ my ($ip,$bits) = ipv4_parse($_); |
19 |
|
|
+ return "$ip/$bits"; |
20 |
|
|
+ } |
21 |
|
|
+ |
22 |
|
|
+ my @localAccess = map { |
23 |
|
|
+ convert_to_cidr($_) |
24 |
|
|
+ } $ndb->local_access_spec(); |
25 |
stephdl |
1.2 |
+ |
26 |
stephdl |
1.3 |
+ foreach my $relayclient (@relayclients) |
27 |
|
|
+ { |
28 |
|
|
+ if (!isValidIP($relayclient)) |
29 |
stephdl |
1.1 |
+ { |
30 |
stephdl |
1.3 |
+ $OUT .= "## $relayclient is not an IP\n"; |
31 |
stephdl |
1.1 |
+ } |
32 |
stephdl |
1.3 |
+ elsif (grep { ipv4_in_network($_, $relayclient) } @localAccess) |
33 |
stephdl |
1.1 |
+ { |
34 |
stephdl |
1.3 |
+ $OUT .= "$relayclient\n"; |
35 |
|
|
+ } |
36 |
stephdl |
1.2 |
+ else |
37 |
stephdl |
1.3 |
+ { |
38 |
|
|
+ $OUT .= "## $relayclient is not in any local network\n"; |
39 |
stephdl |
1.1 |
+ } |
40 |
stephdl |
1.2 |
+ } |
41 |
stephdl |
1.1 |
+} |