parent
62d92d3c91
commit
ea325b0686
@ -81,6 +81,27 @@ def create_app():
|
||||
'operation': 'flush',
|
||||
'result': [x.decode('ascii') for x in res]})
|
||||
|
||||
@app.route("/list/<name>", methods=['GET'])
|
||||
@auth.login_required
|
||||
def list_table(name):
|
||||
remote_user = auth.username()
|
||||
name = untaint(PAT_NAME, name)
|
||||
app.logger.info(f'Flushing table f2b-{name}'
|
||||
f' in anchor f2b-jail/{remote_user}')
|
||||
res = pfctl_table_op('f2b-jail/{remote_user}',
|
||||
table='f2b-{name}',
|
||||
operation='show',
|
||||
verbose=True)
|
||||
result = [entry.groupdict() for entry in
|
||||
re.finditer(_PFCTL_TABLE_PAT,
|
||||
'\n'.join(res),
|
||||
re.MULTILINE|re.VERBOSE)]
|
||||
|
||||
return jsonify({'anchor': f'f2b-jail/{remote_user}',
|
||||
'table': f'f2b-{name}',
|
||||
'operation': 'list',
|
||||
'result': result })
|
||||
|
||||
@app.route("/register", methods=['PUT', 'DELETE'])
|
||||
@auth.login_required
|
||||
def register():
|
||||
|
@ -44,7 +44,8 @@ def pfctl_table_op(anchor, **kwargs):
|
||||
table = kwargs['table']
|
||||
operation = kwargs['operation']
|
||||
value = kwargs['value'] if 'value' in kwargs else None
|
||||
cmd = [_SUDO, _PFCTL, '-a', anchor, '-t', table, '-T', operation, value]
|
||||
verbose = '-v' if 'verbose' in kwargs and kwargs['verbose'] else None
|
||||
cmd = [_SUDO, _PFCTL, '-a', anchor, '-t', table, verbose, '-T', operation, value]
|
||||
|
||||
logging.info('Running %s', cmd)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user