plaintext: use varint msg read/writer
This commit is contained in:
parent
6016ea731b
commit
f8240bd2cb
|
@ -3,7 +3,7 @@ from libp2p.crypto.keys import PrivateKey, PublicKey
|
|||
from libp2p.crypto.pb import crypto_pb2
|
||||
from libp2p.crypto.serialization import deserialize_public_key
|
||||
from libp2p.io.abc import ReadWriteCloser
|
||||
from libp2p.io.msgio import FixedSizeLenMsgReadWriter
|
||||
from libp2p.io.msgio import VarIntLengthMsgReadWriter
|
||||
from libp2p.network.connection.exceptions import RawConnError
|
||||
from libp2p.network.connection.raw_connection_interface import IRawConnection
|
||||
from libp2p.peer.id import ID
|
||||
|
@ -20,11 +20,9 @@ from .pb import plaintext_pb2
|
|||
|
||||
PLAINTEXT_PROTOCOL_ID = TProtocol("/plaintext/2.0.0")
|
||||
|
||||
SIZE_PLAINTEXT_LEN_BYTES = 4
|
||||
|
||||
|
||||
class PlaintextHandshakeReadWriter(FixedSizeLenMsgReadWriter):
|
||||
size_len_bytes = SIZE_PLAINTEXT_LEN_BYTES
|
||||
class PlaintextHandshakeReadWriter(VarIntLengthMsgReadWriter):
|
||||
max_msg_size = 1 << 16
|
||||
|
||||
|
||||
class InsecureSession(BaseSession):
|
||||
|
|
|
@ -8,7 +8,6 @@ import trio
|
|||
|
||||
from libp2p.peer.id import ID
|
||||
from libp2p.peer.peerinfo import PeerInfo, info_from_p2p_addr
|
||||
from libp2p.security.insecure.transport import PLAINTEXT_PROTOCOL_ID
|
||||
from libp2p.typing import TProtocol
|
||||
|
||||
from .constants import LOCALHOST_IP
|
||||
|
@ -28,10 +27,8 @@ class P2PDProcess(BaseInteractiveProcess):
|
|||
is_pubsub_signing: bool = False,
|
||||
is_pubsub_signing_strict: bool = False,
|
||||
) -> None:
|
||||
args = [f"-listen={control_maddr!s}"]
|
||||
# NOTE: To support `-insecure`, we need to hack `go-libp2p-daemon`.
|
||||
if security_protocol == PLAINTEXT_PROTOCOL_ID:
|
||||
args.append("-insecure=true")
|
||||
# NOTE: To support `-security`, we need to hack `go-libp2p-daemon`.
|
||||
args = [f"-listen={control_maddr!s}", f"-security={security_protocol}"]
|
||||
if is_pubsub_enabled:
|
||||
args.append("-pubsub")
|
||||
if is_gossipsub:
|
||||
|
|
|
@ -6,7 +6,6 @@ import pytest
|
|||
import trio
|
||||
|
||||
from libp2p.peer.peerinfo import PeerInfo, info_from_p2p_addr
|
||||
from libp2p.security.insecure.transport import PLAINTEXT_PROTOCOL_ID
|
||||
from libp2p.tools.factories import HostFactory
|
||||
from libp2p.tools.interop.envs import GO_BIN_PATH
|
||||
from libp2p.tools.interop.process import BaseInteractiveProcess
|
||||
|
|
Loading…
Reference in New Issue
Block a user