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