Exemplo n.º 1
0
    def connect(self, message, id):
        self.message.reply_channel.send({"accept": True})
        if not self.authenticate:
            self.message.reply_channel.send(
                {
                    "text":
                    json.dumps({
                        'status': False,
                        'message': 'You must login to the system!'
                    })
                },
                immediately=True)
            self.message.reply_channel.send({"accept": False})
        else:
            #permission auth
            if not self.haspermission('common.can_monitor_serverinfo'):
                self.message.reply_channel.send(
                    {
                        "text":
                        json.dumps({
                            'status':
                            False,
                            'message':
                            'You have not permission to monitor user action!'
                        })
                    },
                    immediately=True)
                self.message.reply_channel.send({"accept": False})

            client = GuacamoleClient(settings.GUACD_HOST, settings.GUACD_PORT)
            log_object = Log.objects.get(id=id)
            cache_key = str(log_object.gucamole_client_id)

            data = log_object.server

            #draft version for real time monitor
            client.send_instruction(Instruction('select', cache_key))
            instruction = client.read_instruction()
            kwargs = {'width': 1024, 'height': 768, 'read_only': 'true'}
            connection_args = [
                kwargs.get(arg.replace('-', '_'), '')
                for arg in instruction.args
            ]
            client.send_instruction(Instruction('size', 1024, 768, 96))
            client.send_instruction(Instruction('audio', *list()))
            client.send_instruction(Instruction('video', *list()))
            client.send_instruction(Instruction('image', *list()))
            client.send_instruction(Instruction('connect', *connection_args))

            #self.message.reply_channel.send({"text":'0.,{0}.{1};'.format(len(cache_key),cache_key)},immediately=True)
            guacamolethread = GuacamoleThread(self.message, client)
            guacamolethread.setDaemon = True
            guacamolethread.start()

            guacamolethreadwrite = GuacamoleThreadWrite(self.message, client)
            guacamolethreadwrite.setDaemon = True
            guacamolethreadwrite.start()
Exemplo n.º 2
0
    def connect(self, message, id):
        self.message.reply_channel.send({"accept": True})
        if not self.authenticate:
            self.message.reply_channel.send(
                {
                    "text":
                    json.dumps({
                        'status': False,
                        'message': 'You must login to the system!'
                    })
                },
                immediately=True)
            self.message.reply_channel.send({"accept": False})
        else:
            client = GuacamoleClient(settings.GUACD_HOST, settings.GUACD_PORT)
            log_object = Log.objects.get(id=id)
            cache_key = str(log_object.gucamole_client_id)

            data = log_object.server
            print 'cache_key', cache_key
            client.handshake(
                width=data.credential.width,
                height=data.credential.height,
                protocol=data.credential.protocol,
                hostname=data.ip,
                port=data.credential.port,
                username=data.credential.username,
                password=data.credential.password,
                read_only=True,
            )

            client.send_instruction(Instruction('select', cache_key))
            #self.message.reply_channel.send({"text":'0.,{0}.{1};'.format(len(cache_key),cache_key)},immediately=True)
            guacamolethread = GuacamoleThread(self.message, client)
            guacamolethread.setDaemon = True
            guacamolethread.start()

            guacamolethreadwrite = GuacamoleThreadWrite(self.message, client)
            guacamolethreadwrite.setDaemon = True
            guacamolethreadwrite.start()
Exemplo n.º 3
0
 def disconnect(self, message, id):
     # close threading
     print('disconnect')
     try:
         log_object = Log.objects.get(id=id)
         cache_key = log_object.gucamole_client_id
         client = GuacamoleClient(
             settings.GUACD_HOST, settings.GUACD_PORT)
         client.send_instruction(Instruction('select', cache_key))
         instruction = client.read_instruction()
         kwargs = {'width': 1024, 'height': 768, 'read_only': 'true'}
         connection_args = [
             kwargs.get(arg.replace('-', '_'), '') for arg in instruction.args
         ]
         client.send_instruction(Instruction('size', 1024, 768, 96))
         client.send_instruction(Instruction('audio', *list()))
         client.send_instruction(Instruction('video', *list()))
         client.send_instruction(Instruction('image', *list()))
         client.send_instruction(Instruction('connect', *connection_args))
         client.send_instruction(Instruction(
             'disconnect', *connection_args))
     except:
         pass
     finally:
         self.message.reply_channel.send({"accept": False})
Exemplo n.º 4
0
 def disconnect(self, message, id):
     # close threading
     print('disconnect')
     try:
         audit_log = Log.objects.get(
             channel=self.message.reply_channel.name)
         audit_log.is_finished = True
         audit_log.end_time = now()
         audit_log.save()
         cache_key = audit_log.gucamole_client_id
         client = GuacamoleClient(
             settings.GUACD_HOST, settings.GUACD_PORT)
         client.send_instruction(Instruction('select', cache_key))
         instruction = client.read_instruction()
         kwargs = {'width': 1024, 'height': 768, 'read_only': 'true'}
         connection_args = [
             kwargs.get(arg.replace('-', '_'), '') for arg in instruction.args
         ]
         client.send_instruction(Instruction('size', 1024, 768, 96))
         client.send_instruction(Instruction('audio', *list()))
         client.send_instruction(Instruction('video', *list()))
         client.send_instruction(Instruction('image', *list()))
         client.send_instruction(Instruction('connect', *connection_args))
         client.send_instruction(Instruction(
             'disconnect', *connection_args))
     except:
         pass
     finally:
         get_redis_instance().delete(id)
         self.message.reply_channel.send({"accept": False})