forked from twisted-infra/twisted-benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsslbio_connect.py
More file actions
41 lines (26 loc) · 1.12 KB
/
sslbio_connect.py
File metadata and controls
41 lines (26 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
This benchmark runs a trivial Twisted TLSv1 echo server using the memory BIO
based TLS implementation from L{twisted.protocols.tls}.
"""
from zope.interface import implementer
from twisted.internet.interfaces import IReactorTime, IReactorSSL
from twisted.protocols.tls import TLSMemoryBIOFactory
from twisted.python.components import proxyForInterface
from benchlib import driver
from ssl_connect import main as _main
@implementer(IReactorSSL)
class SSLBIOReactor(proxyForInterface(IReactorTime, '_reactor')):
def listenSSL(self, port, factory, contextFactory, *args, **kw):
return self._reactor.listenTCP(
port, TLSMemoryBIOFactory(contextFactory, False, factory),
*args, **kw)
def connectSSL(self, host, port, factory, contextFactory, *args, **kw):
return self._reactor.connectTCP(
host, port, TLSMemoryBIOFactory(contextFactory, True, factory),
*args, **kw)
def main(reactor, duration):
return _main(SSLBIOReactor(reactor), duration)
if __name__ == '__main__':
import sys
import sslbio_connect
driver(sslbio_connect.main, sys.argv)