blockinator/apache.py

30 lines
800 B
Python
Raw Permalink Normal View History

#!/usr/bin/python
"""Script to create a simple mod_access style list for inclusion
within Apache."""
2012-05-21 19:08:04 +01:00
import blocklist
import sys
class ApacheBlockList(blocklist.BlockList):
"""New class that extends the main BlockList class for use with Apache."""
def export(self):
2013-07-13 08:44:35 +01:00
"""Exports the blocklist addresses with use within Apache."""
print "\tOrder deny,allow"
for address in self.data.keys():
print "\tDeny from %s/32" % address
print "\tAllow from all"
2012-05-21 19:08:04 +01:00
2013-07-13 08:44:35 +01:00
def main():
"""Main program loop."""
block_list = ApacheBlockList()
2012-05-21 19:08:04 +01:00
2013-07-13 08:44:35 +01:00
block_list.read("http://server1.example.com/default/blocks.txt")
block_list.read("http://server2.example.com/default/blocks.txt")
2012-05-21 19:08:04 +01:00
2013-07-13 08:44:35 +01:00
block_list.export()
2012-05-21 19:08:04 +01:00
sys.exit(0)
2013-07-13 08:44:35 +01:00
if __name__ == "__main__":
main()