#!/usr/bin/perl -w # # pre-rbldns-data # jms1@jms1.net 2002-12-13 # # Used as a pre-processing filter for "rbldns" data files. Finds a "default" # IP address (usually found on the first line of the file) and then copies # the input file to an output file, adding the default IP to any lines which # skipped over the IP address portion of the line. # # Example: for this input file # # :127.0.0.4:We don't accept mail from $ # 10.0.0.0/8::Internal only # # this program will generate the following output: # # :127.0.0.4:We don't accept mail from $ # 10.0.0.0/8:127.0.0.4:Internal only # # This data file would be compatible with "rbldns-data" as patched by my # "djbdns-1.05-rbldns.patch" file, which can be downloaded from my web # site at http://www.jms1.net/djbdns/rbldns-patch.html # # 2003-07-22 jms1: adding specific GPL notice # ############################################################################### # # Copyright (C) 2003 John Simpson. # # 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 2 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, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # or visit http://www.gnu.org/licenses/gpl.txt # ############################################################################### require 5.003 ; use strict ; my $infile = ( shift || die "No input filename specified.\n" ) ; my $outfile = ( shift || die "No output filename specified.\n" ) ; my $default = "" ; open ( I , "<$infile" ) or die "Can\'t read $infile: $!\n" ; open ( O , ">$outfile" ) or die "Can\'t create $outfile: $!\n" ; while ( my $line = ) { next unless ( $line =~ /^\:([\d\.]+)\:/ ) ; $default = $1 ; last ; } seek ( I , 0 , 0 ) ; while ( my $line = ) { $line =~ s/\:\:/\:$default\:/ ; print O $line ; } close O ; close I ;