From 69d277ce4163ec5c605b0f18eff5cfec79f1ceba Mon Sep 17 00:00:00 2001 From: Vadim Kurland Date: Sun, 6 Mar 2011 20:14:47 -0800 Subject: [PATCH] see #2181 importr recognizes -i and -o --- doc/ChangeLog | 4 ++++ src/libgui/IPTImporter.cpp | 22 +++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index ab762975d..501c163c6 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,5 +1,9 @@ 2011-03-06 vadim + * IPTImporter.cpp (pushNATRule): see #2181 "Update iptables + importer to detect inbound & outbound interfaces in NAT rules". + Importer can now import nat rules with "-i" or "-o" interface spec. + * NATCompiler_ipt.cpp (processNext): see #2170 "Compiler should generate error for invalid iptables NAT configs". Now that we allow the user to specify inbound and outbound interfaces in diff --git a/src/libgui/IPTImporter.cpp b/src/libgui/IPTImporter.cpp index 110824db9..f22588f02 100644 --- a/src/libgui/IPTImporter.cpp +++ b/src/libgui/IPTImporter.cpp @@ -1218,11 +1218,18 @@ void IPTImporter::pushNATRule() assert(re!=NULL); re->addRef(s); } + if (!o_intf.empty()) - markCurrentRuleBad( - std::string("Original rule defines outbound interface '") + o_intf + "'.\n Replace address in TSrc with matching interface of the firewall."); + { + RuleElement *itf_o_re = rule->getItfOutb(); + assert(itf_o_re!=NULL); + newInterface(o_intf); + Interface *intf = all_interfaces[o_intf]; + itf_o_re->addRef(intf); + } } + if (target=="DNAT") { rule->setRuleType(NATRule::DNAT); @@ -1246,10 +1253,15 @@ void IPTImporter::pushNATRule() assert(re!=NULL); re->addRef(s); } - if (!i_intf.empty()) - markCurrentRuleBad( - std::string("Original rule defines inbound interface '") + i_intf + "'.\n Replace address in ODst with matching interface of the firewall."); + if (!i_intf.empty()) + { + RuleElement *itf_i_re = rule->getItfInb(); + assert(itf_i_re!=NULL); + newInterface(i_intf); + Interface *intf = all_interfaces[i_intf]; + itf_i_re->addRef(intf); + } } if (target=="NETMAP") {