ssh.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:spoonybard 作者: notnownikki 项目源码 文件源码
def handle(self, *args, **kwargs):
        t = paramiko.Transport(self.request)
        t.add_server_key(host_key)
        # Note that this actually spawns a new thread to handle the requests.
        # (Actually, paramiko.Transport is a subclass of Thread)
        t.start_server(server=self.server)
        # wait for auth
        chan = t.accept(20)
        time_taken = 0.0
        while getattr(chan, 'spoonybard_command', False) is False:
            time.sleep(0.25)
            time_taken += 0.25
            if time_taken > command_timeout:
                break
        if chan is None:
            print('No channel')
            t.close()
            return
        if getattr(chan, 'spoonybard_command', False):
            cmd = chan.spoonybard_command.split(' ')[0]
            args = ' '.join(chan.spoonybard_command.split(' ')[1:])
            command = spoonybard.engine.plugins.get_command_handler(cmd)
            if command is None:
                chan.send('Sorry, %s is an unknown command.\n' % cmd)
            else:
                if command.parse_args(args):
                    command.execute(chan)
                else:
                    command.help(chan)
        chan.close()
        t.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号