diff options
author | Michael Larson <slioch@eng-140.vyatta.com> | 2008-03-20 09:54:56 -0700 |
---|---|---|
committer | Michael Larson <slioch@eng-140.vyatta.com> | 2008-03-20 09:54:56 -0700 |
commit | db3ccf7834617fa5f278e512bb73b831acb407d3 (patch) | |
tree | bcf07c7f52890a76070e08e6c59dbc7da7a1a4a9 /scripts/vyatta-wanloadbalance.pl | |
parent | e1bc4714fd3049d928c8aa106ab698d51a5d315a (diff) | |
download | vyatta-wanloadbalance-db3ccf7834617fa5f278e512bb73b831acb407d3.tar.gz vyatta-wanloadbalance-db3ccf7834617fa5f278e512bb73b831acb407d3.zip |
modified configuration to mirror nat/firewall for port/address configuration. added port configuration support for common port
configuration validation. still needs additional validation for address configuration.
Diffstat (limited to 'scripts/vyatta-wanloadbalance.pl')
-rw-r--r-- | scripts/vyatta-wanloadbalance.pl | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/scripts/vyatta-wanloadbalance.pl b/scripts/vyatta-wanloadbalance.pl index 5069e29..ec361fa 100644 --- a/scripts/vyatta-wanloadbalance.pl +++ b/scripts/vyatta-wanloadbalance.pl @@ -88,25 +88,26 @@ sub write_rules { print FILE_LCK "\tdestination {\n"; my $daddr = $config->returnValue("$rule destination address"); if (defined $daddr) { - print FILE_LCK "\t\taddress " . $daddr . "\n"; - } - - my $dnet = $config->returnValue("$rule destination network"); - if (defined $dnet && !defined $daddr) { - print FILE_LCK "\t\tnetwork " . $dnet . "\n"; - } - elsif (defined $dnet && defined $daddr) { - print "Please specify either destination address or source network\n"; - exit 2; + print FILE_LCK "\t\taddress \"" . $daddr . "\"\n"; } my $option = $config->returnValue("$rule destination port"); if (defined $option) { - if ($protocol ne "tcp" && $protocol ne "udp") { - print "Please specify protocol tcp or udp when configuring ports\n"; - exit 2; + my $can_use_port; + my $port_str; + my $port_err; + + if ($protocol eq "tcp" || $protocol eq "udp") { + $can_use_port = "yes"; + } + ($port_str, $port_err) = VyattaMisc::getPortRuleString($option, $can_use_port, "d", $protocol); + if (defined $port_str) { + print FILE_LCK "\t\tport-ipt \"" . $port_str . "\"\n"; + } + else { + print $port_err; + exit 1; } - print FILE_LCK "\t\tport " . $option . "\n"; } print FILE_LCK "\t}\n"; @@ -118,25 +119,26 @@ sub write_rules { print FILE_LCK "\tsource {\n"; my $saddr = $config->returnValue("$rule source address"); if (defined $saddr) { - print FILE_LCK "\t\taddress " . $saddr . "\n"; - } - - my $snet = $config->returnValue("$rule source network"); - if (defined $snet && !defined $saddr) { - print FILE_LCK "\t\tnetwork " . $snet . "\n"; - } - elsif (defined $snet && defined $saddr) { - print "Please specify either source address or source network\n"; - exit 2; + print FILE_LCK "\t\taddress \"" . $saddr . "\"\n"; } $option = $config->returnValue("$rule source port"); if (defined $option) { - if ($protocol ne "tcp" && $protocol ne "udp") { - print "Please specify protocol tcp or udp when configuring ports\n"; - exit 2; + my $can_use_port; + my $port_str; + my $port_err; + + if ($protocol eq "tcp" || $protocol eq "udp") { + $can_use_port = "yes"; + } + ($port_str, $port_err) = VyattaMisc::getPortRuleString($option, $can_use_port, "d", $protocol); + if (defined $port_str) { + print FILE_LCK "\t\tport-ipt \"" . $port_str . "\"\n"; + } + else { + print $port_err; + exit 1; } - print FILE_LCK "\t\tport " . $option . "\n"; } print FILE_LCK "\t}\n"; |