def main(reactor, duration):
    chunkSize = 16384

    server = BenchmarkSSHFactory()
    server.portal = Portal(BenchmarkRealm())

    checker = InMemoryUsernamePasswordDatabaseDontUse()
    checker.users = {b"username": b"password"}

    server.portal.registerChecker(checker)

    port = reactor.listenTCP(0, server)
    tcpServer = TCP4ClientEndpoint(reactor, '127.0.0.1', port.getHost().port)
    sshServer = SSHCommandClientEndpoint(
        b'chargen', tcpServer,
        lambda command:
            SSHPasswordUserAuth(b'username', b'password', command))

    client = Client(reactor, sshServer)
    d = client.run(duration, chunkSize)
    def cleanup(passthrough):
        d = port.stopListening()
        d.addCallback(lambda ignored: passthrough)
        return d
    d.addCallback(cleanup)
    return d
def main(reactor, duration):
    chunkSize = 16384

    server = BenchmarkSSHFactory()
    server.portal = Portal(BenchmarkRealm())

    checker = InMemoryUsernamePasswordDatabaseDontUse()
    checker.users = {b"username": b"password"}

    server.portal.registerChecker(checker)

    port = reactor.listenTCP(0, server)
    tcpServer = TCP4ClientEndpoint(reactor, '127.0.0.1', port.getHost().port)
    sshServer = SSHCommandClientEndpoint(
        b'chargen', tcpServer,
        lambda command: SSHPasswordUserAuth(b'username', b'password', command))

    client = Client(reactor, sshServer)
    d = client.run(duration, chunkSize)

    def cleanup(passthrough):
        d = port.stopListening()
        d.addCallback(lambda ignored: passthrough)
        return d

    d.addCallback(cleanup)
    return d
Пример #3
0
def main(reactor, duration):
    chunkSize = 16384

    server = ServerFactory()
    server.protocol = Echo
    port = reactor.listenSSL(0, server, cert.options())
    client = Client(
        reactor,
        SSL4ClientEndpoint(
            reactor, '127.0.0.1', port.getHost().port,
            CertificateOptions(
                verify=True, requireCertificate=True, caCerts=[cert.original])))
    d = client.run(duration, chunkSize)
    def cleanup(passthrough):
        d = port.stopListening()
        d.addCallback(lambda ignored: passthrough)
        return d
    d.addCallback(cleanup)
    return d