fix: Cleanup cloudflare module.

pull/591/head
Raphaël Vinot 2023-01-30 16:26:46 +01:00
parent ecb4623b86
commit 9273b80602
1 changed files with 2 additions and 14 deletions

View File

@ -2,12 +2,10 @@
import ipaddress import ipaddress
import logging import logging
from typing import Dict, List from typing import Dict, Set
import requests import requests
from har2tree import CrawledTree
from ..default import ConfigError, get_config from ..default import ConfigError, get_config
@ -41,17 +39,7 @@ class Cloudflare():
self.v4_list = [ipaddress.ip_network(net) for net in ipv4_list.split('\n')] self.v4_list = [ipaddress.ip_network(net) for net in ipv4_list.split('\n')]
self.v6_list = [ipaddress.ip_network(net) for net in ipv6_list.split('\n')] self.v6_list = [ipaddress.ip_network(net) for net in ipv6_list.split('\n')]
def capture_default_trigger(self, crawled_tree: CrawledTree, /, *, auto_trigger: bool=False) -> Dict: def ips_lookup(self, ips: Set[str]) -> Dict[str, bool]:
'''Run the module on all the nodes up to the final redirect'''
if not self.available:
return {'error': 'Module not available'}
if auto_trigger and not self.allow_auto_trigger:
return {'error': 'Auto trigger not allowed on module'}
# TODO: trigger something?
return {'success': 'Module triggered'}
def ips_lookup(self, ips: List[str]) -> Dict[str, bool]:
'''Lookup a list of IPs. True means it is a known Cloudflare IP''' '''Lookup a list of IPs. True means it is a known Cloudflare IP'''
if not self.available: if not self.available:
raise ConfigError('Hashlookup not available, probably not enabled.') raise ConfigError('Hashlookup not available, probably not enabled.')