diff options
| author | Michael Larson <slioch@eng-140.vyatta.com> | 2008-02-22 10:26:42 -0800 |
|---|---|---|
| committer | Michael Larson <slioch@eng-140.vyatta.com> | 2008-02-22 10:26:42 -0800 |
| commit | 7f762bce68d659ae654a611a0d7b7b3100880bcf (patch) | |
| tree | b49618722683cb47348380dea5453593b35be500 /scripts | |
| parent | 5500072cf6923bfab97ae1ed89231d71e4abce0f (diff) | |
| download | vyatta-wanloadbalance-7f762bce68d659ae654a611a0d7b7b3100880bcf.tar.gz vyatta-wanloadbalance-7f762bce68d659ae654a611a0d7b7b3100880bcf.zip | |
add check in cli for both address and network configured--in this case generate configuration error.
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/vyatta-wanloadbalance.pl | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/scripts/vyatta-wanloadbalance.pl b/scripts/vyatta-wanloadbalance.pl index e89726d..2faef89 100644 --- a/scripts/vyatta-wanloadbalance.pl +++ b/scripts/vyatta-wanloadbalance.pl @@ -93,17 +93,21 @@ sub write_rules { #destination print FILE_LCK "\tdestination {\n"; - my $option = $config->returnValue("$rule destination address"); - if (defined $option) { - print FILE_LCK "\t\taddress " . $option . "\n"; + my $daddr = $config->returnValue("$rule destination address"); + if (defined $daddr) { + print FILE_LCK "\t\taddress " . $daddr . "\n"; } - $option = $config->returnValue("$rule destination network"); - if (defined $option) { - print FILE_LCK "\t\tnetwork " . $option . "\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; } - $option = $config->returnValue("$rule destination port"); + 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"; @@ -119,14 +123,18 @@ sub write_rules { print FILE_LCK "\tsource {\n"; - $option = $config->returnValue("$rule source address"); - if (defined $option) { - print FILE_LCK "\t\taddress " . $option . "\n"; + my $saddr = $config->returnValue("$rule source address"); + if (defined $saddr) { + print FILE_LCK "\t\taddress " . $saddr . "\n"; } - $option = $config->returnValue("$rule source network"); - if (defined $option) { - print FILE_LCK "\t\tnetwork " . $option . "\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; } $option = $config->returnValue("$rule source port"); |
