diff --git a/opt/ahenk/base/command/command_manager.py b/opt/ahenk/base/command/command_manager.py index 7196369..0ef88ff 100644 --- a/opt/ahenk/base/command/command_manager.py +++ b/opt/ahenk/base/command/command_manager.py @@ -48,10 +48,11 @@ class Commander(object): data['ip'] = params[5] - elif len(params) == 3 and params[1] == 'logout': + elif len(params) == 4 and params[1] == 'logout': print('{0} logging out'.format(str(params[2]))) data['event'] = params[1] data['username'] = params[2] + data['ip'] = params[3] elif len(params) == 2 and params[1] == 'stop': data['event'] = 'stop' diff --git a/opt/ahenk/base/command/command_runner.py b/opt/ahenk/base/command/command_runner.py index 3e19cdd..22694fc 100644 --- a/opt/ahenk/base/command/command_runner.py +++ b/opt/ahenk/base/command/command_runner.py @@ -145,7 +145,10 @@ class CommandRunner(object): self.execute_manager.remove_user_executed_policy_dict(username) # TODO delete all user records while initializing self.logger.info('logout event is handled for user: {0}'.format(username)) - logout_message = self.message_manager.logout_msg(username) + ip = None + if 'ip' in json_data: + ip = json_data['ip'] + logout_message = self.message_manager.logout_msg(username,ip) self.messenger.send_direct_message(logout_message) self.plugin_manager.process_mode('logout', username) diff --git a/opt/ahenk/base/messaging/messaging.py b/opt/ahenk/base/messaging/messaging.py index 044abde..7747330 100644 --- a/opt/ahenk/base/messaging/messaging.py +++ b/opt/ahenk/base/messaging/messaging.py @@ -85,11 +85,12 @@ class Messaging(object): self.logger.debug('Login message was created') return json_data - def logout_msg(self, username): + def logout_msg(self, username,ip): data = dict() data['type'] = 'LOGOUT' data['username'] = str(username) data['timestamp'] = Util.timestamp() + data['userIp'] = ip json_data = json.dumps(data) self.logger.debug('Logout message was created') return json_data diff --git a/opt/ahenk/plugins/sample/init.py b/opt/ahenk/plugins/sample/init.py deleted file mode 100644 index 4ddf5d6..0000000 --- a/opt/ahenk/plugins/sample/init.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -from base.plugin.abstract_plugin import AbstractPlugin - - -class Init(AbstractPlugin): - def __init__(self, context): - super(Init, self).__init__() - self.context = context - self.logger = self.get_logger() - - def handle_init_mode(self): - # TODO Do what do you want to do! - pass - - -def handle_mode(context): - init = Init(context) - init.handle_init_mode() \ No newline at end of file diff --git a/opt/ahenk/plugins/sample/login.py b/opt/ahenk/plugins/sample/login.py deleted file mode 100644 index d54477f..0000000 --- a/opt/ahenk/plugins/sample/login.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -from base.plugin.abstract_plugin import AbstractPlugin - - -class Login(AbstractPlugin): - def __init__(self, context): - super(Login, self).__init__() - self.context = context - self.username = str(context.get_username()) - self.logger = self.get_logger() - - def handle_login_mode(self): - # TODO Do what do you want to do! - pass - - -def handle_mode(context): - login = Login(context) - login.handle_login_mode() \ No newline at end of file diff --git a/opt/ahenk/plugins/sample/logout.py b/opt/ahenk/plugins/sample/logout.py deleted file mode 100644 index 83c066b..0000000 --- a/opt/ahenk/plugins/sample/logout.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -from base.plugin.abstract_plugin import AbstractPlugin - - -class Logout(AbstractPlugin): - def __init__(self, context): - super(Logout, self).__init__() - self.context = context - self.username = str(context.get_username()) - self.logger = self.get_logger() - - def handle_logout_mode(self): - # TODO Do what do you want to do! - pass - - -def handle_mode(context): - logout = Logout(context) - logout.handle_logout_mode() \ No newline at end of file diff --git a/opt/ahenk/plugins/sample/main.py b/opt/ahenk/plugins/sample/main.py deleted file mode 100644 index c353133..0000000 --- a/opt/ahenk/plugins/sample/main.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -def info(): - return None \ No newline at end of file diff --git a/opt/ahenk/plugins/sample/policy.py b/opt/ahenk/plugins/sample/policy.py deleted file mode 100644 index c0a4c70..0000000 --- a/opt/ahenk/plugins/sample/policy.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -from base.plugin.abstract_plugin import AbstractPlugin - - -class Sample(AbstractPlugin): - def __init__(self, profile_data, context): - super(Sample, self).__init__() - self.profile_data = profile_data - self.context = context - self.logger = self.get_logger() - - def handle_policy(self): - # TODO Do what do you want to do! - # TODO Don't Forget returning response with - pass - - -def handle_policy(profile_data, context): - print('Sample Plugin Policy') - sample = Sample(profile_data, context) - sample.handle_policy() \ No newline at end of file diff --git a/opt/ahenk/plugins/sample/safe.py b/opt/ahenk/plugins/sample/safe.py deleted file mode 100644 index 2445976..0000000 --- a/opt/ahenk/plugins/sample/safe.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -from base.plugin.abstract_plugin import AbstractPlugin - - -class Safe(AbstractPlugin): - def __init__(self, context): - super(Safe, self).__init__() - self.context = context - self.username = str(context.get_username()) - self.logger = self.get_logger() - - def handle_safe_mode(self): - # TODO Do what do you want to do! - pass - - -def handle_mode(context): - safe = Safe(context) - safe.handle_safe_mode() \ No newline at end of file diff --git a/opt/ahenk/plugins/sample/shutdown.py b/opt/ahenk/plugins/sample/shutdown.py deleted file mode 100644 index f21eb8a..0000000 --- a/opt/ahenk/plugins/sample/shutdown.py +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -from base.plugin.abstract_plugin import AbstractPlugin - - -class Shutdown(AbstractPlugin): - def __init__(self, context): - super(Shutdown, self).__init__() - self.context = context - self.logger = self.get_logger() - - def handle_shutdown_mode(self): - # TODO Do what do you want to do! - pass - - -def handle_mode(context): - shutdown = Shutdown(context) - shutdown.handle_shutdown_mode() \ No newline at end of file diff --git a/opt/ahenk/plugins/sample/task_command_id.py b/opt/ahenk/plugins/sample/task_command_id.py deleted file mode 100644 index 99dd67e..0000000 --- a/opt/ahenk/plugins/sample/task_command_id.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/python3 -# -*- coding: utf-8 -*- - -from base.plugin.abstract_plugin import AbstractPlugin - - -class Sample(AbstractPlugin): - def __init__(self, task, context): - super(Sample, self).__init__() - self.task = task - self.context = context - self.logger = self.get_logger() - - def handle_task(self): - # TODO Do what do you want to do! - # TODO Don't Forget returning response with - pass - - -def handle_task(task, context): - print('Sample Plugin Task') - sample = Sample(task, context) - sample.handle_task() \ No newline at end of file