Skip to content

Commit

Permalink
OSX fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jcameron committed Feb 28, 2008
1 parent cd4565a commit ed708d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 2 additions & 0 deletions bandwidth/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ Firewall rules are now correctly created even when using Shorewall, by adding th
The module now also supports the IPFilter firewall, although counts may not be accurate on fast network interfaces, as IPFilter appears to not log all packets.
---- Changes since 1.390 ----
Bandwidth monitoring can now be setup on an interface that isn't currently active, including patterns like ppp+.
---- Changes since 1.400 ----
Fixed several bugs that prevented bandwidth monitoring from working properly on FreeBSD and OSX.
17 changes: 9 additions & 8 deletions bandwidth/bandwidth-lib.pl
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ sub find_sysconf
{
local ($conf) = @_;
local $c;
local @ll = &get_loglevel();
foreach $c (@$conf) {
next if (!$c->{'active'});
next if ($c->{'file'} ne $bandwidth_log);
next if ($c->{'sel'}->[0] ne &get_loglevel());
next if ($c->{'sel'}->[0] ne $ll[0]);
return $c;
}
return undef;
Expand Down Expand Up @@ -386,7 +387,7 @@ sub process_firewall_line
# get_firewall_loglevel()
sub get_firewall_loglevel
{
return "kern.=debug";
return ( "kern.=debug" );
}

############### functions for ipfw #################
Expand Down Expand Up @@ -477,10 +478,10 @@ sub pre_ipfw_process
sub process_ipfw_line
{
local ($line, $hours, $time_now) = @_;
if ($line =~ /^(\S+)\s+(\d+)\s+(\d+):(\d+):(\d+).*ipfw:\s+\S+\s+Accept\s+(\S+)\s+(\S+)\s+(\S+)\s+(in|out)\s+via\s+(\S+)/) {
if ($line =~ /^(\S+)\s+(\d+)\s+(\d+):(\d+):(\d+).*ipfw:\s+\S+\s+(Accept|Count)\s+(\S+)\s+(\S+)\s+(\S+)\s+(in|out)\s+via\s+(\S+)/) {
# Found a valid line
local ($mon, $day, $hr, $min, $sec) = ($1, $2, $3, $4, $5);
local ($proto, $src, $dest, $dir, $iface) = ($6, $7, $8, $9, $10);
local ($proto, $src, $dest, $dir, $iface) = ($7, $8, $9, $10, $11);
local ($srchost, $srcport) = split(/:/, $src);
local ($desthost, $destport) = split(/:/, $dest);
$proto =~ s/:.*//;
Expand Down Expand Up @@ -510,7 +511,7 @@ sub process_ipfw_line
$port = '_'.$srcport.'_'.$destport;
}
}
local $host = $dir eq "in" ? $dest : $src;
local $host = $dir eq "in" ? $desthost : $srchost;
local $key = $host.'_'.$proto.$port;
local ($in, $out) = split(/ /, $hour->{$key});
if ($dir eq "in") {
Expand All @@ -532,7 +533,7 @@ sub process_ipfw_line
# get_ipfw_loglevel()
sub get_ipfw_loglevel
{
return "security.*";
return ( "security.*", "kern.debug" );
}

############### functions for Shorewall #################
Expand Down Expand Up @@ -626,7 +627,7 @@ sub find_shorewall_rule
# get_shorewall_loglevel()
sub get_shorewall_loglevel
{
return "kern.=debug";
return ( "kern.=debug" );
}

sub process_shorewall_line
Expand Down Expand Up @@ -776,7 +777,7 @@ sub process_ipfilter_line
# get_ipfilter_loglevel()
sub get_ipfilter_loglevel
{
return "local7.debug";
return ( "local7.debug" );
}

1;
Expand Down
3 changes: 2 additions & 1 deletion bandwidth/setup.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ else {
}
if (!$filter) {
# Create filter for facility and level
($fac, $lvl) = split(/\./, &get_loglevel());
local @ll = &get_loglevel();
($fac, $lvl) = split(/\./, $ll[0]);
$lvl =~ s/^=//;
$filter = { 'name' => 'filter',
'type' => 1,
Expand Down

0 comments on commit ed708d7

Please sign in to comment.