X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=html%2Fcgi-bin%2Fforwardfw.cgi;h=3bd3e0f24d97b406035c8612a2914eb3dac31470;hb=f18c38312cb4156858fad253f84d66cfe01811da;hp=904135b7d4fd28fee0be01650ce56934ad7dc4af;hpb=ec6fd189ee94eb5fb8f969ff71b9ffae9e13a37c;p=people%2Fteissler%2Fipfire-2.x.git diff --git a/html/cgi-bin/forwardfw.cgi b/html/cgi-bin/forwardfw.cgi index 904135b7d..3bd3e0f24 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,70 @@ 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(); + } + + // 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; -} END @@ -175,6 +176,23 @@ if ($fwdfwsettings{'ACTION'} eq 'saverule') &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;} @@ -830,7 +848,7 @@ sub 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; } @@ -881,6 +899,12 @@ sub checkrule $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'} = ''; @@ -1677,30 +1701,50 @@ END &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< -
+ +
+
"; 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 use srcport'} + + + + + $Lang::tr{'fwdfw use srv'} + + +
+ + +
+ + + + - + + + + - -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'}); @@ -1805,55 +1884,69 @@ END -
$Lang::tr{'fwdfw rule activate'}
$Lang::tr{'fwdfw log rule'}


-END - &Header::closebox(); - #---ADD TIMEFRAME----------------------------------------------- - &Header::openbox('100%', 'left', $Lang::tr{'fwdfw timeframe'}); - print< - $Lang::tr{'fwdfw timeframe'} -   - - $Lang::tr{'time'}:  - $Lang::tr{'advproxy monday'} $Lang::tr{'advproxy tuesday'} $Lang::tr{'advproxy wednesday'} $Lang::tr{'advproxy thursday'} $Lang::tr{'advproxy friday'} $Lang::tr{'advproxy saturday'} $Lang::tr{'advproxy sunday'} - $Lang::tr{'advproxy from'} - $Lang::tr{'advproxy to'} - - - - - - - - - - - + + $Lang::tr{'fwdfw timeframe'} + + + + + + + + + + + + + + + + + + + + + + + + + -
 $Lang::tr{'advproxy monday'}$Lang::tr{'advproxy tuesday'}$Lang::tr{'advproxy wednesday'}$Lang::tr{'advproxy thursday'}$Lang::tr{'advproxy friday'}$Lang::tr{'advproxy saturday'}$Lang::tr{'advproxy sunday'} 
  + ‐ +


+ + + + + + + +

END + #---ACTION------------------------------------------------------ if($fwdfwsettings{'updatefwrule'} ne 'on'){ print<