def create_hosts(rootdir, confdata): f = codecs.open(os.path.join(rootdir, confdata['hosts']['meta']), "r", "utf-8") meta = json.loads(f.read(), object_pairs_hook=collections.OrderedDict) f.close() disabled = load_file(os.path.join(rootdir, confdata['hosts']['disabled'])) data = load_file(os.path.join(rootdir, confdata['hosts']['data'])) enable = int(confdata['hosts']['enable'])!=0 return FireflyHosts(enable, data, meta, disabled)
def create_hosts(rootdir, confdata): f = codecs.open(os.path.join(rootdir, confdata['hosts']['meta']), "r", "utf-8") meta = json.loads(f.read(), object_pairs_hook=collections.OrderedDict) f.close() disabled = load_file(os.path.join(rootdir, confdata['hosts']['disabled'])) data = load_file(os.path.join(rootdir, confdata['hosts']['data'])) enable = int(confdata['hosts']['enable']) != 0 return FireflyHosts(enable, data, meta, disabled)
def create_matcher(rootdir, confdata, circumvention_url): hosts = create_hosts(rootdir, confdata) f = codecs.open(os.path.join(rootdir, confdata["blacklist_meta"]), "r", "utf-8") meta = json.loads(f.read(), object_pairs_hook=collections.OrderedDict) f.close() blacklist = load_file(os.path.join(rootdir, confdata["blacklist"])) custom_blacklist = load_file(os.path.join(rootdir, confdata["custom_blacklist"])) custom_whitelist = load_file(os.path.join(rootdir, confdata["custom_whitelist"])) return FireflyMatcher( hosts, BlacklistMatcher(meta, blacklist, custom_blacklist, custom_whitelist, urlparse(circumvention_url)) )
def create_matcher(rootdir, confdata, circumvention_url): hosts = create_hosts(rootdir, confdata) f = codecs.open(os.path.join(rootdir, confdata['blacklist_meta']), "r", "utf-8") meta = json.loads(f.read(), object_pairs_hook=collections.OrderedDict) f.close() blacklist = load_file(os.path.join(rootdir, confdata['blacklist'])) custom_blacklist = load_file( os.path.join(rootdir, confdata['custom_blacklist'])) custom_whitelist = load_file( os.path.join(rootdir, confdata['custom_whitelist'])) return FireflyMatcher( hosts, BlacklistMatcher(meta, blacklist, custom_blacklist, custom_whitelist, urlparse(circumvention_url)))