Added "whoami" route
WhoAmI provides the unique server-side peer id and the os-username to a client
This commit is contained in:
parent
2c2633eebd
commit
9ffb1dcb86
1 changed files with 9 additions and 0 deletions
|
@ -7,6 +7,7 @@ import json
|
|||
import os
|
||||
import subprocess
|
||||
import re
|
||||
import pwd
|
||||
import platform
|
||||
import struct
|
||||
from subprocess import Popen, PIPE
|
||||
|
@ -102,6 +103,13 @@ class Subscribe(Route):
|
|||
handler.routes["peers"].push_changes(handler)
|
||||
|
||||
|
||||
class WhoAmI(Route):
|
||||
def run(self, data, handler):
|
||||
handler.send({"id" : handler.id_,
|
||||
"user" : pwd.getpwuid(os.getuid()).pw_name},
|
||||
handler.reverse_routes[self])
|
||||
|
||||
|
||||
class Peers(Route):
|
||||
"""
|
||||
{"subscribe" : [1, 2]}
|
||||
|
@ -237,6 +245,7 @@ server.set_app(WebSocketWSGIApplication(handler_cls=Handler,
|
|||
handler_args={"debug" : config.debug, "broadcast" : broadcast,
|
||||
"websockets" : server.manager.websockets,
|
||||
"routes" : {"info" : Info(),
|
||||
"whoami" : WhoAmI(),
|
||||
"subscribe" : Subscribe(),
|
||||
"hostname" : DummyPipe(),
|
||||
"processes" : DummyPipe(),
|
||||
|
|
Reference in a new issue