Don't assume WebSocket clients are dashboards by default; announce user agents
This commit is contained in:
parent
55e3507122
commit
6a866ad530
@ -1567,6 +1567,11 @@ Dashboard.prototype.connectWebSocket = function() {
|
|||||||
|
|
||||||
this.ws.onopen = function(ev) {
|
this.ws.onopen = function(ev) {
|
||||||
console.log("WebSocket opened:", ev);
|
console.log("WebSocket opened:", ev);
|
||||||
|
this.ws.send(JSON.stringify({
|
||||||
|
"type": "hello",
|
||||||
|
"mode": "dashboard",
|
||||||
|
"user_agent": navigator.userAgent
|
||||||
|
}));
|
||||||
this.decayer.reset();
|
this.decayer.reset();
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ from autobahn.asyncio.websocket import WebSocketServerFactory, WebSocketServerPr
|
|||||||
class GrabberServerProtocol(WebSocketServerProtocol):
|
class GrabberServerProtocol(WebSocketServerProtocol):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.mode = "dashboard"
|
self.mode = None
|
||||||
|
|
||||||
def onConnect(self, request):
|
def onConnect(self, request):
|
||||||
self.peer = request.peer
|
self.peer = request.peer
|
||||||
@ -36,10 +36,11 @@ class GrabberServerProtocol(WebSocketServerProtocol):
|
|||||||
if type == "hello" and obj.get("mode"):
|
if type == "hello" and obj.get("mode"):
|
||||||
mode = obj['mode']
|
mode = obj['mode']
|
||||||
if mode in ('dashboard', 'grabber'):
|
if mode in ('dashboard', 'grabber'):
|
||||||
print("{} set mode {}".format(self.peer, mode))
|
self.mode = mode
|
||||||
if mode == "grabber":
|
if mode == "grabber":
|
||||||
print("{} is grabbing {}".format(self.peer, obj['url']))
|
print("{} is grabbing {}".format(self.peer, obj['url']))
|
||||||
self.mode = mode
|
elif mode == "dashboard":
|
||||||
|
print("{} is dashboarding with {}".format(self.peer, obj['user_agent']))
|
||||||
elif type == "download":
|
elif type == "download":
|
||||||
self.broadcastToDashboards({
|
self.broadcastToDashboards({
|
||||||
"type": type,
|
"type": type,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user