mirror of
https://github.com/nikdoof/rpzhole.git
synced 2025-12-23 22:59:24 +00:00
Introduce local blacklists
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user