aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/web
diff options
context:
space:
mode:
Diffstat (limited to 'libmproxy/web')
-rw-r--r--libmproxy/web/__init__.py15
-rw-r--r--libmproxy/web/app.py10
-rw-r--r--libmproxy/web/static/js/app.js10
3 files changed, 32 insertions, 3 deletions
diff --git a/libmproxy/web/__init__.py b/libmproxy/web/__init__.py
index c2597861..50b41b80 100644
--- a/libmproxy/web/__init__.py
+++ b/libmproxy/web/__init__.py
@@ -81,18 +81,31 @@ class WebMaster(flow.FlowMaster):
self.shutdown()
def handle_request(self, f):
- pprint.pprint(f.get_state())
+ app.ClientConnection.broadcast("flow", f.get_state(True))
flow.FlowMaster.handle_request(self, f)
if f:
f.reply()
return f
def handle_response(self, f):
+ app.ClientConnection.broadcast("flow", f.get_state(True))
flow.FlowMaster.handle_response(self, f)
if f:
f.reply()
return f
def handle_error(self, f):
+ app.ClientConnection.broadcast("flow", f.get_state(True))
flow.FlowMaster.handle_error(self, f)
return f
+
+ def handle_log(self, l):
+ app.ClientConnection.broadcast(
+ "event", {
+ "message": l.msg,
+ "level": l.level
+ }
+ )
+ self.add_event(l.msg, l.level)
+ l.reply()
+
diff --git a/libmproxy/web/app.py b/libmproxy/web/app.py
index e9bcc526..e2765a6d 100644
--- a/libmproxy/web/app.py
+++ b/libmproxy/web/app.py
@@ -2,6 +2,7 @@ import os.path
import tornado.web
import tornado.websocket
import logging
+import json
class IndexHandler(tornado.web.RequestHandler):
@@ -22,7 +23,14 @@ class ClientConnection(tornado.websocket.WebSocketHandler):
def broadcast(cls, type, data):
for conn in cls.connections:
try:
- conn.write_message(type, data)
+ conn.write_message(
+ json.dumps(
+ {
+ "type": type,
+ "data": data
+ }
+ )
+ )
except:
logging.error("Error sending message", exc_info=True)
diff --git a/libmproxy/web/static/js/app.js b/libmproxy/web/static/js/app.js
index 90a004ef..84eece87 100644
--- a/libmproxy/web/static/js/app.js
+++ b/libmproxy/web/static/js/app.js
@@ -221,7 +221,15 @@ _Connection.prototype.onopen = function (open) {
};
_Connection.prototype.onmessage = function (message) {
//AppDispatcher.dispatchServerAction(...);
- console.log("onmessage", this, arguments);
+ var m = JSON.parse(message.data);
+ switch (m.type){
+ case "flow":
+ console.log("flow", m.data);
+ break;
+ case "event":
+ console.log("event", m.data.message)
+ break;
+ }
};
_Connection.prototype.onerror = function (error) {
console.log("onerror", this, arguments);