From: git@ipfire.org
To: ipfire-scm@lists.ipfire.org
Subject: [git.ipfire.org] IPFire 2.x development tree branch, next, updated. b0d9fad3f94fb73b1686c5e6a948066497638d26
Date: Tue, 18 Mar 2014 23:49:53 +0100 [thread overview]
Message-ID: <20140318224954.4682220AF4@argus.ipfire.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 3375 bytes --]
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "IPFire 2.x development tree".
The branch, next has been updated
via b0d9fad3f94fb73b1686c5e6a948066497638d26 (commit)
from cc77ac2364436f6dff5fa31bbe6fb0dd1f92c4fd (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b0d9fad3f94fb73b1686c5e6a948066497638d26
Author: Michael Tremer <michael.tremer(a)ipfire.org>
Date: Tue Mar 18 23:49:23 2014 +0100
firewall: rules.pl: Add support for auto selection of NAT addresses.
-----------------------------------------------------------------------
Summary of changes:
config/firewall/rules.pl | 46 ++++++++++++++++++++++++++++++++++++++++------
1 file changed, 40 insertions(+), 6 deletions(-)
Difference in files:
diff --git a/config/firewall/rules.pl b/config/firewall/rules.pl
index 7a8e9ba..50fff3f 100755
--- a/config/firewall/rules.pl
+++ b/config/firewall/rules.pl
@@ -400,13 +400,14 @@ sub get_nat_address {
my $source = shift;
# Any static address of any zone.
- if ($zone eq "RED" || $zone eq "GREEN" || $zone eq "ORANGE" || $zone eq "BLUE") {
- return $defaultNetworks{$zone . "_ADDRESS"};
-
- } elsif ($zone eq "Default IP") {
+ if ($zone eq "AUTO") {
if ($source) {
my $firewall_ip = &get_internal_firewall_ip_address($source, 1);
+ if ($firewall_ip) {
+ return $firewall_ip;
+ }
+ $firewall_ip = &get_matching_firewall_address($source, 1);
if ($firewall_ip) {
return $firewall_ip;
}
@@ -414,6 +415,12 @@ sub get_nat_address {
return &get_external_address();
+ } elsif ($zone eq "RED" || $zone eq "GREEN" || $zone eq "ORANGE" || $zone eq "BLUE") {
+ return $defaultNetworks{$zone . "_ADDRESS"};
+
+ } elsif ($zone eq "Default IP") {
+ return &get_external_address();
+
} else {
return &get_alias($zone);
}
@@ -845,8 +852,8 @@ sub get_internal_firewall_ip_address {
my $use_orange = shift;
my ($net_address, $net_mask) = split("/", $subnet);
- if (!$net_mask) {
- return;
+ if ((!$net_mask) || ($net_mask ~~ ["32", "255.255.255.255"])) {
+ return 0;
}
my @addresses = &get_internal_firewall_ip_addresses($use_orange);
@@ -855,6 +862,8 @@ sub get_internal_firewall_ip_address {
return $zone_address;
}
}
+
+ return 0;
}
sub firewall_is_in_subnet {
@@ -870,3 +879,28 @@ sub firewall_is_in_subnet {
return 0;
}
+
+sub get_matching_firewall_address {
+ my $addr = shift;
+ my $use_orange = shift;
+
+ my ($address, $netmask) = split("/", $addr);
+
+ my @zones = ("GREEN", "BLUE");
+ if ($use_orange) {
+ push(@zones, "ORANGE");
+ }
+
+ foreach my $zone (@zones) {
+ next unless (exists $defaultNetworks{$zone . "_ADDRESS"});
+
+ my $zone_subnet = $defaultNetworks{$zone . "_NETADDRESS"};
+ my $zone_mask = $defaultNetworks{$zone . "_NETMASK"};
+
+ if (&General::IpInSubnet($address, $zone_subnet, $zone_mask)) {
+ return $defaultNetworks{$zone . "_ADDRESS"};
+ }
+ }
+
+ return 0;
+}
hooks/post-receive
--
IPFire 2.x development tree
reply other threads:[~2014-03-18 22:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140318224954.4682220AF4@argus.ipfire.org \
--to=git@ipfire.org \
--cc=ipfire-scm@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox