mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-22 10:52:17 +03:00
ip parameter handled
This commit is contained in:
parent
ad0cb49347
commit
6496b0e35e
2 changed files with 12 additions and 2 deletions
|
@ -38,12 +38,14 @@ class Commander(object):
|
||||||
self.clean()
|
self.clean()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
elif len(params) == 5 and params[1] == 'login':
|
elif len(params) > 4 and params[1] == 'login':
|
||||||
print('{0} logging in'.format(str(params[2])))
|
print('{0} logging in'.format(str(params[2])))
|
||||||
data['event'] = params[1]
|
data['event'] = params[1]
|
||||||
data['username'] = params[2]
|
data['username'] = params[2]
|
||||||
data['desktop'] = params[3]
|
data['desktop'] = params[3]
|
||||||
data['display'] = params[4]
|
data['display'] = params[4]
|
||||||
|
if len(params) == 6:
|
||||||
|
data['ip'] = params[5]
|
||||||
|
|
||||||
elif len(params) == 3 and params[1] == 'logout':
|
elif len(params) == 3 and params[1] == 'logout':
|
||||||
print('{0} logging out'.format(str(params[2])))
|
print('{0} logging out'.format(str(params[2])))
|
||||||
|
|
|
@ -28,6 +28,9 @@ class CommandRunner(object):
|
||||||
|
|
||||||
def check_last_login(self):
|
def check_last_login(self):
|
||||||
last_login_tmstmp=self.db_service.select_one_result('session', 'timestamp')
|
last_login_tmstmp=self.db_service.select_one_result('session', 'timestamp')
|
||||||
|
if not last_login_tmstmp:
|
||||||
|
return True
|
||||||
|
|
||||||
if (int(time.time())-int(last_login_tmstmp))<10:
|
if (int(time.time())-int(last_login_tmstmp))<10:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
|
@ -57,6 +60,11 @@ class CommandRunner(object):
|
||||||
username = json_data['username']
|
username = json_data['username']
|
||||||
display = json_data['display']
|
display = json_data['display']
|
||||||
desktop = json_data['desktop']
|
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))
|
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)
|
||||||
self.messenger.send_direct_message(login_message)
|
self.messenger.send_direct_message(login_message)
|
||||||
|
@ -110,7 +118,7 @@ class CommandRunner(object):
|
||||||
username))
|
username))
|
||||||
session_columns = self.db_service.get_cols('session')
|
session_columns = self.db_service.get_cols('session')
|
||||||
self.db_service.update('session', session_columns,
|
self.db_service.update('session', session_columns,
|
||||||
[username, display, desktop, str(int(time.time()))])
|
[username, display, desktop, str(int(time.time())),ip])
|
||||||
get_policy_message = self.message_manager.policy_request_msg(username)
|
get_policy_message = self.message_manager.policy_request_msg(username)
|
||||||
|
|
||||||
self.plugin_manager.process_mode('safe', username)
|
self.plugin_manager.process_mode('safe', username)
|
||||||
|
|
Loading…
Reference in a new issue