From e41d771ed42b59d5605624823406f4859a5c3861 Mon Sep 17 00:00:00 2001 From: Edip YILDIZ Date: Mon, 14 Aug 2017 11:17:18 +0300 Subject: [PATCH] =?UTF-8?q?user=C4=B1n=20kendi=20ip=20si=20eklendi..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- opt/ahenk/base/command/command_manager.py | 1 + opt/ahenk/base/command/command_runner.py | 3 ++- opt/ahenk/base/messaging/messaging.py | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/opt/ahenk/base/command/command_manager.py b/opt/ahenk/base/command/command_manager.py index d8af143..7196369 100644 --- a/opt/ahenk/base/command/command_manager.py +++ b/opt/ahenk/base/command/command_manager.py @@ -47,6 +47,7 @@ class Commander(object): if len(params) == 6: data['ip'] = params[5] + elif len(params) == 3 and params[1] == 'logout': print('{0} logging out'.format(str(params[2]))) data['event'] = params[1] diff --git a/opt/ahenk/base/command/command_runner.py b/opt/ahenk/base/command/command_runner.py index 220d241..3e19cdd 100644 --- a/opt/ahenk/base/command/command_runner.py +++ b/opt/ahenk/base/command/command_runner.py @@ -61,12 +61,13 @@ class CommandRunner(object): display = json_data['display'] desktop = json_data['desktop'] + ip = None if 'ip' in json_data: ip = json_data['ip'] self.logger.info('login event is handled for user: {0}'.format(username)) - login_message = self.message_manager.login_msg(username) + login_message = self.message_manager.login_msg(username,ip) self.messenger.send_direct_message(login_message) agreement = Agreement() diff --git a/opt/ahenk/base/messaging/messaging.py b/opt/ahenk/base/messaging/messaging.py index 86c7ced..06fece6 100644 --- a/opt/ahenk/base/messaging/messaging.py +++ b/opt/ahenk/base/messaging/messaging.py @@ -64,12 +64,13 @@ class Messaging(object): self.logger.debug('Policy status message was created') return str(json_data) - def login_msg(self, username): + def login_msg(self, username,ip=None): data = dict() data['type'] = 'LOGIN' data['username'] = username data['ipAddresses'] = str(System.Hardware.Network.ip_addresses()).replace('[', '').replace(']', '') data['timestamp'] = Util.timestamp() + data['userIp'] = ip data['hardware.monitors'] = str(System.Hardware.monitors()), data['hardware.screens'] = str(System.Hardware.screens()),