Line 138: |
Line 138: |
| | | |
| { | | { |
− | <nowiki> </nowiki> use esmith::ConfigDB;
| + | use esmith::ConfigDB; |
− | <nowiki> </nowiki> my $db = esmith::ConfigDB->open_ro || die 'Could not open configuration database';
| + | my $db = esmith::ConfigDB->open_ro |
− | <nowiki> </nowiki> # Completely block any riff raff
| + | || die 'Could not open configuration database'; |
− | <nowiki> </nowiki> if ( ( my $status = $db->get_prop( 'ipblock', 'status' ) ) eq 'enabled' ) {
| + | # Completely block any riff raff |
− | <nowiki> </nowiki> my $DenyHosts = $db->get_prop( 'ipblock', 'DenyHosts' ) || <nowiki>''</nowiki>'';
| + | if ( ( my $status = $db->get_prop( 'ipblock', 'status' ) ) eq 'enabled' ) |
− | my $logging = $db->get_prop( 'ipblock', 'logging' ) || 'disabled'; | + | { |
− | foreach my $host ( split( ',', $DenyHosts ) ) {
| + | my $DenyHosts = $db->get_prop( 'ipblock', 'DenyHosts' ) || <nowiki>''</nowiki>''; |
− | $OUT .= "\n";
| + | if ( $DenyHosts ne <nowiki>''</nowiki> ) { |
− | $OUT .= " # Simple IP block for riff raff\n\n";
| + | my $logging = $db->get_prop( 'ipblock', 'logging' ) || 'disabled'; |
− | if ( $logging eq 'enabled' ) {
| + | foreach my $host ( split( ',', $DenyHosts ) ) { |
− | $OUT .= " /sbin/iptables -A INPUT -s $host -j denylog\n"; | + | $OUT .= "\n"; |
| + | $OUT .= "# Simple ipblock for riff raff\n\n"; |
| + | if ( $logging eq 'enabled' ) { |
| + | $OUT .= "/sbin/iptables -A INPUT -s $host -j denylog\n"; |
| + | } |
| + | else { |
| + | $OUT .= "/sbin/iptables -A INPUT -s $host -j DROP\n"; |
| + | } |
| + | $OUT .= "\n"; |
| } | | } |
− | else {
| |
− | $OUT .= " /sbin/iptables -A INPUT -s $host -j DROP\n";
| |
− | }
| |
− | $OUT .= "\n";
| |
| } | | } |
| + | else { |
| + | $OUT .= "# ipblock no DenyHosts set\n"; |
| + | } |
| + | } |
| + | else { |
| + | $OUT .= "# ipblock disabled\n"; |
| } | | } |
| } | | } |