From: Michael Tremer Date: Tue, 15 Oct 2013 19:06:32 +0000 (+0200) Subject: firewall: Simplify protocol selection. X-Git-Url: http://git.ipfire.org/?p=people%2Fteissler%2Fipfire-2.x.git;a=commitdiff_plain;h=a1e89f481d13a59a38854a3921f3c0d85a26f4dd firewall: Simplify protocol selection. Plausibility checks and removed checkboxed need to be made functional again. Also proper styling is missing. --- diff --git a/html/cgi-bin/forwardfw.cgi b/html/cgi-bin/forwardfw.cgi index 904135b7d..3810b8b32 100755 --- a/html/cgi-bin/forwardfw.cgi +++ b/html/cgi-bin/forwardfw.cgi @@ -63,6 +63,8 @@ my %aliases=(); 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"; @@ -100,71 +102,62 @@ my @protocols; #### JAVA SCRIPT #### print< - \$(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(); } - // When nat not used, hide it - if (! \$("#nat").attr("checked")) { - toggle_elements('#natpart'); + + // Handle ICMP. + if (protocol === "ICMP") { + \$("#PROTOCOL_ICMP_TYPES").show(); + } else { + \$("#PROTOCOL_ICMP_TYPES").hide(); } - // 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(); + }; + + \$(document).ready(function() { + \$("#protocol").change(update_protocol); + update_protocol(); + + // When nat not used, hide it + if (\$("#nat").attr("checked")) { + \$("#natpart").show(); } // Show NAT area when "use nat" checkbox is clicked - \$( "#nat" ).change(function() { - toggle_elements('#natpart'); - }); - // 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'); + \$("#nat").change(function() { + \$("#natpart").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; -} END @@ -1678,26 +1671,42 @@ END #---PROTOCOL------------------------------------------------------ &Header::openbox('100%', 'left', $Lang::tr{'fwhost prot'}); print< -
+ +
+
"; print< + +
$Lang::tr{'fwhost icmptype'} +
+ + +
+ + + + -
$Lang::tr{'fwhost icmptype'} +



-END - #SOURCEPORT - print<

-
- -
$Lang::tr{'fwdfw use srcport'}
-
- -END - $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g; - print< -
$Lang::tr{'fwdfw man port'}

+ + print < + + + + END - #TARGETPORT - print<
-
-
$Lang::tr{'fwdfw use srv'}
-
+ +
$Lang::tr{'fwhost cust service'} + + + + + + + + + +
+ $Lang::tr{'fwdfw man port'} + + + + $Lang::tr{'fwdfw man port'} + + +
+ + +
+ + + + - + + + + - -END - $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g; - print< -
+ + $Lang::tr{'fwhost cust service'} + +
$Lang::tr{'fwhost cust srvgrp'} +
+ + $Lang::tr{'fwhost cust srvgrp'} + +
$Lang::tr{'fwdfw man port'}


+ +
+
+ +


END + &Header::closebox; #---Activate/logging/remark------------------------------------- &Header::openbox('100%', 'left', $Lang::tr{'fwdfw additional'});