mirror of
https://github.com/ziirish/burp-ui.git
synced 2026-05-15 14:16:08 -06:00
rename the 'async' backend into 'parallel' in order to be compliant with python 3.7
This commit is contained in:
parent
a3eda48012
commit
ea2d374d85
17 changed files with 140 additions and 129 deletions
|
|
@ -101,7 +101,7 @@ class Api(ApiPlus):
|
|||
release = __release__
|
||||
__doc__ = __doc__
|
||||
__url__ = __url__
|
||||
CELERY_REQUIRED = ['async']
|
||||
CELERY_REQUIRED = ['tasks']
|
||||
|
||||
def load_all(self):
|
||||
if config['WITH_LIMIT']:
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# -*- coding: utf8 -*-
|
||||
"""
|
||||
.. module:: burpui.api.async
|
||||
.. module:: burpui.api.tasks
|
||||
:platform: Unix
|
||||
:synopsis: Burp-UI async api module.
|
||||
:synopsis: Burp-UI tasks api module.
|
||||
|
||||
.. moduleauthor:: Ziirish <hi+burpui@ziirish.me>
|
||||
|
||||
|
|
@ -42,17 +42,17 @@ else:
|
|||
db = None
|
||||
|
||||
bui = current_app # type: BUIServer
|
||||
ns = api.namespace('async', 'Asynchronous methods')
|
||||
ns = api.namespace('tasks', 'Asynchronous tasks methods')
|
||||
|
||||
task_types = {
|
||||
'restore': (perform_restore, '.async_get_file'),
|
||||
'browse': (load_all_tree, '.async_do_browse_all'),
|
||||
'restore': (perform_restore, '.task_get_file'),
|
||||
'browse': (load_all_tree, '.task_do_browse_all'),
|
||||
}
|
||||
|
||||
|
||||
@ns.route('/status/<task_type>/<task_id>',
|
||||
'/<server>/status/<task_type>/<task_id>',
|
||||
endpoint='async_status')
|
||||
endpoint='task_status')
|
||||
@ns.doc(
|
||||
params={
|
||||
'server': 'Which server to collect data from when in multi-agent mode',
|
||||
|
|
@ -60,11 +60,11 @@ task_types = {
|
|||
'task_type': 'The task type (either "restore" or "browse")',
|
||||
}
|
||||
)
|
||||
class AsyncStatus(Resource):
|
||||
"""The :class:`burpui.api.async.AsyncStatus` resource allows you to
|
||||
class TaskStatus(Resource):
|
||||
"""The :class:`burpui.api.tasks.TaskStatus` resource allows you to
|
||||
follow a restore task.
|
||||
|
||||
This resource is part of the :mod:`burpui.api.async` module.
|
||||
This resource is part of the :mod:`burpui.api.tasks` module.
|
||||
"""
|
||||
if config['WITH_LIMIT']:
|
||||
try:
|
||||
|
|
@ -140,18 +140,18 @@ class AsyncStatus(Resource):
|
|||
|
||||
@ns.route('/get/<task_id>',
|
||||
'/<server>/get/<task_id>',
|
||||
endpoint='async_get_file')
|
||||
endpoint='task_get_file')
|
||||
@ns.doc(
|
||||
params={
|
||||
'server': 'Which server to collect data from when in multi-agent mode',
|
||||
'task_id': 'The task ID to process',
|
||||
}
|
||||
)
|
||||
class AsyncGetFile(Resource):
|
||||
"""The :class:`burpui.api.async.AsyncGetFile` resource allows you to
|
||||
class TaskGetFile(Resource):
|
||||
"""The :class:`burpui.api.tasks.TaskGetFile` resource allows you to
|
||||
retrieve the archive generated by the given task.
|
||||
|
||||
This resource is part of the :mod:`burpui.api.async` module.
|
||||
This resource is part of the :mod:`burpui.api.tasks` module.
|
||||
"""
|
||||
|
||||
@ns.doc(
|
||||
|
|
@ -285,7 +285,7 @@ class AsyncGetFile(Resource):
|
|||
|
||||
@ns.route('/archive/<name>/<int:backup>',
|
||||
'/<server>/archive/<name>/<int:backup>',
|
||||
endpoint='async_restore')
|
||||
endpoint='task_restore')
|
||||
@ns.doc(
|
||||
params={
|
||||
'server': 'Which server to collect data from when in multi-agent mode',
|
||||
|
|
@ -293,11 +293,11 @@ class AsyncGetFile(Resource):
|
|||
'backup': 'Backup number',
|
||||
},
|
||||
)
|
||||
class AsyncRestore(Resource):
|
||||
"""The :class:`burpui.api.async.AsyncRestore` resource allows you to
|
||||
class TaskRestore(Resource):
|
||||
"""The :class:`burpui.api.tasks.TaskRestore` resource allows you to
|
||||
perform a file restoration.
|
||||
|
||||
This resource is part of the :mod:`burpui.api.async` module.
|
||||
This resource is part of the :mod:`burpui.api.tasks` module.
|
||||
|
||||
The following parameters are supported:
|
||||
- ``list``: list of files/directories to restore
|
||||
|
|
@ -413,18 +413,18 @@ class AsyncRestore(Resource):
|
|||
'/<server>/running',
|
||||
'/running/<client>',
|
||||
'/<server>/running/<client>',
|
||||
endpoint='async_running_clients')
|
||||
endpoint='task_running_clients')
|
||||
@ns.doc(
|
||||
params={
|
||||
'server': 'Which server to collect data from when in multi-agent mode',
|
||||
'client': 'Client name',
|
||||
},
|
||||
)
|
||||
class AsyncRunningClients(RunningClients):
|
||||
"""The :class:`burpui.api.async.AsyncRunningClients` resource allows you
|
||||
class TaskRunningClients(RunningClients):
|
||||
"""The :class:`burpui.api.tasks.TaskRunningClients` resource allows you
|
||||
to retrieve a list of clients that are currently running a backup.
|
||||
|
||||
This resource is part of the :mod:`burpui.api.async` module.
|
||||
This resource is part of the :mod:`burpui.api.tasks` module.
|
||||
|
||||
This resource is backed by a periodic task. If the periodic task fail or is
|
||||
not running, we fallback to the "synchronous" API call.
|
||||
|
|
@ -466,21 +466,21 @@ class AsyncRunningClients(RunningClients):
|
|||
|
||||
@ns.route('/backup-running',
|
||||
'/<server>/backup-running',
|
||||
endpoint='async_running_backup')
|
||||
endpoint='task_running_backup')
|
||||
@ns.doc(
|
||||
params={
|
||||
'server': 'Which server to collect data from when in multi-agent mode',
|
||||
}
|
||||
)
|
||||
class AsyncRunningBackup(RunningBackup):
|
||||
"""The :class:`burpui.api.async.AsyncRunningBackup` resource allows you to
|
||||
class TaskRunningBackup(RunningBackup):
|
||||
"""The :class:`burpui.api.tasks.TaskRunningBackup` resource allows you to
|
||||
access the status of the server in order to know if there is a running
|
||||
backup currently.
|
||||
|
||||
This resource is backed by a periodic task. If the periodic task fail or is
|
||||
not running, we fallback to the "synchronous" API call.
|
||||
|
||||
This resource is part of the :mod:`burpui.api.async` module.
|
||||
This resource is part of the :mod:`burpui.api.tasks` module.
|
||||
"""
|
||||
|
||||
@ns.marshal_with(
|
||||
|
|
@ -520,14 +520,14 @@ class AsyncRunningBackup(RunningBackup):
|
|||
'/history/<client>',
|
||||
'/<server>/history',
|
||||
'/<server>/history/<client>',
|
||||
endpoint='async_history')
|
||||
endpoint='task_history')
|
||||
@ns.doc(
|
||||
params={
|
||||
'server': 'Which server to collect data from when in multi-agent mode',
|
||||
'client': 'Client name',
|
||||
},
|
||||
)
|
||||
class AsyncHistory(History):
|
||||
class TaskHistory(History):
|
||||
"""The :class:`burpui.api.misc.History` resource allows you to retrieve
|
||||
an history of the backups
|
||||
|
||||
|
|
@ -636,14 +636,14 @@ class AsyncHistory(History):
|
|||
|
||||
@ns.route('/report',
|
||||
'/<server>/report',
|
||||
endpoint='async_clients_report')
|
||||
endpoint='task_clients_report')
|
||||
@ns.doc(
|
||||
params={
|
||||
'server': 'Which server to collect data from when in multi-agent mode',
|
||||
},
|
||||
)
|
||||
class AsyncClientsReport(ClientsReport):
|
||||
"""The :class:`burpui.api.async.AsyncClientsReport` resource allows you to
|
||||
class TaskClientsReport(ClientsReport):
|
||||
"""The :class:`burpui.api.tasks.TaskClientsReport` resource allows you to
|
||||
access general reports about your clients.
|
||||
|
||||
This resource is part of the :mod:`burpui.api.clients` module.
|
||||
|
|
@ -726,7 +726,7 @@ class AsyncClientsReport(ClientsReport):
|
|||
|
||||
@ns.route('/browseall/<name>/<int:backup>',
|
||||
'/<server>/browsall/<name>/<int:backup>',
|
||||
endpoint='async_client_tree_all')
|
||||
endpoint='task_client_tree_all')
|
||||
@ns.doc(
|
||||
params={
|
||||
'server': 'Which server to collect data from when in' +
|
||||
|
|
@ -735,8 +735,8 @@ class AsyncClientsReport(ClientsReport):
|
|||
'backup': 'Backup number',
|
||||
},
|
||||
)
|
||||
class AsyncClientTreeAll(Resource):
|
||||
"""The :class:`burpui.api.async.AsyncClientTreeAll` resource allows you to
|
||||
class TaskClientTreeAll(Resource):
|
||||
"""The :class:`burpui.api.tasks.TaskClientTreeAll` resource allows you to
|
||||
retrieve a list of all the files in a given backup through the celery
|
||||
worker.
|
||||
|
||||
|
|
@ -805,17 +805,17 @@ class AsyncClientTreeAll(Resource):
|
|||
|
||||
@ns.route('/get-browse/<task_id>',
|
||||
'/<server>/get-browse/<task_id>',
|
||||
endpoint='async_do_browse_all')
|
||||
endpoint='task_do_browse_all')
|
||||
@ns.doc(
|
||||
params={
|
||||
'task_id': 'The task ID to process',
|
||||
}
|
||||
)
|
||||
class AsyncDoBrowseAll(Resource):
|
||||
"""The :class:`burpui.api.async.AsyncDoBrowseAll` resource allows you to
|
||||
class TaskDoBrowseAll(Resource):
|
||||
"""The :class:`burpui.api.tasks.TaskDoBrowseAll` resource allows you to
|
||||
retrieve the tree generated by the given task.
|
||||
|
||||
This resource is part of the :mod:`burpui.api.async` module.
|
||||
This resource is part of the :mod:`burpui.api.tasks` module.
|
||||
"""
|
||||
|
||||
@ns.marshal_list_with(node_fields, code=200, description='Success')
|
||||
|
|
@ -310,18 +310,18 @@ def compile_translation():
|
|||
@click.option('-m', '--monitor', default=None,
|
||||
help='bui-monitor configuration file')
|
||||
@click.option('-C', '--concurrency', default=None, type=click.INT,
|
||||
help='Number of concurrent async process to spawn')
|
||||
help='Number of concurrent parallel processes to spawn')
|
||||
@click.option('-B', '--backend', default=None,
|
||||
help='Switch to another backend', type=click.Choice(['burp2', 'async']))
|
||||
help='Switch to another backend', type=click.Choice(['burp2', 'parallel']))
|
||||
@click.option('-n', '--dry', is_flag=True,
|
||||
help='Dry mode. Do not edit the files but display changes')
|
||||
def setup_burp(bconfcli, bconfsrv, client, host, redis, database,
|
||||
plugins, monitor, concurrency, backend, dry):
|
||||
"""Setup burp client for burp-ui."""
|
||||
if app.config['BACKEND'] not in ['burp2', 'async']:
|
||||
if app.config['BACKEND'] not in ['burp2', 'parallel']:
|
||||
click.echo(
|
||||
click.style(
|
||||
'Sorry, you can only setup the burp2 and the async backends',
|
||||
"Sorry, you can only setup the 'burp2' and the 'parallel' backends",
|
||||
fg='red'
|
||||
),
|
||||
err=True
|
||||
|
|
@ -349,7 +349,7 @@ def setup_burp(bconfcli, bconfsrv, client, host, redis, database,
|
|||
)
|
||||
)
|
||||
|
||||
is_async = app.config['BACKEND'] == 'async' or (backend and backend == 'async')
|
||||
is_parallel = app.config['BACKEND'] == 'parallel' or (backend and backend == 'parallel')
|
||||
|
||||
if backend and app.config['BACKEND'] != backend:
|
||||
app.config['BACKEND'] = backend
|
||||
|
|
@ -415,7 +415,7 @@ def setup_burp(bconfcli, bconfsrv, client, host, redis, database,
|
|||
refresh = True
|
||||
if (database or redis) and not app.conf.lookup_section('Production', source):
|
||||
refresh = True
|
||||
if concurrency and not app.conf.lookup_section('Async', source):
|
||||
if concurrency and not app.conf.lookup_section('Parallel', source):
|
||||
refresh = True
|
||||
|
||||
if refresh:
|
||||
|
|
@ -462,8 +462,8 @@ def setup_burp(bconfcli, bconfsrv, client, host, redis, database,
|
|||
refresh |= _edit_conf('plugins', plugins, 'plugins', 'Global', app)
|
||||
if backend:
|
||||
refresh |= _edit_conf('backend', backend, None, 'Global', None)
|
||||
if is_async and concurrency:
|
||||
refresh |= _edit_conf('concurrency', concurrency, None, 'Async', None)
|
||||
if is_parallel and concurrency:
|
||||
refresh |= _edit_conf('concurrency', concurrency, None, 'Parallel', None)
|
||||
|
||||
if refresh:
|
||||
app.conf._refresh(True)
|
||||
|
|
@ -475,9 +475,9 @@ def setup_burp(bconfcli, bconfsrv, client, host, redis, database,
|
|||
if refresh:
|
||||
monconf._refresh(True)
|
||||
|
||||
if monitor and app.config['BACKEND'] == 'async':
|
||||
if monitor and app.config['BACKEND'] == 'parallel':
|
||||
mon_password = monconf.options['Global'].get('password')
|
||||
back_password = app.conf.options['Async'].get('password')
|
||||
back_password = app.conf.options['Parallel'].get('password')
|
||||
|
||||
if mon_password != back_password:
|
||||
click.echo(
|
||||
|
|
@ -867,10 +867,10 @@ password = abcdefgh
|
|||
help='Show you some tips')
|
||||
def diag(client, host, tips):
|
||||
"""Check Burp-UI is correctly setup."""
|
||||
if app.config['BACKEND'] not in ['burp2', 'async']:
|
||||
if app.config['BACKEND'] not in ['burp2', 'parallel']:
|
||||
click.echo(
|
||||
click.style(
|
||||
'Sorry, you can only diag the burp2 and the async backends',
|
||||
"Sorry, you can only diag the 'burp2' and the 'parallel' backends",
|
||||
fg='red'
|
||||
),
|
||||
err=True
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# -*- coding: utf8 -*-
|
||||
"""
|
||||
.. module:: burpui.misc.backend.async
|
||||
.. module:: burpui.misc.backend.parallel
|
||||
:platform: Unix
|
||||
:synopsis: Burp-UI async backend module.
|
||||
:synopsis: Burp-UI parallel backend module.
|
||||
|
||||
.. moduleauthor:: Ziirish <hi+burpui@ziirish.me>
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ from ...exceptions import BUIserverException
|
|||
from ..._compat import to_unicode, to_bytes
|
||||
|
||||
BUI_DEFAULTS = {
|
||||
'Async': {
|
||||
'Parallel': {
|
||||
'host': '::1',
|
||||
'port': 11111,
|
||||
'ssl': True,
|
||||
|
|
@ -35,35 +35,38 @@ BUI_DEFAULTS = {
|
|||
}
|
||||
|
||||
|
||||
class Async:
|
||||
class Parallel:
|
||||
logger = logging.getLogger('burp-ui') # type: logging.Logger
|
||||
|
||||
def __init__(self, conf):
|
||||
"""Async client
|
||||
"""Parallel client
|
||||
|
||||
:param conf: Configuration to use
|
||||
:type conf: :class:`burpui.config.BUIConfig`
|
||||
"""
|
||||
|
||||
self.host = conf.safe_get('host', section='Async', defaults=BUI_DEFAULTS)
|
||||
self.port = conf.safe_get('port', 'integer', section='Async', defaults=BUI_DEFAULTS)
|
||||
self.ssl = conf.safe_get('ssl', 'boolean', section='Async', defaults=BUI_DEFAULTS)
|
||||
self.password = conf.safe_get('password', section='Async', defaults=BUI_DEFAULTS)
|
||||
self.timeout = conf.safe_get('timeout', 'integer', section='Async', defaults=BUI_DEFAULTS)
|
||||
self.host = conf.safe_get('host', section='Parallel', defaults=BUI_DEFAULTS)
|
||||
self.port = conf.safe_get('port', 'integer', section='Parallel', defaults=BUI_DEFAULTS)
|
||||
self.ssl = conf.safe_get('ssl', 'boolean', section='Parallel', defaults=BUI_DEFAULTS)
|
||||
self.password = conf.safe_get('password', section='Parallel', defaults=BUI_DEFAULTS)
|
||||
self.timeout = conf.safe_get('timeout', 'integer', section='Parallel', defaults=BUI_DEFAULTS)
|
||||
|
||||
self.logger.info(f'Monitor {self.host}:{self.port} - ssl: {self.ssl}')
|
||||
|
||||
self.connected = False
|
||||
|
||||
async def conn(self):
|
||||
if self.ssl:
|
||||
ctx = ssl.SSLContext()
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
ctx.check_hostname = False
|
||||
ctx.load_default_certs()
|
||||
self.client_stream = await trio.open_ssl_over_tcp_stream(self.host, self.port, ssl_context=ctx)
|
||||
else:
|
||||
self.client_stream = await trio.open_tcp_stream(self.host, self.port)
|
||||
try:
|
||||
if self.ssl:
|
||||
ctx = ssl.SSLContext()
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
ctx.check_hostname = False
|
||||
ctx.load_default_certs()
|
||||
self.client_stream = await trio.open_ssl_over_tcp_stream(self.host, self.port, ssl_context=ctx)
|
||||
else:
|
||||
self.client_stream = await trio.open_tcp_stream(self.host, self.port)
|
||||
except OSError as exc:
|
||||
raise BUIserverException(str(exc))
|
||||
|
||||
self.logger.debug('Connected')
|
||||
self.connected = True
|
||||
|
|
@ -152,7 +155,7 @@ class Async:
|
|||
|
||||
# Some functions are the same as in Burp1 backend
|
||||
class Burp(Burp2):
|
||||
"""The :class:`burpui.misc.backend.async.Burp` class provides a consistent
|
||||
"""The :class:`burpui.misc.backend.parallel.Burp` class provides a consistent
|
||||
backend for ``burp-2`` servers through the bui-monitor pool. It is also able to
|
||||
perform some operations asynchronously to speedup the whole API.
|
||||
|
||||
|
|
@ -191,7 +194,7 @@ class Burp(Burp2):
|
|||
self.parser = Parser(self)
|
||||
self.conf = conf
|
||||
|
||||
self.concurrency = conf.safe_get('concurrency', 'integer', section='Async', defaults=BUI_DEFAULTS)
|
||||
self.concurrency = conf.safe_get('concurrency', 'integer', section='Parallel', defaults=BUI_DEFAULTS)
|
||||
|
||||
self.logger.info('burp conf cli: {}'.format(self.burpconfcli))
|
||||
self.logger.info('burp conf srv: {}'.format(self.burpconfsrv))
|
||||
|
|
@ -222,12 +225,18 @@ class Burp(Burp2):
|
|||
return self._batch_list_supported
|
||||
|
||||
async def _async_status(self, query='c:\n', timeout=None, cache=True):
|
||||
async_client = Async(self.conf)
|
||||
return await async_client.status(query, timeout, cache)
|
||||
async_client = Parallel(self.conf)
|
||||
try:
|
||||
return await async_client.status(query, timeout, cache)
|
||||
except OSError as exc:
|
||||
raise BUIserverException(str(exc))
|
||||
|
||||
async def _async_request(self, func, *args, **kwargs):
|
||||
async_client = Async(self.conf)
|
||||
return await async_client.request(func, *args, **kwargs)
|
||||
async_client = Parallel(self.conf)
|
||||
try:
|
||||
return await async_client.request(func, *args, **kwargs)
|
||||
except OSError as exc:
|
||||
raise BUIserverException(str(exc))
|
||||
|
||||
def status(self, query='c:\n', timeout=None, cache=True, agent=None):
|
||||
"""See :func:`burpui.misc.backend.interface.BUIbackend.status`"""
|
||||
|
|
@ -262,7 +271,6 @@ class Burp(Burp2):
|
|||
res = await _do_stuff()
|
||||
|
||||
if store is not None:
|
||||
# await store.put(res)
|
||||
store.append(res)
|
||||
else:
|
||||
return res
|
||||
|
|
@ -270,18 +278,12 @@ class Burp(Burp2):
|
|||
async def _async_get_all_backup_logs(self, client, forward=False):
|
||||
ret = []
|
||||
backups = await self._async_get_client(client)
|
||||
# queue = trio.Queue(len(backups))
|
||||
queue = []
|
||||
limit = trio.CapacityLimiter(self.concurrency)
|
||||
async with trio.open_nursery() as nursery:
|
||||
for back in backups:
|
||||
nursery.start_soon(self._async_get_backup_logs, back['number'], client, forward, queue, limit)
|
||||
|
||||
# while not queue.empty():
|
||||
# tmp = await queue.get()
|
||||
# ret.append(tmp)
|
||||
|
||||
# ret = sorted(ret, key=lambda x: x['number'])
|
||||
ret = sorted(queue, key=lambda x: x['number'])
|
||||
return ret
|
||||
|
||||
|
|
@ -323,7 +325,7 @@ class Burp(Burp2):
|
|||
return 1
|
||||
|
||||
async def _async_parse_backup_stats(self, number, client, forward=False, agent=None):
|
||||
"""The :func:`burpui.misc.backend.burp2.Burp._async_parse_backup_stats`
|
||||
"""The :func:`burpui.misc.backend.parallel.Burp._async_parse_backup_stats`
|
||||
function is used to parse the burp logs.
|
||||
|
||||
:param number: Backup number to work on
|
||||
|
|
@ -579,10 +581,8 @@ class Burp(Burp2):
|
|||
append = False
|
||||
|
||||
if append:
|
||||
# await ret.put(back)
|
||||
ret.append(back)
|
||||
|
||||
# queue = trio.Queue(len(backups))
|
||||
queue = []
|
||||
limiter = trio.CapacityLimiter(self.concurrency)
|
||||
|
||||
|
|
@ -619,13 +619,8 @@ class Burp(Burp2):
|
|||
elif limit > 0 and idx >= limit:
|
||||
break
|
||||
|
||||
# while not queue.empty():
|
||||
# tmp = await queue.get()
|
||||
# ret.append(tmp)
|
||||
|
||||
# Here we need to reverse the array so the backups are sorted by num
|
||||
# ASC
|
||||
# ret = sorted(ret, key=lambda x: x['number'])
|
||||
ret = sorted(queue, key=lambda x: x['number'])
|
||||
return ret
|
||||
|
||||
|
|
@ -65,7 +65,7 @@
|
|||
<br />
|
||||
<div class="row form-horizontal">
|
||||
{% if config.WITH_CELERY -%}
|
||||
<form id="form-restore" class="form-inline col-md-6" method="POST" role="form" action="{{ url_for('api.async_restore', name=cname, backup=nbackup, server=server) }}">
|
||||
<form id="form-restore" class="form-inline col-md-6" method="POST" role="form" action="{{ url_for('api.task_restore', name=cname, backup=nbackup, server=server) }}">
|
||||
{% else -%}
|
||||
<form id="form-restore" class="form-inline col-md-6" method="POST" role="form" action="{{ url_for('api.restore', name=cname, backup=nbackup, server=server) }}">
|
||||
{% endif -%}
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ var buiFail = function(xhr, stat, err) {
|
|||
};
|
||||
|
||||
{% if config.WITH_CELERY -%}
|
||||
{% set api_running_backup = "api.async_running_backup" %}
|
||||
{% set api_running_backup = "api.task_running_backup" %}
|
||||
{% else -%}
|
||||
{% set api_running_backup = "api.running_backup" %}
|
||||
{% endif -%}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ $(document).ready(function() {
|
|||
|
||||
fetchEvents = function(start, end) {
|
||||
{% if config.WITH_CELERY -%}
|
||||
var feed_url = '{{ url_for("api.async_history", client=cname, server=server) }}?start='+start+'&end='+end;
|
||||
var feed_url = '{{ url_for("api.task_history", client=cname, server=server) }}?start='+start+'&end='+end;
|
||||
{% else -%}
|
||||
var feed_url = '{{ url_for("api.history", client=cname, server=server) }}?start='+start+'&end='+end;
|
||||
{% endif -%}
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ $( document ).ready(function() {
|
|||
var _check_task_schedule = undefined;
|
||||
$('#cancel-running-restore').on('click', function(e) {
|
||||
var task_id = $(this).data('task_id');
|
||||
var url = '{{ url_for("api.async_status", task_type="restore", task_id="", server=server) }}'+task_id;
|
||||
var url = '{{ url_for("api.task_status", task_type="restore", task_id="", server=server) }}'+task_id;
|
||||
if (!task_id) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -235,7 +235,7 @@ $( document ).ready(function() {
|
|||
|
||||
{% if config.WITH_CELERY -%}
|
||||
var check_task = function(task_id) {
|
||||
$.getJSON('{{ url_for("api.async_status", task_type="restore", task_id="", server=server) }}'+task_id)
|
||||
$.getJSON('{{ url_for("api.task_status", task_type="restore", task_id="", server=server) }}'+task_id)
|
||||
.done(function(data) {
|
||||
if (data.state != 'SUCCESS') {
|
||||
_check_task_schedule = setTimeout(function() {
|
||||
|
|
@ -346,10 +346,10 @@ $( document ).ready(function() {
|
|||
});
|
||||
};
|
||||
{% if config.WITH_CELERY -%}
|
||||
var url = "{{ url_for('api.async_client_tree_all', name=cname, backup=nbackup, server=server) }}";
|
||||
var url = "{{ url_for('api.task_client_tree_all', name=cname, backup=nbackup, server=server) }}";
|
||||
var _task_status_schedule = undefined;
|
||||
var task_status = function(task_id) {
|
||||
$.getJSON('{{ url_for("api.async_status", task_type="browse", task_id="", server=server) }}'+task_id)
|
||||
$.getJSON('{{ url_for("api.task_status", task_type="browse", task_id="", server=server) }}'+task_id)
|
||||
.fail(buiFail)
|
||||
.done(function(data) {
|
||||
if (data.state != 'SUCCESS') {
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ var _client = function() {
|
|||
var __refresh_running = undefined;
|
||||
var refresh_status = function( is_running ) {
|
||||
{% if config.WITH_CELERY %}
|
||||
{% set api_running_clients = "api.async_running_clients" %}
|
||||
{% set api_running_clients = "api.task_running_clients" %}
|
||||
{% else %}
|
||||
{% set api_running_clients = "api.running_clients" %}
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ var _clients = function() {
|
|||
aggreg = $('#aggreg').val();
|
||||
}
|
||||
{% if config.WITH_CELERY -%}
|
||||
url = '{{ url_for("api.async_clients_report", server=server) }}';
|
||||
url = '{{ url_for("api.task_clients_report", server=server) }}';
|
||||
{% else -%}
|
||||
url = '{{ url_for("api.clients_report", server=server) }}';
|
||||
{% endif -%}
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ var __last_clients_running = [];
|
|||
var refresh_status = function( is_running ) {
|
||||
cancel_refresh();
|
||||
{% if config.WITH_CELERY %}
|
||||
{% set api_running_clients = "api.async_running_clients" %}
|
||||
{% set api_running_clients = "api.task_running_clients" %}
|
||||
{% else %}
|
||||
{% set api_running_clients = "api.running_clients" %}
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ BURPUI_GID=${BURPUI_GID:-5337}
|
|||
BURPUI_PLUGINS=${BURPUI_PLUGINS:-none}
|
||||
BURPUI_WS_WORKERS=${BURPUI_WS_WORKERS:-$(getconf _NPROCESSORS_ONLN)}
|
||||
BURPUI_RP_SCHEME=${BURPUI_RP_SCHEME:-https}
|
||||
BURPUI_BACKEND=${BURPUI_BACKEND:-async}
|
||||
BURPUI_BACKEND=${BURPUI_BACKEND:-parallel}
|
||||
BURP_CLIENT_CONFIG=${BURP_CLIENT_CONFIG:-/tmp/burp.conf}
|
||||
BURP_SERVER_CONFIG=${BURP_SERVER_CONFIG:-/etc/burp/burp-server.conf}
|
||||
BURP_SERVER_ADDR=${BURP_SERVER_ADDR:-burp-server}
|
||||
|
|
@ -76,7 +76,7 @@ appStart () {
|
|||
ASYNC="True"
|
||||
CELERY="True"
|
||||
grep -q "Unable to contact the redis server" $LOGFILE && CELERY=""
|
||||
[ "$GUNICORN_WORKER_CLASS" != "sync" ] || [ "$BURPUI_BACKEND" != "async" ] && ASYNC=""
|
||||
[ "$GUNICORN_WORKER_CLASS" != "sync" ] || [ "$BURPUI_BACKEND" != "parallel" ] && ASYNC=""
|
||||
|
||||
[ "$ret" != "0" ] && {
|
||||
echo
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ services:
|
|||
# - BURPUI_PLUGINS=none
|
||||
# - BURPUI_WS_WORKERS=2
|
||||
# - BURPUI_RP_SCHEME=https
|
||||
# - BURPUI_BACKEND=async
|
||||
# - BURPUI_BACKEND=parallel
|
||||
# - BURP_CLIENT_CONFIG=/tmp/burp.conf
|
||||
# - BURP_SERVER_CONFIG=/etc/burp/burp-server.conf
|
||||
# - DATABASE_URL=postgresql://burpui:burpui@pgsql/burpuidb
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@ The `burpui.cfg`_ configuration file contains a ``[Global]`` section as follow:
|
|||
::
|
||||
|
||||
[Global]
|
||||
# burp backend to load either one of 'burp1', 'burp2', 'async' or 'multi'.
|
||||
# burp backend to load either one of 'burp1', 'burp2', 'parallel' or 'multi'.
|
||||
# If you choose 'multi', you will have to declare at lease one 'Agent' section.
|
||||
# If you choose 'async', you need to configure the [Async] section.
|
||||
# If you choose 'parallel', you need to configure the [Parallel] section.
|
||||
# If you choose either 'burp1' or 'burp2', you need to configure the [Burp]
|
||||
# section.
|
||||
# The [Burp] section is also used with the 'async' backend for the restoration
|
||||
# The [Burp] section is also used with the 'parallel' backend for the restoration
|
||||
# process.
|
||||
# You can also use whatever custom backend you like if it is located in the
|
||||
# 'plugins' directory and if it implements the right interface.
|
||||
|
|
@ -68,7 +68,7 @@ The `burpui.cfg`_ configuration file contains a ``[Global]`` section as follow:
|
|||
Each option is commented, but here is a more detailed documentation:
|
||||
|
||||
- *backend*: What `Burp`_ backend to load. Can either be one of *burp1*,
|
||||
*burp2*, *async* or *multi*, or can be whatever custom backend you like as
|
||||
*burp2*, *parallel* or *multi*, or can be whatever custom backend you like as
|
||||
long as it implements the proper interface.
|
||||
If providing a custom backend name, it must be located in the *plugins*
|
||||
directory. You can also specify a custom external module by providing the
|
||||
|
|
@ -263,7 +263,7 @@ Backends
|
|||
- `Burp1`_
|
||||
- `Burp2`_
|
||||
- `Multi`_
|
||||
- `Async`_
|
||||
- `Parallel`_
|
||||
|
||||
These backends allow you to either connect to a `Burp`_ server version 1.x.x or
|
||||
2.x.x.
|
||||
|
|
@ -366,17 +366,17 @@ Once this backend is enabled, you have to create **one** ``[Agent]`` section
|
|||
To configure your agents, please refer to the `bui-agent`_ page.
|
||||
|
||||
|
||||
Async
|
||||
^^^^^
|
||||
Parallel
|
||||
^^^^^^^^
|
||||
|
||||
The *async* backend allows you to connect to the `bui-monitor`_ pool. It can be
|
||||
enabled by setting the *backend* option to *async* in the ``[Global]`` section
|
||||
The *parallel* backend allows you to connect to the `bui-monitor`_ pool. It can be
|
||||
enabled by setting the *backend* option to *parallel* in the ``[Global]`` section
|
||||
of your `burpui.cfg`_ file:
|
||||
|
||||
::
|
||||
|
||||
[Global]
|
||||
backend = async
|
||||
backend = parallel
|
||||
|
||||
|
||||
This backend allows you to access `Burp`_ servers through the `bui-monitor`_
|
||||
|
|
@ -385,12 +385,12 @@ The architecture is available on the bui-monitor
|
|||
`page <buimonitor.html#architecture>`__.
|
||||
|
||||
|
||||
Once this backend is enabled, you have to configure the ``[Async]`` section.
|
||||
Once this backend is enabled, you have to configure the ``[Parallel]`` section.
|
||||
|
||||
::
|
||||
|
||||
# async backend specific options
|
||||
[Async]
|
||||
# parallel backend specific options
|
||||
[Parallel]
|
||||
# address of the monitor pool
|
||||
host = ::1
|
||||
# port of the monitor pool
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ beforehand.
|
|||
Also, this wasn't very scalable.
|
||||
|
||||
If you choose to use the `bui-monitor`_ pool with the appropriate backend (the
|
||||
`async`_ one), you can now take advantage of some requests parallelisation.
|
||||
`parallel`_ one), you can now take advantage of some requests parallelisation.
|
||||
|
||||
Cherry on the cake, the `async`_ backend is available within both the *local*
|
||||
Cherry on the cake, the `parallel`_ backend is available within both the *local*
|
||||
`Burp-UI`_ process but also within the `bui-agent`_!
|
||||
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ options. There are fewer options because we only launch client processes.
|
|||
Benchmark
|
||||
---------
|
||||
|
||||
On my development VM which has 2 vCPUs I noticed the `async`_ backend which
|
||||
On my development VM which has 2 vCPUs I noticed the `parallel`_ backend which
|
||||
interacts with the `bui-monitor`_ was twice faster than the `burp2`_ backend.
|
||||
|
||||
The test script was something like:
|
||||
|
|
@ -151,13 +151,13 @@ The server was launched with gunicorn:
|
|||
|
||||
::
|
||||
|
||||
# for the async backend
|
||||
# for the parallel backend
|
||||
gunicorn -b 0.0.0.0:5000 -w 2 'burpui:create_app(conf="path/to/burpui.cfg")'
|
||||
# for the burp2 backend
|
||||
gunicorn -k gevent -b 0.0.0.0:5000 -w 2 'burpui:create_app(conf="path/to/burpui.cfg")'
|
||||
|
||||
|
||||
.. info:: The `async`_ backend is not compatible with gevent hence the different
|
||||
.. info:: The `parallel`_ backend is not compatible with gevent hence the different
|
||||
launching command.
|
||||
|
||||
Here are the results:
|
||||
|
|
@ -167,14 +167,14 @@ Here are the results:
|
|||
# with burp2 backend
|
||||
bash /tmp/bench.sh 0.10s user 0.06s system 0% cpu 20.377 total
|
||||
bash /tmp/bench.sh 0.11s user 0.04s system 0% cpu 21.447 total
|
||||
# with async backend
|
||||
# with parallel backend
|
||||
bash /tmp/bench.sh 0.12s user 0.04s system 1% cpu 10.267 total
|
||||
bash /tmp/bench.sh 0.11s user 0.05s system 1% cpu 9.735 total
|
||||
|
||||
|
||||
My feeling is, the more you have CPU cores, the more performance improvements
|
||||
you'll notice over the `burp2`_ backend because we let the kernel handle the I/O
|
||||
parallelization with the `async`_ backend and `bui-monitor`_.
|
||||
parallelization with the `parallel`_ backend and `bui-monitor`_.
|
||||
|
||||
Service
|
||||
-------
|
||||
|
|
@ -200,5 +200,5 @@ this:
|
|||
.. _bui-agent: buiagent.html
|
||||
.. _bui-monitor: buimonitor.html
|
||||
.. _burp2: advanced_usage.html#burp2
|
||||
.. _async: advanced_usage.html#async
|
||||
.. _parallel: advanced_usage.html#parallel
|
||||
.. _celery: http://www.celeryproject.org/
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ ssl = true
|
|||
sslcert = /var/lib/burp/ssl/server/ssl_cert-server.pem
|
||||
# ssl key
|
||||
sslkey = /var/lib/burp/ssl/server/ssl_cert-server.key
|
||||
# burp backend to load either 'burp1', 'burp2' or 'async'.
|
||||
# burp backend to load either 'burp1', 'burp2' or 'parallel'.
|
||||
# You can also use whatever custom backend you like if it is located in the
|
||||
# 'plugins' directory and if it implements the right interface.
|
||||
backend = burp2
|
||||
|
|
@ -62,3 +62,19 @@ bconfsrv = /etc/burp/burp-server.conf
|
|||
tmpdir = /tmp/bui
|
||||
# how many time to wait for the monitor to answer (in seconds)
|
||||
timeout = 15
|
||||
|
||||
# parallel backend specific options
|
||||
[Parallel]
|
||||
# address of the monitor pool
|
||||
host = ::1
|
||||
# port of the monitor pool
|
||||
port = 11111
|
||||
# how many time to wait for the monitor pool to answer (in seconds)
|
||||
timeout = 15
|
||||
# monitor pool password
|
||||
password = password123456
|
||||
# enable SSL
|
||||
ssl = true
|
||||
# number of operations to process concurrently
|
||||
# the value should not exceed the pool size you set in the bui-monitor.cfg file
|
||||
concurrency = 2
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
# Burp-UI configuration file
|
||||
[Global]
|
||||
# burp backend to load either one of 'burp1', 'burp2', 'async' or 'multi'.
|
||||
# burp backend to load either one of 'burp1', 'burp2', 'parallel' or 'multi'.
|
||||
# If you choose 'multi', you will have to declare at lease one 'Agent' section.
|
||||
# If you choose 'async', you need to configure the [Async] section.
|
||||
# If you choose 'parallel', you need to configure the [Parallel] section.
|
||||
# If you choose either 'burp1' or 'burp2', you need to configure the [Burp]
|
||||
# section.
|
||||
# The [Burp] section is also used with the 'async' backend for the restoration
|
||||
# The [Burp] section is also used with the 'parallel' backend for the restoration
|
||||
# process.
|
||||
# You can also use whatever custom backend you like if it is located in the
|
||||
# 'plugins' directory and if it implements the right interface.
|
||||
|
|
@ -183,8 +183,8 @@ tmpdir = /tmp/bui
|
|||
# how many time to wait for the monitor to answer (in seconds)
|
||||
timeout = 15
|
||||
|
||||
# async backend specific options
|
||||
[Async]
|
||||
# parallel backend specific options
|
||||
[Parallel]
|
||||
# address of the monitor pool
|
||||
host = ::1
|
||||
# port of the monitor pool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue