Introduce local blacklists

This commit is contained in:
Glen Pit-Pladdy
2017-04-11 12:17:23 +01:00
parent d52f1ba7de
commit 495f7a8e4c
4 changed files with 29 additions and 8 deletions

View File

@@ -90,9 +90,9 @@ for source in config['blacklists']:
# all done
data = response.data
# we are good to go
outputdata += ";=============================================================================\n"
outputdata += "; Source: %s :: %s\n" % (source,config['blacklists'][source]['url'])
outputdata += ";=============================================================================\n\n"
outputdata += "\n%s=============================================================================\n" % commentstart
outputdata += "%s Source: %s :: %s\n" % (commentstart,source,config['blacklists'][source]['url'])
outputdata += "%s=============================================================================\n\n" % commentstart
# process data
recordcount = 0
if config['blacklists'][source]['format'] == 'hosts':
@@ -110,7 +110,6 @@ for source in config['blacklists']:
for host in hostlist[1:]:
recordcount += 1
addhost ( host )
seenbefore[host.lower()] = source
elif config['blacklists'][source]['format'] == 'raw':
# comments start "#"
for line in data.splitlines():
@@ -127,6 +126,14 @@ for source in config['blacklists']:
if recordcount == 0:
sys.exit ( "Got recordcount of %d for %s" % (recordcount,source) )
# if we have a local blacklist, add that also
if 'localblacklist' in config:
outputdata += "\n%s=============================================================================\n" % commentstart
outputdata += "%s Source: Local blacklist from %s\n" % (commentstart,configfile)
outputdata += "%s=============================================================================\n\n" % commentstart
for host in config['localblacklist']:
addhost ( host )
# write the config['rpzfile'] file
with open ( config['rpzfile']+'.TMP', 'wt' ) as f:

View File

@@ -37,3 +37,7 @@ exclusions:
pagead.l.doubleclick.net: True # CNAME for www.googleadservices.com needed for google shopping
# Note that "localhost" is always excluded t prevent conflicts
# we can also add our own local backlist
#localblacklist:
# - evilhost.example.com # going there does evil stuff

View File

@@ -96,9 +96,9 @@ for source in config['blacklists']:
# all done
data = response.data
# we are good to go
outputdata += "#=============================================================================\n"
outputdata += "# Source: %s :: %s\n" % (source,config['blacklists'][source]['url'])
outputdata += "#=============================================================================\n\n"
outputdata += "\n%s=============================================================================\n" % commentstart
outputdata += "%s Source: %s :: %s\n" % (commentstart,source,config['blacklists'][source]['url'])
outputdata += "%s=============================================================================\n\n" % commentstart
# process data
recordcount = 0
if config['blacklists'][source]['format'] == 'hosts':
@@ -116,7 +116,6 @@ for source in config['blacklists']:
for host in hostlist[1:]:
recordcount += 1
addhost ( host )
seenbefore[host.lower()] = source
elif config['blacklists'][source]['format'] == 'raw':
# comments start "#"
for line in data.splitlines():
@@ -133,6 +132,13 @@ for source in config['blacklists']:
if recordcount == 0:
sys.exit ( "Got recordcount of %d for %s" % (recordcount,source) )
# if we have a local blacklist, add that also
if 'localblacklist' in config:
outputdata += "\n%s=============================================================================\n" % commentstart
outputdata += "%s Source: Local blacklist from %s\n" % (commentstart,configfile)
outputdata += "%s=============================================================================\n\n" % commentstart
for host in config['localblacklist']:
addhost ( host )
# write the config['hostsfile'] file
with open ( config['hostsfile']+'.TMP', 'wt' ) as f:

View File

@@ -55,3 +55,7 @@ exclusions:
pagead.l.doubleclick.net: True # CNAME for www.googleadservices.com needed for google shopping
# Note that "localhost" is always excluded t prevent conflicts
# we can also add our own local backlist
#localblacklist:
# - evilhost.example.com # going there does evil stuff