X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fqos.cgi;h=1beb9e3363f8de45f8bdc7cd85956b539a6f2ed5;hp=6c8067040ed5444130ec5eb0fcda2d9ef2e8ebe7;hb=dd862e474183235317a5e795c20ff00d4fe2ddc9;hpb=cb5e9c6c64d5281eba5c790f14c2e5f3066becbf diff --git a/html/cgi-bin/qos.cgi b/html/cgi-bin/qos.cgi index 6c8067040e..1beb9e3363 100644 --- a/html/cgi-bin/qos.cgi +++ b/html/cgi-bin/qos.cgi @@ -1,17 +1,29 @@ #!/usr/bin/perl -# -# IPFire CGIs -# -# This code is distributed under the terms of the GPL -# -# (c) The IPFire Team -# +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### use RRDs; use strict; # enable only the following on debugging purpose # use warnings; -#use CGI::Carp 'fatalsToBrowser'; +# use CGI::Carp 'fatalsToBrowser'; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; @@ -52,8 +64,6 @@ my $portfile = "/var/ipfire/qos/portconfig"; my $tosfile = "/var/ipfire/qos/tosconfig"; &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); -&Header::showhttpheaders(); - $qossettings{'ENABLED'} = 'off'; $qossettings{'EDIT'} = 'no'; $qossettings{'OUT_SPD'} = ''; @@ -108,8 +118,19 @@ my %mainsettings = (); &General::readhash("${General::swroot}/main/settings", \%mainsettings); &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); -&Header::openpage('QoS', 1, ''); -&Header::openbigbox('100%', 'left', '', $errormessage); +my @querry = split(/\?/,$ENV{'QUERY_STRING'}); +$querry[0] = '' unless defined $querry[0]; +$querry[1] = 'hour' unless defined $querry[1]; + +if ( $querry[0] ne ""){ + print "Content-type: image/png\n\n"; + binmode(STDOUT); + &Graphs::updateqosgraph($querry[0],$querry[1]); +}else{ + &Header::showhttpheaders(); + + &Header::openpage('QoS', 1, ''); + &Header::openbigbox('100%', 'left', '', $errormessage); ############################################################################################################################ ############################################################################################################################ @@ -127,10 +148,10 @@ END ; close FILE; } else { - $qossettings{'ACTION'} = 'Parentklasse hinzufuegen'; + $qossettings{'ACTION'} = $Lang::tr{'parentclass add'}; } } -elsif ($qossettings{'DOCLASS'} eq 'Bearbeiten') +elsif ($qossettings{'DOCLASS'} eq $Lang::tr{'edit'}) { open( FILE, "< $classfile" ) or die "Unable to read $classfile"; @classes = ; @@ -159,7 +180,7 @@ elsif ($qossettings{'DOCLASS'} eq 'Bearbeiten') &Header::closepage(); exit } -elsif ($qossettings{'DOCLASS'} eq 'Loeschen') +elsif ($qossettings{'DOCLASS'} eq $Lang::tr{'delete'}) { open( FILE, "< $classfile" ) or die "Unable to read $classfile"; @tmp = ; @@ -205,9 +226,9 @@ END ; close FILE; } else { - $qossettings{'ACTION'} = 'Unterklasse hinzufuegen'; + $qossettings{'ACTION'} = $Lang::tr{'qos add subclass'}; } -} elsif ($qossettings{'DOSCLASS'} eq 'Loeschen') +} elsif ($qossettings{'DOSCLASS'} eq $Lang::tr{'delete'}) { open( FILE, "< $subclassfile" ) or die "Unable to read $classfile"; @tmp = ; @@ -231,15 +252,15 @@ END if ($qossettings{'DOLEVEL7'} eq $Lang::tr{'save'}) { if ( $qossettings{'QIP'} ne '' ) { - unless ( &General::validip($qossettings{'QIP'}) ) { + unless ( &General::validip($qossettings{'QIP'}) ) { $qossettings{'VALID'} = 'no'; - $message = "Die Quell-IP-Adresse ist ungueltig."; + $message = $Lang::tr{'The source IP address is invalid.'}; } } if ( $qossettings{'DIP'} ne '' ) { - unless ( &General::validip($qossettings{'DIP'}) ) { + unless ( &General::validip($qossettings{'DIP'}) ) { $qossettings{'VALID'} = 'no'; - $message = "Die Ziel-IP-Adresse ist ungueltig."; + $message = $Lang::tr{'The destination IP address is invalid.'}; } } if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) { @@ -259,9 +280,9 @@ END ; close FILE; } else { - $qossettings{'ACTION'} = 'Level7-Regel hinzufuegen'; + $qossettings{'ACTION'} = $Lang::tr{'Add Level7 rule'}; } -} elsif ($qossettings{'DOLEVEL7'} eq 'Loeschen') +} elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr{'delete'}) { open( FILE, "< $level7file" ) or die "Unable to read $level7file"; @l7rules = ; @@ -271,7 +292,7 @@ END { @l7ruleline = split( /\;/, $l7ruleentry ); if ( ($l7ruleline[0] eq $qossettings{'CLASS'}) && ($l7ruleline[2] eq $qossettings{'L7PROT'})) - {$message = "Level7-Regel ($qossettings{'CLASS'} - $qossettings{'L7PROT'}) wurde geloescht.";} + {$message = "$Lang::tr{'Level7 Rule'} ($qossettings{'CLASS'} - $qossettings{'L7PROT'}) $Lang::tr{'was deleted'}.";} else { open( FILE, ">> $level7file" ) or die "Unable to read $level7file"; print FILE $l7ruleentry; @@ -279,7 +300,7 @@ END } } open( FILE, "< $level7file" ) or system("touch $level7file");close FILE; - } elsif ($qossettings{'DOLEVEL7'} eq 'Bearbeiten') + } elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr{'edit'}) { open( FILE, "< $level7file" ) or die "Unable to read $level7file"; @l7rules = ; @@ -306,15 +327,15 @@ END if ($qossettings{'DOPORT'} eq $Lang::tr{'save'}) { if ( $qossettings{'QIP'} ne '' ) { - unless ( &General::validip($qossettings{'QIP'}) ) { + unless ( &General::validip($qossettings{'QIP'}) ) { $qossettings{'VALID'} = 'no'; - $message = "Die Quell-IP-Adresse ist ungueltig."; + $message = "$Lang::tr{'The source IP address is invalid.'}"; } } if ( $qossettings{'DIP'} ne '' ) { - unless ( &General::validip($qossettings{'DIP'}) ) { + unless ( &General::validip($qossettings{'DIP'}) ) { $qossettings{'VALID'} = 'no'; - $message = "Die Ziel-IP-Adresse ist ungueltig."; + $message = "$Lang::tr{'The destination IP address is invalid.'}"; } } if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) { @@ -334,9 +355,9 @@ END ; close FILE; } else { - $qossettings{'ACTION'} = 'Port-Regel hinzufuegen'; + $qossettings{'ACTION'} = $Lang::tr{'Add Port Rule'}; } -} elsif ($qossettings{'DOPORT'} eq 'Loeschen') +} elsif ($qossettings{'DOPORT'} eq $Lang::tr{'delete'}) { open( FILE, "< $portfile" ) or die "Unable to read $portfile"; @portrules = ; @@ -352,7 +373,7 @@ END } close FILE; $message = "$Lang::tr{'Port Rule'} ($qossettings{'CLASS'} - $qossettings{'PPROT'}) $Lang::tr{'was deleted'}."; -} elsif ($qossettings{'DOPORT'} eq 'Bearbeiten') +} elsif ($qossettings{'DOPORT'} eq $Lang::tr{'edit'}) { open( FILE, "< $portfile" ) or die "Unable to read $portfile"; @portrules = ; @@ -393,7 +414,7 @@ $qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'TOS'}; END ; close FILE; -} +} elsif ($qossettings{'DOTOS'} eq 'Loeschen') { open( FILE, "< $tosfile" ) or die "Unable to read $tosfile"; @@ -410,7 +431,7 @@ elsif ($qossettings{'DOTOS'} eq 'Loeschen') } close FILE; $message = "$Lang::tr{'TOS Rule'} ($qossettings{'CLASS'} - $qossettings{'TOS'}) $Lang::tr{'was deleted'}."; -} elsif ($qossettings{'DOTOS'} eq 'Bearbeiten') +} elsif ($qossettings{'DOTOS'} eq $Lang::tr{'edit'}) { open( FILE, "< $tosfile" ) or die "Unable to read $tosfile"; @tosrules = ; @@ -438,16 +459,16 @@ elsif ($qossettings{'DOTOS'} eq 'Loeschen') ############################################################################################################################ ############################################################################################################################ -if ($qossettings{'ACTION'} eq 'Start') +if ($qossettings{'ACTION'} eq $Lang::tr{'start'}) { + $qossettings{'ENABLED'} = 'on'; + &General::writehash("${General::swroot}/qos/settings", \%qossettings); system("/usr/local/bin/qosctrl generate >/dev/null 2>&1"); system("/usr/bin/touch /var/ipfire/qos/enable"); system("/usr/local/bin/qosctrl start >/dev/null 2>&1"); system("logger -t ipfire 'QoS started'"); - $qossettings{'ENABLED'} = 'on'; - &General::writehash("${General::swroot}/qos/settings", \%qossettings); } -elsif ($qossettings{'ACTION'} eq 'Stop') +elsif ($qossettings{'ACTION'} eq $Lang::tr{'stop'}) { system("/usr/local/bin/qosctrl stop >/dev/null 2>&1"); unlink "/var/ipfire/qos/bin/qos.sh"; @@ -456,7 +477,7 @@ elsif ($qossettings{'ACTION'} eq 'Stop') $qossettings{'ENABLED'} = 'off'; &General::writehash("${General::swroot}/qos/settings", \%qossettings); } -elsif ($qossettings{'ACTION'} eq 'Neustart') +elsif ($qossettings{'ACTION'} eq $Lang::tr{'restart'}) { if ($qossettings{'ENABLED'} eq 'on'){ system("/usr/local/bin/qosctrl stop >/dev/null 2>&1"); @@ -475,7 +496,101 @@ elsif ($qossettings{'ACTION'} eq $Lang::tr{'save'}) } &General::writehash("${General::swroot}/qos/settings", \%qossettings); } -elsif ($qossettings{'ACTION'} eq 'Statusinformationen') +elsif ($qossettings{'ACTION'} eq $Lang::tr{'template'} ) +{ + my @UP; + #print "UP
"; + for(my $i = 1; $i <= 10; $i++) { + $UP[$i] = int($qossettings{'OUT_SPD'} / $i ); + #print $i."=".$UP[$i]." "; + } + my @DOWN; + #print "

Down
"; + for(my $i = 1; $i <= 20; $i++) { + $DOWN[$i] = int($qossettings{'INC_SPD'} / $i); + #print $i."=".$DOWN[$i]." "; + } + open( FILE, "> $classfile" ) or die "Unable to write $classfile"; + print FILE < $level7file" ) or die "Unable to write $level7file"; + print FILE < $portfile" ) or die "Unable to write $portfile"; + print FILE </dev/null 2>&1"); + system("/usr/bin/touch /var/ipfire/qos/enable"); + system("/usr/local/bin/qosctrl start >/dev/null 2>&1"); + system("logger -t ipfire 'QoS started'"); +} +elsif ($qossettings{'ACTION'} eq $Lang::tr{'status'} ) { &Header::openbox('100%', 'left', 'QoS Status'); if ($qossettings{'ENABLED'} eq 'on'){ @@ -489,30 +604,30 @@ elsif ($qossettings{'ACTION'} eq 'Statusinformationen') &Header::closepage(); exit } -elsif ($qossettings{'ACTION'} eq 'Parentklasse hinzufuegen') +elsif ($qossettings{'ACTION'} eq $Lang::tr{'parentclass add'} ) { &parentclass(); &Header::closebigbox(); &Header::closepage(); exit } -elsif ($qossettings{'ACTION'} eq 'Unterklasse hinzufuegen') +elsif ($qossettings{'ACTION'} eq $Lang::tr{'qos add subclass'}) { &subclass(); &Header::closebigbox(); &Header::closepage(); exit } -elsif ($qossettings{'ACTION'} eq 'Regel hinzufuegen') +elsif ($qossettings{'ACTION'} eq $Lang::tr{'Add Rule'}) { &Header::openbox('100%', 'center', $Lang::tr{'Add Rule'}); print < $Lang::tr{'Choose Rule'} - - - + + + END ; @@ -542,21 +657,21 @@ END &Header::closepage(); exit } -elsif ($qossettings{'ACTION'} eq 'Erweiterte Einstellungen') +elsif ($qossettings{'ACTION'} eq "$Lang::tr{'urlfilter advanced settings'}" ) { &expert(); &Header::closebigbox(); &Header::closepage(); exit } -if ($qossettings{'ACTIONBW'} eq 'Andern') +if ($qossettings{'ACTIONBW'} eq "$Lang::tr{'modify'}" ) { &changebandwidth(); &Header::closebigbox(); &Header::closepage(); exit } -if ($qossettings{'ACTIONDEF'} eq 'Andern') +if ($qossettings{'ACTIONDEF'} eq "$Lang::tr{'modify'}" ) { &changedefclasses(); &Header::closebigbox(); @@ -601,8 +716,8 @@ END Quality of Service: $status - - + + END ; @@ -612,7 +727,7 @@ END
 
$Lang::tr{'downlink speed'}: $qossettings{'INC_SPD'} - +
$Lang::tr{'uplink speed'}: $qossettings{'OUT_SPD'}
END @@ -623,8 +738,8 @@ END
- -END -;} -else -{ -print $Lang::tr{'no information available'}; -} -print "\t

-
$Lang::tr{'downlink std class'}: $qossettings{'DEFCLASS_INC'} - +
$Lang::tr{'downlink std class'}: $qossettings{'DEFCLASS_INC'} +
$Lang::tr{'uplink std class'}: $qossettings{'DEFCLASS_OUT'}
ACKs: $qossettings{'ACK'}

@@ -633,9 +748,9 @@ END
-
- - +
+ +
END @@ -657,28 +772,12 @@ if ( ($qossettings{'DEFCLASS_INC'} eq '') || ($qossettings{'DEFCLASS_OUT'} eq '' exit } -&Header::openbox('100%', 'center', $Lang::tr{'info'}); -&Graphs::overviewgraph("3240",$qossettings{'RED_DEV'}); -&Graphs::overviewgraph("3240",$qossettings{'IMQ_DEV'}); -print < -
 $Lang::tr{'add subclass'} |  $Lang::tr{'Add Rule'} |  $Lang::tr{'edit'} |  $Lang::tr{'delete'}   -
$Lang::tr{'TOS Bits'}:  0 - $Lang::tr{'disabled'} | 8 - $Lang::tr{'min delay'} | 4 - $Lang::tr{'max throughput'} | 2 - $Lang::tr{'max reliability'} | 1 - $Lang::tr{'min costs'}   -END -; -if (( -e "/srv/web/ipfire/html/graphs/qos-graph-$qossettings{'RED_DEV'}-3240.png") && ( -e "/srv/web/ipfire/html/graphs/qos-graph-$qossettings{'IMQ_DEV'}-3240.png")) { - print <
"; - -&Header::closebox(); + &Header::openbox('100%', 'center', "$qossettings{'RED_DEV'} $Lang::tr{'graph'}"); + &Graphs::makegraphbox("qos.cgi",$qossettings{'RED_DEV'},"hour","325"); + &Header::closebox(); + &Header::openbox('100%', 'center', "$qossettings{'IMQ_DEV'} $Lang::tr{'graph'}"); + &Graphs::makegraphbox("qos.cgi",$qossettings{'IMQ_DEV'},"hour","325"); + &Header::closebox(); &showclasses($qossettings{'RED_DEV'}); &showclasses($qossettings{'IMQ_DEV'}); @@ -686,6 +785,8 @@ print "\t"; &Header::closebigbox(); &Header::closepage(); +} + ############################################################################################################################ ############################################################################################################################ @@ -701,7 +802,7 @@ END for ( $c = 200 ; $c <= 220 ; $c++ ) { if ( $qossettings{'DEFCLASS_INC'} ne $c ) - { print "\n"; } + { print "\n"; } else { print "\n"; } } print < - + + + + +
$Lang::tr{'down and up speed'} -
$Lang::tr{'downlink speed'}: - -   -
$Lang::tr{'uplink speed'}: - -   +
$Lang::tr{'down and up speed'}
$Lang::tr{'downlink speed'}:

$Lang::tr{'uplink speed'}:
+ $Lang::tr{'template warning'} END ; } @@ -774,7 +875,7 @@ END if ( $message ne "" ) { print "$message"; } - if ( $qossettings{'EDIT'} eq 'yes' ) { + if ( $qossettings{'EDIT'} eq 'yes' ) { print ""; print ""; } @@ -784,7 +885,7 @@ END END ; - if ( $qossettings{'EDIT'} eq 'yes' ) { + if ( $qossettings{'EDIT'} eq 'yes' ) { print ""; @@ -801,7 +902,7 @@ END $Lang::tr{'Class'}: END ; - if ( $qossettings{'EDIT'} eq 'yes' ) { + if ( $qossettings{'EDIT'} eq 'yes' ) { print ""; @@ -846,13 +947,17 @@ END Ceilburst:   +END +; + $selected{'TOS'}{$qossettings{'TOS'}} = "selected='selected'"; +print <TOS-Bit: + + + + +   $Lang::tr{'remark'}: @@ -965,7 +1070,7 @@ END next if -d "/etc/l7-protocols/protocols/$direntry"; @proto = split( /\./, $direntry ); if ( $proto[0] eq $qossettings{'L7PROT'} ) { - print "\n"; + print "\n"; } else { print "\n"; } @@ -979,6 +1084,7 @@ END $Lang::tr{'destination ip'}: + $Lang::tr{'qos warning'} END ; @@ -1003,7 +1109,7 @@ END @tmpline = split( /\ /, $direntry ); next if $tmpline[0] =~ "#"; if ( $tmpline[0] eq $qossettings{'PPROT'} ) { - print "\n"; + print "\n"; } else { print "\n"; } @@ -1047,7 +1153,7 @@ END $Lang::tr{'min delay'} (8) $Lang::tr{'max throughput'} (4) $Lang::tr{'max reliability'} (2) - + $Lang::tr{'min costs'} (1) END @@ -1078,7 +1184,7 @@ sub showclasses { @classline = split( /\;/, $classentry ); if ( $classline[0] eq $qossettings{'DEV'} ) { - &Header::openbox('100%', 'center', "Klasse: $classline[1]"); + &Header::openbox('100%', 'center', "$Lang::tr{'Class'}: $classline[1]"); print < $Lang::tr{'interface'} @@ -1102,22 +1208,22 @@ sub showclasses {
- +
- +
- +
- +
@@ -1142,14 +1248,14 @@ END
- - + +
- - + +
END @@ -1185,14 +1291,14 @@ END ; if ($portruleline[4]) { print <Quell-Port: $portruleline[4] + $Lang::tr{'source port'}: $portruleline[4] END ; } print ""; if ($portruleline[6]) { print <Ziel-Port: $portruleline[6] + $Lang::tr{'destination port'}: $portruleline[6] END ; } @@ -1207,7 +1313,7 @@ END - +
@@ -1217,7 +1323,7 @@ END - +
@@ -1265,14 +1371,14 @@ END - +
- +
@@ -1300,17 +1406,17 @@ END
- +
- +
- +
@@ -1390,7 +1496,7 @@ sub validclass { } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) { if ($qossettings{'CLASS'} lt 200 || $qossettings{'CLASS'} ge 221) { $qossettings{'VALID'} = 'no'; - $message = "Die Klassennummer passt nicht zum angegebenen Interface."; + $message = "$Lang::tr{'The class number does not match the specified interface.'}"; } } open( FILE, "< $classfile" ) or die "Unable to read $classfile";