my %optionsfw=();
my %ifaces=();
+my @PROTOCOLS = ("TCP", "UDP", "ICMP", "IGMP", "AH", "ESP", "GRE");
+
my $color;
my $confignet = "${General::swroot}/fwhosts/customnetworks";
my $confighost = "${General::swroot}/fwhosts/customhosts";
#### JAVA SCRIPT ####
print<<END;
<script>
- \$(document).ready(function() {
- // Hide sourceport area when no sourceport is used
- if (! \$("#USE_SRC_PORT").attr("checked")) {
- toggle_elements('#srcport');
+ var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
+
+ var update_protocol = function() {
+ var protocol = \$("#protocol").val();
+
+ if (protocol === undefined)
+ return;
+
+ // Check if a template is/should be used.
+ if (protocol === "template") {
+ \$("#PROTOCOL_TEMPLATE").show();
+ } else {
+ \$("#PROTOCOL_TEMPLATE").hide();
}
- // Hide targetport area when no targetport is used
- if (! \$("#USESRV").attr("checked")) {
- toggle_elements('#targetport');
+
+ // Check if we are dealing with a protocol, that knows ports.
+ if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
+ \$("#PROTOCOL_PORTS").show();
+ } else {
+ \$("#PROTOCOL_PORTS").hide();
+ }
+
+ // Handle ICMP.
+ if (protocol === "ICMP") {
+ \$("#PROTOCOL_ICMP_TYPES").show();
+ } else {
+ \$("#PROTOCOL_ICMP_TYPES").hide();
}
+ };
+
+ \$(document).ready(function() {
+ \$("#protocol").change(update_protocol);
+ update_protocol();
+
// When nat not used, hide it
if (! \$("#nat").attr("checked")) {
- toggle_elements('#natpart');
- }
- // When protocol dropdown is changed, check if we selected icmp - then show icmp-types
- \$("#prt").change(function(){
- if ( \$("#PROT").val() === 'ICMP' ){
- \$('#PROTOKOLL').show();
- }
- else{
- \$('#PROTOKOLL').hide();
- }
- });
- // When Prot not icmp, hide icmp-types
- if ( ! \$("#PROT").val() == 'ICMP') {
- \$('#PROTOKOLL').hide();
+ \$("#natpart").hide();
}
// Show NAT area when "use nat" checkbox is clicked
- \$( "#nat" ).change(function() {
- toggle_elements('#natpart');
+ \$("#nat").change(function() {
+ \$("#natpart").toggle();
});
- // Show Sourceport area when "use sourceport" checkbox is clicked
- \$( "#spt" ).change(function() {
- toggle_elements('#srcport');
- });
- // Show Targetport area when "use Targetport" checkbox is clicked
- \$( "#tpt" ).change(function() {
- toggle_elements('#targetport');
+
+ // Time constraints
+ if(!\$("#USE_TIME_CONSTRAINTS").attr("checked")) {
+ \$("#TIME_CONSTRAINTS").hide();
+ }
+ \$("#USE_TIME_CONSTRAINTS").change(function() {
+ \$("#TIME_CONSTRAINTS").toggle();
});
+
// Automatically select radio buttons when corresponding
// dropdown menu changes.
\$("select").change(function() {
var id = \$(this).attr("name");
- //When using SNAT or DNAT, check "USE NAT" Checkbox
- if ( id === 'snat' || id === 'dnat') {
+
+ // When using SNAT or DNAT, check "USE NAT" Checkbox
+ if (id === 'snat' || id === 'dnat') {
\$('#USE_NAT').prop('checked', true);
}
\$('#' + id).prop("checked", true);
});
});
-function checkradio(a){
- \$(a).attr('checked', true);
-}
-function toggle_elements( id ) {
- \$(id).toggle();
- if(! \$("targetport:visible") && \$("#PROT").val() === 'ICMP' )
- {
- \$('#PROTOKOLL').show();
- }
- if(\$("targetport:visible") && \$("#PROT").val() === 'ICMP' )
- {
- \$('#PROTOKOLL').hide();
- }
- return true;
-}
</script>
END
&General::readhasharray("$configfwdfw", \%configfwdfw);
&General::readhasharray("$configinput", \%configinputfw);
&General::readhasharray("$configoutgoing", \%configoutgoingfw);
+ #Set Variables according to the JQuery code in protocol section
+ if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP')
+ {
+ if ($fwdfwsettings{'SRC_PORT'} ne '')
+ {
+ $fwdfwsettings{'USE_SRC_PORT'} = 'ON';
+ }
+ if ($fwdfwsettings{'TGT_PORT'} ne '')
+ {
+ $fwdfwsettings{'USESRV'} = 'ON';
+ $fwdfwsettings{'grp3'} = 'TGT_PORT';
+ }
+ }
+ if ($fwdfwsettings{'PROT'} eq 'template')
+ {
+ $fwdfwsettings{'USESRV'} = 'ON';
+ }
$errormessage=&checksource;
if(!$errormessage){&checktarget;}
if(!$errormessage){&checkrule;}
return;
}
#when icmp selected, no targetport allowed
- if (($fwdfwsettings{'PROT'} ne '' && $fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP') && ($fwdfwsettings{'USESRV'} eq 'ON' || $fwdfwsettings{'USE_SRC_PORT'} eq 'ON')){
+ if (($fwdfwsettings{'PROT'} ne '' && $fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP' && $fwdfwsettings{'PROT'} ne 'template') && ($fwdfwsettings{'USESRV'} eq 'ON' || $fwdfwsettings{'USE_SRC_PORT'} eq 'ON')){
$errormessage.=$Lang::tr{'fwdfw err prot_port'};
return;
}
$fwdfwsettings{'ICMP_TYPES'}='';
$fwdfwsettings{'USESRV'}='';
$fwdfwsettings{'TGT_PORT'}='';
+ }elsif($fwdfwsettings{'PROT'} eq 'IGMP'){
+ $fwdfwsettings{'USE_SRC_PORT'}='';
+ $fwdfwsettings{'SRC_PORT'}='';
+ $fwdfwsettings{'ICMP_TYPES'}='';
+ $fwdfwsettings{'USESRV'}='';
+ $fwdfwsettings{'TGT_PORT'}='';
}elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP' && $fwdfwsettings{'PROT'} ne 'ICMP'){
$fwdfwsettings{'ICMP_TYPES'}='';
$fwdfwsettings{'PROT'} = '';
&Header::closebox;
#---PROTOCOL------------------------------------------------------
&Header::openbox('100%', 'left', $Lang::tr{'fwhost prot'});
+ #Fix Protocol for JQuery
+ if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
+ $fwdfwsettings{'PROT'} = 'template';
+ }
print<<END;
- <div id="prt"><table width='15%' border='0' style="float:left;">
- <tr><td><select name='PROT' id='PROT' >
+ <div id="prt">
+ <table width='15%' border='0' style="float:left;">
+ <tr>
+ <td>
+ <select name='PROT' id='protocol'>
END
- if ($fwdfwsettings{'PROT'} eq ''){
- print"<option value='' selected>$Lang::tr{'all'}</option>";
- }else{
- print"<option value=''>$Lang::tr{'all'}</option>";
+ print "<option value=\"\"";
+ if ($fwdfwsettings{'PROT'} eq '') {
+ print " selected=\"selected\"";
}
- foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
- {
- if ($_ eq $fwdfwsettings{'PROT'})
- {
- print"<option selected>$_</option>";
- }else{
- print"<option>$_</option>";
+ print ">$Lang::tr{'all'}</option>";
+
+ print "<option value=\"template\"";
+ print " selected=\"selected\"" if ($fwdfwsettings{'grp3'} eq 'cust_srv' || $fwdfwsettings{'grp3'} eq 'cust_srvgrp');
+ print ">- $Lang::tr{'template'} -</option>";
+
+ foreach (@PROTOCOLS) {
+ print"<option value=\"$_\"";
+ if ($_ eq $fwdfwsettings{'PROT'}) {
+ print " selected=\"selected\"";
}
+ print ">$_</option>";
}
- print"</select></td></tr></table></div>";
print<<END;
- <div id="PROTOKOLL" class="noscript"><table width='30%' border='0' style="float:left;"><tr><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES' style='min-width:230px;'>
+ </select>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+ <div id="PROTOCOL_ICMP_TYPES">
+ <table width='50%' border='0' style="float:left;">
+ <tr>
+ <td width='20%'>$Lang::tr{'fwhost icmptype'}</td>
+ <td colspan='2'>
+ <select name='ICMP_TYPES' style='min-width:230px;'>
END
&General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
- print"<option>All ICMP-Types</option>";
+ print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
foreach my $key (sort { ncmp($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
}
}
- print<<END;
- </select></td></tr>
- </table></div><br><br><br>
-END
- #SOURCEPORT
- print<<END;
- <table width='100%'><tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></table>
- <div id="spt"><table width='100%' border='0'>
- <tr><td width='1%'><input type='checkbox' name='USE_SRC_PORT' id='USE_SRC_PORT' value='ON' $checked{'USE_SRC_PORT'}{'ON'}></td>
- <td width='51%' colspan='3'>$Lang::tr{'fwdfw use srcport'}</td></tr></table></div>
- <div id="srcport" class="noscript"><table width='100%' border='0'><tr>
- <td width='70%' nowrap='nowrap' align='right'>$Lang::tr{'fwdfw man port'}</td>
-END
- $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
- print<<END;
- <td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
- </table></div><br>
+
+ print <<END;
+ </select>
+ </td>
+ </tr>
+ </table>
+ </div>
END
- #TARGETPORT
- print<<END;
- <hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '><br>
- <div id="tpt"><table width='100%' border='0'>
- <tr><td width='1%'><input type='checkbox' name='USESRV' id='USESRV' value='ON' $checked{'USESRV'}{'ON'}></td><td width='48%'>$Lang::tr{'fwdfw use srv'}</td></tr></table></div>
- <div id="targetport" class="noscript"><table width='100%' border='0'><tr><td width='80%'></td><td width='1%'><input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked></td><td nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td width='1%' colspan='2'><select name='cust_srv' style='min-width:230px;' >
+
+ $fwdfwsettings{'SRC_PORT'} =~ s/\|/,/g;
+ $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
+
+ print <<END;
+
+ <div id="PROTOCOL_PORTS">
+ <table border="0">
+ <tr>
+ <!-- #SOURCEPORT -->
+ <td>
+ $Lang::tr{'fwdfw use srcport'}
+ </td>
+ <td>
+ <input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18'>
+ </td>
+ <td width='10%'>
+ </td>
+
+ <!-- #TARGETPORT -->
+ <td>
+ $Lang::tr{'fwdfw use srv'}
+ </td>
+
+ <td>
+ <input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18'>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+ <div id="PROTOCOL_TEMPLATE">
+ <table border="0">
+ <tr>
+ <td>
+ <input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked>
+ $Lang::tr{'fwhost cust service'}
+ </td>
+ <td>
+ <select name='cust_srv' style='min-width: 230px;'>
END
&General::readhasharray("$configsrv", \%customservice);
foreach my $key (sort { ncmp($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
print"<option ";
print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
- }
+ }
+
print<<END;
- </select></td></tr>
- <tr><td></td><td><input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}></td><td nowrap='nowrap'>$Lang::tr{'fwhost cust srvgrp'}</td><td colspan='2'><select name='cust_srvgrp' style='min-width:230px;' >
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}>
+ $Lang::tr{'fwhost cust srvgrp'}
+ </td>
+ <td>
+ <select name='cust_srvgrp' style='min-width:230px;'>
END
+
&General::readhasharray("$configsrvgrp", \%customservicegrp);
my $helper;
foreach my $key (sort { ncmp($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
$helper=$customservicegrp{$key}[0];
}
print<<END;
- </select></td></tr>
- <tr><td></td><td><input type='radio' name='grp3' id='TGT_PORT' value='TGT_PORT' $checked{'grp3'}{'TGT_PORT'}></td><td>$Lang::tr{'fwdfw man port'}</td>
-END
- $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
- print<<END;
- <td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' onclick='checkradio(\"#TGT_PORT\")'></td></tr>
- </table></div><br><hr>
+ </select>
+ </td>
+ </tr>
+ </table>
+ </div>
+
+ <br><br><br>
END
+
&Header::closebox;
#---Activate/logging/remark-------------------------------------
&Header::openbox('100%', 'left', $Lang::tr{'fwdfw additional'});
</table><table width='100%'>
<tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
<tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
- </table><br><hr>
-END
- &Header::closebox();
- #---ADD TIMEFRAME-----------------------------------------------
- &Header::openbox('100%', 'left', $Lang::tr{'fwdfw timeframe'});
- print<<END;
- <table width='70%' border='0'>
- <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='9'>$Lang::tr{'fwdfw timeframe'}</td></tr>
- <tr><td colspan='10'> </td></tr>
- <tr>
- <td align='left' >$Lang::tr{'time'}: </td>
- <td>$Lang::tr{'advproxy monday'}</td><td> $Lang::tr{'advproxy tuesday'} </td><td>$Lang::tr{'advproxy wednesday'}</td><td> $Lang::tr{'advproxy thursday'}</td><td> $Lang::tr{'advproxy friday'}</td><td> $Lang::tr{'advproxy saturday'}</td><td> $Lang::tr{'advproxy sunday'}</td>
- <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
- <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
- </tr>
- <tr>
- <td align='right'></td>
- <td width='1%' align='left'><input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} ></td>
- <td width='1%' align='left'><input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} ></td>
- <td width='1%' align='left'><input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} ></td>
- <td width='1%' align='left'><input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} ></td>
- <td width='1%' align='left'><input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} ></td>
- <td width='1%' align='left'><input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} ></td>
- <td width='15%' align='left'><input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} ></td>
- <td><select name='TIME_FROM'>
+ <tr>
+ <td width='1%'>
+ <input type='checkbox' name='TIME' id="USE_TIME_CONSTRAINTS" value='ON' $checked{'TIME'}{'ON'}>
+ </td>
+ <td>$Lang::tr{'fwdfw timeframe'}</td>
+ </tr>
+ <tr id="TIME_CONSTRAINTS">
+ <td colspan="2">
+ <table width="66%" border="0">
+ <tr>
+ <td width="8em"> </td>
+ <td align="center">$Lang::tr{'advproxy monday'}</td>
+ <td align="center">$Lang::tr{'advproxy tuesday'}</td>
+ <td align="center">$Lang::tr{'advproxy wednesday'}</td>
+ <td align="center">$Lang::tr{'advproxy thursday'}</td>
+ <td align="center">$Lang::tr{'advproxy friday'}</td>
+ <td align="center">$Lang::tr{'advproxy saturday'}</td>
+ <td align="center">$Lang::tr{'advproxy sunday'}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td width="8em"> </td>
+ <td align="center"><input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} ></td>
+ <td align="center"><input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} ></td>
+ <td align="center"><input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} ></td>
+ <td align="center"><input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} ></td>
+ <td align="center"><input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} ></td>
+ <td align="center"><input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} ></td>
+ <td align="center"><input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} ></td>
+ <td>
+ <select name='TIME_FROM'>
END
for (my $i=0;$i<=23;$i++) {
$i = sprintf("%02s",$i);
for (my $j=0;$j<=45;$j+=15) {
$j = sprintf("%02s",$j);
my $time = $i.":".$j;
- print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
+ print "<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
}
}
print<<END;
- </select></td>
- <td><select name='TIME_TO'>
+ </select> ‐
+ <select name='TIME_TO'>
END
for (my $i=0;$i<=23;$i++) {
$i = sprintf("%02s",$i);
for (my $j=0;$j<=45;$j+=15) {
$j = sprintf("%02s",$j);
my $time = $i.":".$j;
- print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
+ print "<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
}
}
print<<END;
- </select></td></tr></table><br><hr>
+ </select>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ <br><hr>
END
+
#---ACTION------------------------------------------------------
if($fwdfwsettings{'updatefwrule'} ne 'on'){
print<<END;