mirror of
https://gitlab.com/shorewall/code.git
synced 2025-06-20 17:58:07 +02:00
Unify handling of ULOG/NFLOG
git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@7691 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
parent
6e12f5ab06
commit
1c293a8386
@ -1162,9 +1162,15 @@ my %validlevels = ( debug => 7,
|
|||||||
ULOG => 'ULOG',
|
ULOG => 'ULOG',
|
||||||
NFLOG => 'NFLOG');
|
NFLOG => 'NFLOG');
|
||||||
|
|
||||||
|
my @suffixes = qw(group range threshhold);
|
||||||
|
|
||||||
#
|
#
|
||||||
# Validate a log level -- Drop the trailing '!' and translate to numeric value if appropriate"
|
# Validate a log level -- Drop the trailing '!' and translate to numeric value if appropriate"
|
||||||
#
|
#
|
||||||
|
sub level_error( $ ) {
|
||||||
|
fatal_error "Invalid log level ($_[0])";
|
||||||
|
}
|
||||||
|
|
||||||
sub validate_level( $ ) {
|
sub validate_level( $ ) {
|
||||||
my $level = $_[0];
|
my $level = $_[0];
|
||||||
|
|
||||||
@ -1174,37 +1180,31 @@ sub validate_level( $ ) {
|
|||||||
return $value if defined $value;
|
return $value if defined $value;
|
||||||
return $level if $level =~ /^[0-7]$/;
|
return $level if $level =~ /^[0-7]$/;
|
||||||
|
|
||||||
if ( $level =~ /^NFLOG[(](.*)[)]$/ ) {
|
if ( $level =~ /^(NFLOG|ULOG)[(](.*)[)]$/ ) {
|
||||||
my @options = split /,/, $1;
|
my $olevel = $1;
|
||||||
|
my @options = split /,/, $2;
|
||||||
$level = 'NFLOG';
|
my $prefix = lc $olevel;
|
||||||
$level .= " --nflog-group $options[0]" if defined $options[0] && $options[0] ne '';
|
my $index = 0;
|
||||||
$level .= " --nflog-range $options[1]" if defined $options[1] && $options[1] ne '';
|
|
||||||
$level .= " --nflog-threshhold $options[2]" if defined $options[2] && $options[2] ne '';
|
level_error( $level ) if @options > 3;
|
||||||
|
|
||||||
|
for ( @options ) {
|
||||||
|
if ( defined $_ and $_ ne '' ) {
|
||||||
|
level_error( $level ) unless /^\d+/;
|
||||||
|
$olevel .= " --${prefix}-$suffixes[$index] $_";
|
||||||
|
}
|
||||||
|
|
||||||
|
$index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $olevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $level =~ /^NFLOG --/ or $level =~ /^ULOG --/ ) {
|
||||||
return $level;
|
return $level;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $level =~ /^NFLOG --/ ) {
|
level_error( $level );
|
||||||
return $level;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $level =~ /^ULOG[(](.*)[)]$/ ) {
|
|
||||||
my @options = split /,/, $1;
|
|
||||||
|
|
||||||
$level = 'ULOG';
|
|
||||||
$level .= " --ulog-group $options[0]" if defined $options[0] && $options[0] ne '';
|
|
||||||
$level .= " --ulog-range $options[1]" if defined $options[1] && $options[1] ne '';
|
|
||||||
$level .= " --ulog-threshhold $options[2]" if defined $options[2] && $options[2] ne '';
|
|
||||||
|
|
||||||
return $level;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $level =~ /^ULOG --/ ) {
|
|
||||||
return $level;
|
|
||||||
}
|
|
||||||
|
|
||||||
fatal_error "Invalid log level ($level)";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
'';
|
'';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user