2018-11-20 20:28:41 -05:00
|
|
|
from stream_muxer.mplex.mplex import Mplex
|
2018-11-11 19:37:07 -05:00
|
|
|
|
2018-11-12 13:02:49 -05:00
|
|
|
|
|
|
|
class TransportUpgrader():
|
2018-11-26 18:24:29 -05:00
|
|
|
# pylint: disable=no-self-use
|
2018-11-11 09:56:44 -05:00
|
|
|
|
2018-11-11 16:09:37 -05:00
|
|
|
def __init__(self, secOpt, muxerOpt):
|
|
|
|
self.sec = secOpt
|
|
|
|
self.muxer = muxerOpt
|
2018-11-11 09:56:44 -05:00
|
|
|
|
2018-11-11 16:09:37 -05:00
|
|
|
def upgrade_listener(self, transport, listeners):
|
|
|
|
"""
|
|
|
|
upgrade multiaddr listeners to libp2p-transport listeners
|
2018-11-11 09:56:44 -05:00
|
|
|
|
2018-11-11 16:09:37 -05:00
|
|
|
"""
|
2018-11-12 13:02:49 -05:00
|
|
|
|
2018-11-11 16:09:37 -05:00
|
|
|
def upgrade_security(self):
|
|
|
|
pass
|
2018-11-11 09:56:44 -05:00
|
|
|
|
2018-11-29 13:42:05 -05:00
|
|
|
def upgrade_connection(self, conn):
|
2018-11-11 16:09:37 -05:00
|
|
|
"""
|
|
|
|
upgrade raw connection to muxed connection
|
|
|
|
"""
|
2018-11-12 13:02:49 -05:00
|
|
|
|
|
|
|
# For PoC, no security, default to mplex
|
2018-11-11 19:37:07 -05:00
|
|
|
# TODO do exchange to determine multiplexer
|
2018-11-29 13:42:05 -05:00
|
|
|
return Mplex(conn)
|