mirror of
https://github.com/ziirish/burp-ui.git
synced 2026-05-21 06:45:24 -06:00
fix: gevent issues
This commit is contained in:
parent
affdc8442e
commit
f3f999889e
3 changed files with 16 additions and 28 deletions
|
|
@ -88,8 +88,13 @@ def init(conf=None, debug=0, logfile=None, gunicorn=True, unittest=False):
|
|||
from .routes import view
|
||||
from .api import api, apibp
|
||||
|
||||
if gunicorn:
|
||||
from gevent import monkey
|
||||
monkey.patch_all()
|
||||
|
||||
# We initialize the core
|
||||
app = BurpUI()
|
||||
app.gunicorn = gunicorn
|
||||
|
||||
app.config['CFG'] = None
|
||||
|
||||
|
|
@ -156,8 +161,6 @@ def init(conf=None, debug=0, logfile=None, gunicorn=True, unittest=False):
|
|||
|
||||
if gunicorn: # pragma: no cover
|
||||
from werkzeug.contrib.fixers import ProxyFix
|
||||
from gevent import monkey
|
||||
monkey.patch_all()
|
||||
if app.storage and app.storage.lower() == 'redis':
|
||||
if app.redis:
|
||||
part = app.redis.split(':')
|
||||
|
|
@ -181,7 +184,6 @@ def init(conf=None, debug=0, logfile=None, gunicorn=True, unittest=False):
|
|||
pass
|
||||
|
||||
app.wsgi_app = ProxyFix(app.wsgi_app)
|
||||
app.gunicorn = True
|
||||
|
||||
# Then we load our routes
|
||||
view.init_bui(app)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ from ..exceptions import BUIserverException
|
|||
|
||||
from flask.ext.restplus import Resource, fields
|
||||
from flask.ext.login import current_user
|
||||
import multiprocessing
|
||||
|
||||
ns = api.namespace('servers', 'Servers methods')
|
||||
|
||||
|
|
@ -63,40 +62,22 @@ class ServersStats(Resource):
|
|||
check = True
|
||||
allowed = api.bui.acl.servers(current_user.get_id())
|
||||
|
||||
def get_server_infos(serv, output):
|
||||
for serv in api.bui.cli.servers:
|
||||
try:
|
||||
if check:
|
||||
if serv in allowed:
|
||||
output.put({
|
||||
r.append({
|
||||
'name': serv,
|
||||
'clients': len(api.bui.cli.servers[serv].get_all_clients(serv)),
|
||||
'clients': len(api.bui.acl.clients(current_user.get_id(), serv)),
|
||||
'alive': api.bui.cli.servers[serv].ping()
|
||||
})
|
||||
return
|
||||
else:
|
||||
output.put({
|
||||
r.append({
|
||||
'name': serv,
|
||||
'clients': len(api.bui.cli.servers[serv].get_all_clients(serv)),
|
||||
'alive': api.bui.cli.servers[serv].ping()
|
||||
})
|
||||
return
|
||||
output.put(None)
|
||||
except BUIserverException as e:
|
||||
output.put(str(e))
|
||||
|
||||
output = multiprocessing.Queue()
|
||||
pools = [multiprocessing.Process(target=get_server_infos, args=(s, output)) for s in api.bui.cli.servers]
|
||||
for p in pools:
|
||||
p.start()
|
||||
|
||||
for p in pools:
|
||||
p.join()
|
||||
|
||||
for p in pools:
|
||||
tmp = output.get()
|
||||
if tmp and isinstance(tmp, dict):
|
||||
r.append(tmp)
|
||||
elif tmp:
|
||||
api.abort(500, tmp)
|
||||
api.abort(500, str(e))
|
||||
|
||||
return r
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ try:
|
|||
import ConfigParser
|
||||
except ImportError:
|
||||
import configparser as ConfigParser
|
||||
try:
|
||||
from gevent.local import local
|
||||
except ImportError:
|
||||
local = object
|
||||
|
||||
from six import iteritems
|
||||
|
||||
|
|
@ -175,7 +179,7 @@ class Burp(BUIbackend):
|
|||
return self.servers[agent].get_server_version()
|
||||
|
||||
|
||||
class NClient(BUIbackend):
|
||||
class NClient(BUIbackend, local):
|
||||
"""The :class:`burpui.misc.backend.multi.NClient` class provides a
|
||||
consistent backend to interact with ``agents``.
|
||||
|
||||
|
|
@ -253,6 +257,7 @@ class NClient(BUIbackend):
|
|||
if self.connected and force:
|
||||
self.sock.sendall(struct.pack('!Q', 2))
|
||||
self.sock.sendall(b'RE')
|
||||
self.sock.shutdown(socket.SHUT_RDWR)
|
||||
self.sock.close()
|
||||
self.connected = False
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue