configurable glob

This commit is contained in:
n.diaz
2024-11-25 19:45:11 +01:00
parent 86c4366724
commit 839685af30

View File

@ -15,12 +15,12 @@ from rich import print
base_path = Path('/var/opt/waf')
conf_file = base_path / 'config.yml'
if conf_file.exists():
conf = yaml.safe_load(conf_file.text())
else:
conf = {
'vroots': "/srv",
'logs_glob': "*/logs/*access*.log",
'whitelist_ips': [
'127.0.0.1',
],
@ -31,9 +31,6 @@ else:
conf_file.touch()
yaml.dump(conf, conf_file.open('w'))
# db_path = base_path / 'waf.db'
now = arrow.utcnow()
older_than = now.shift(days=-3).floor('day')
last_hour = now.shift(hours=-1).floor('hour')
@ -42,8 +39,7 @@ last_thirty_min = now.shift(minutes=-30)
# Configuring
db_path = base_path / conf['db_filename']
date_range = globals()[conf['date_range']]
vroots = Path(conf['vroots'])
logs = vroots.glob('*/logs/*access*.log')
logs = Path(conf['vroots']).glob(conf['logs_glob'])
whitelist_ips = conf['whitelist_ips']
# Database