From 7ce9a5e7b57045b1c4c75a5842da751c8cb42633 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Mon, 9 Jul 2018 09:39:55 +0800 Subject: [PATCH] fix ssh record log bug --- webterminal/consumers.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/webterminal/consumers.py b/webterminal/consumers.py index 40279d9b..d6a034e7 100644 --- a/webterminal/consumers.py +++ b/webterminal/consumers.py @@ -116,9 +116,9 @@ def receive(self,text=None, bytes=None, **kwargs): self.message.reply_channel.send({"accept":False}) logger.error("unknown or unsupported key type, only support rsa dsa ed25519 ecdsa key type!") self.ssh.connect(ip, port=port, username=username, pkey=private_key, timeout=3) - #when connect server sucess record log - audit_log = Log.objects.create(user=User.objects.get(username=self.message.user),server=data,channel=self.message.reply_channel.name,width=width,height=height) - audit_log.save() + #when connect server sucess record log + audit_log = Log.objects.create(user=User.objects.get(username=self.message.user),server=data,channel=self.message.reply_channel.name,width=width,height=height) + audit_log.save() except socket.timeout: self.message.reply_channel.send({"text":json.dumps(['stdout','\033[1;3;31mConnect to server time out\033[0m'])},immediately=True) logger.error("Connect to server {0} time out!".format(ip)) @@ -361,9 +361,9 @@ def openterminal(self,ip,id,channel,width,height,elementid=None): self.message.reply_channel.send({"text":json.dumps(['stdout','\033[1;3;31munknown or unsupported key type, only support rsa dsa ed25519 ecdsa key type\033[0m',elementid.rsplit('_')[0]])},immediately=True) self.message.reply_channel.send({"accept":False}) self.ssh.connect(ip, port=port, username=username, pkey=private_key, timeout=3) - #record log - audit_log = Log.objects.create(user=User.objects.get(username=self.message.user),server=data,channel=elementid,width=width,height=height) - audit_log.save() + #record log + audit_log = Log.objects.create(user=User.objects.get(username=self.message.user),server=data,channel=elementid,width=width,height=height) + audit_log.save() except socket.timeout: self.message.reply_channel.send({"text":json.dumps(['stdout','\033[1;3;31mConnect to server time out\033[0m',elementid.rsplit('_')[0]])},immediately=True) self.message.reply_channel.send({"accept":False})