Fix linting issues'
This commit is contained in:
parent
e555f17a7b
commit
4333c2d061
|
@ -2,6 +2,7 @@ import asyncio
|
|||
import multiaddr
|
||||
|
||||
from Crypto.PublicKey import RSA
|
||||
from libp2p.security.insecure_security import InsecureTransport
|
||||
from .peer.peerstore import PeerStore
|
||||
from .peer.id import id_from_public_key
|
||||
from .network.swarm import Swarm
|
||||
|
@ -10,7 +11,6 @@ from .kademlia.routed_host import RoutedHost
|
|||
from .transport.upgrader import TransportUpgrader
|
||||
from .transport.tcp.tcp import TCP
|
||||
from .kademlia.network import KademliaServer
|
||||
from libp2p.security.insecure_security import InsecureTransport
|
||||
|
||||
|
||||
async def cleanup_done_tasks():
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import asyncio
|
||||
from .raw_connection_interface import IRawConnection
|
||||
|
||||
|
||||
class RawConnection(IRawConnection):
|
||||
|
||||
def __init__(self, ip, port, reader, writer, initiator):
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
from abc import ABC, abstractmethod
|
||||
|
||||
# pylint: disable=W0105
|
||||
|
||||
"""
|
||||
Represents a secured connection object, which includes a connection and details about the security
|
||||
involved in the secured connection
|
||||
|
@ -19,4 +21,3 @@ class ISecureConn(ABC):
|
|||
"""
|
||||
:return: map containing details about the connections security
|
||||
"""
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import asyncio
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
# pylint: disable=W0105
|
||||
|
||||
"""
|
||||
Transport that is used to secure a connection. This transport is
|
||||
chosen by a security transport multistream module.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import asyncio
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from abc import ABC
|
||||
from libp2p.protocol_muxer.multiselect_client import MultiselectClient
|
||||
from libp2p.protocol_muxer.multiselect import Multiselect
|
||||
|
||||
# pylint: disable=W0105
|
||||
|
||||
"""
|
||||
Represents a secured connection object, which includes a connection and details about the security
|
||||
involved in the secured connection
|
||||
|
@ -72,13 +72,15 @@ class SecurityMultistream(ABC):
|
|||
:param initiator: true if we are the initiator, false otherwise
|
||||
:return: selected secure transport
|
||||
"""
|
||||
# TODO: Is conn acceptable to multiselect/multiselect_client instead of stream? In go repo,
|
||||
# they pass in a raw conn (https://raw.githubusercontent.com/libp2p/go-conn-security-multistream/master/ssms.go)
|
||||
# TODO: Is conn acceptable to multiselect/multiselect_client
|
||||
# instead of stream? In go repo, they pass in a raw conn
|
||||
# (https://raw.githubusercontent.com/libp2p/go-conn-security-multistream/master/ssms.go)
|
||||
|
||||
protocol = None
|
||||
if initiator:
|
||||
# Select protocol if initiator
|
||||
protocol = await self.multiselect_client.select_one_of(list(self.transports.keys()), conn)
|
||||
protocol = \
|
||||
await self.multiselect_client.select_one_of(list(self.transports.keys()), conn)
|
||||
else:
|
||||
# Select protocol if non-initiator
|
||||
protocol, _ = await self.multiselect.negotiate(conn)
|
||||
|
|
|
@ -25,8 +25,8 @@ class TransportUpgrader:
|
|||
"""
|
||||
if initiator:
|
||||
return await self.security_multistream.secure_outbound(raw_conn, peer_id)
|
||||
else:
|
||||
return await self.security_multistream.secure_inbound(raw_conn)
|
||||
|
||||
return await self.security_multistream.secure_inbound(raw_conn)
|
||||
|
||||
def upgrade_connection(self, conn, generic_protocol_handler, peer_id):
|
||||
"""
|
||||
|
|
|
@ -4,9 +4,8 @@ import pytest
|
|||
|
||||
from libp2p import new_node
|
||||
from libp2p.peer.peerinfo import info_from_p2p_addr
|
||||
from tests.utils import cleanup, set_up_nodes_by_transport_opt
|
||||
from libp2p.security.security_multistream import SecurityMultistream
|
||||
from libp2p.security.insecure_security import InsecureConn, InsecureTransport
|
||||
from libp2p.security.insecure_security import InsecureTransport
|
||||
from tests.utils import cleanup
|
||||
from simple_security import SimpleSecurityTransport
|
||||
|
||||
# TODO: Add tests for multiple streams being opened on different
|
||||
|
@ -25,7 +24,8 @@ async def connect(node1, node2):
|
|||
info = info_from_p2p_addr(addr)
|
||||
await node1.connect(info)
|
||||
|
||||
async def perform_simple_test(assertion_func, transports_for_initiator, transports_for_noninitiator):
|
||||
async def perform_simple_test(assertion_func, \
|
||||
transports_for_initiator, transports_for_noninitiator):
|
||||
|
||||
# Create libp2p nodes and connect them, then secure the connection, then check
|
||||
# the proper security was chosen
|
||||
|
@ -93,4 +93,3 @@ async def test_two_simple_test_security_transport_for_initiator_succeeds():
|
|||
|
||||
await perform_simple_test(assertion_func,
|
||||
transports_for_initiator, transports_for_noninitiator)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user