def __init__(self, file_name, allowed_names, options):
        """
        @param allowed_names: a dictionary of name: regex_list values from
            the server. This gets turned into a dictionary of AllowedSite
            objects
        """
        DaemonBase.__init__(self, options)
        self.max_log_size = options.max_log_size
        self.file_name = file_name
        self.allowed_names = allowed_names
        self.allowed_sites = {}
        from pprint import pprint

        pprint(allowed_names)
        for name, regex_strings in allowed_names.iteritems():
            self.allowed_sites[name] = AllowedSite(name, regex_strings, options)

        self.generic_matcher = re.compile("reply\s(\S+)\sis\s([<CNAME>\d\.]+)")
        self.watch_for_cname = None
        self.options = options
        cmds = ["iptables -F %s" % IPTABLES_TARGET, "iptables -A %s -j REJECT" % (IPTABLES_TARGET)]
        self._implement_rules(cmds)
        self.current_position = 0

        self.ip_cache = {}
        self.cname_cache = {}
        self.published_ips = set()
        self.file_handle = None
        if options.prep_system:
            self.prep_system()
        self._open_file()
 def __init__(self, options):
     DaemonBase.__init__(self, options)
     self.kill_switch = False
     self.loops = 0
     self.downloader = Downloader(options)
     self.uploader = Uploader(options)
     self.allowed_traffic = self.downloader.get_allowed_traffic()
     self.policy_mgr = PolicyMgr("/tmp/dnsmasq.log", self.allowed_traffic,
         self.options)
     self.policy_mgr.prep_system()
     self.policy_mgr.initial_load()
     self.policy_mgr.rotate_log()
 def __init__(self, options):
     DaemonBase.__init__(self, options)