Try the pfctl_table_op and set http code accordingly
This commit is contained in:
parent
d43a574579
commit
dd66bf3dc9
@ -88,10 +88,17 @@ def create_app():
|
||||
name = untaint(PAT_NAME, name)
|
||||
app.logger.info(f'Flushing table f2b-{name}'
|
||||
f' in anchor f2b-jail/{remote_user}')
|
||||
try:
|
||||
res = pfctl_table_op('f2b-jail/{remote_user}',
|
||||
table='f2b-{name}',
|
||||
operation='show',
|
||||
verbose=True)
|
||||
except CalledProcessError as err:
|
||||
if err.stderr.find(b'pfctl: Table does not exist.') > 0:
|
||||
res = []
|
||||
else:
|
||||
raise err
|
||||
|
||||
result = [entry.groupdict() for entry in
|
||||
re.finditer(_PFCTL_TABLE_PAT,
|
||||
'\n'.join([x.decode('ascii') for x in res]),
|
||||
@ -100,7 +107,7 @@ def create_app():
|
||||
return jsonify({'anchor': f'f2b-jail/{remote_user}',
|
||||
'table': f'f2b-{name}',
|
||||
'operation': 'list',
|
||||
'result': result })
|
||||
'result': result }), 200 if len(res) else 404
|
||||
|
||||
@app.route("/register", methods=['PUT', 'DELETE'])
|
||||
@auth.login_required
|
||||
|
Loading…
x
Reference in New Issue
Block a user