-
Notifications
You must be signed in to change notification settings - Fork 3
/
sslbio_connect.py
44 lines (33 loc) · 1.19 KB
/
sslbio_connect.py
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
42
43
44
"""
This benchmark runs a trivial Twisted TLSv1 echo server using the memory BIO
based TLS implementation from L{twisted.protocols.tls}.
"""
from ssl_connect import main as _main
from zope.interface import implementer
from twisted.internet.interfaces import IReactorSSL, IReactorTime
from twisted.protocols.tls import TLSMemoryBIOFactory
from twisted.python.components import proxyForInterface
from benchlib import driver
@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)