Beispiel #1
0
 def on_ssh(self, ssh_list=None):
     """Get/Set SSH list on server/client request. If event emitted without ssh_list, returns current SSH list."""
     if ssh_list is not None:
         models.set_ssh_list(ssh_list)
         self.emit('ssh', models.get_ssh_list())
     else:
         self.emit('ssh', models.get_ssh_list())
Beispiel #2
0
    def on_check_ssh(self):
        ssh_list = models.get_ssh_list()
        self.on_clear_live()
        self.on_clear_die()

        coros = [self.check_ssh_handler(ssh) for ssh in ssh_list]
        fut = asyncio.gather(*coros, loop=self.loop)
        self.loop.run_until_complete(fut)
Beispiel #3
0
    def on_connect_ssh(self, port_list):
        global current_pool
        if current_pool is None:
            process_count = models.get_settings()['process_count']
            current_pool = self.pool = controllers.ProxyPool(
                process_count, self.loop)
        for ssh in models.get_ssh_list():
            self.pool.add_ssh(ssh['ip'], ssh['username'], ssh['password'])

        aws = [
            self.pool.proxy_port(port, self.port_proxy_callback)
            for port in port_list
        ]
        try:
            self.loop.run_until_complete(asyncio.gather(*aws, loop=self.loop))
        except controllers.OutOfSSHError:
            self.emit('out_of_ssh')
Beispiel #4
0
def ssh_list():
    return json.dumps(models.get_ssh_list())