Skip to content
9 changes: 9 additions & 0 deletions cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-----BEGIN CERTIFICATE-----
MIIBQTCB6KADAgECAhQWyQBQ6xpLta4tn3UdIzsFe5xlBDAKBggqhkjOPQQDAjAU
MRIwEAYDVQQDDAlsb2NhbGhvc3QwHhcNMjUwNTI2MTg0MzQ5WhcNMjYwNTI2MTg0
MzQ5WjAUMRIwEAYDVQQDDAlsb2NhbGhvc3QwWTATBgcqhkjOPQIBBggqhkjOPQMB
BwNCAATNb56TO/OEg6XZHAgYfVr8uSSBXZ5bDGwgwBcEG+id8KoH/YlAGrmWoGei
Lh2xDh29aTSwrK2CbiInCde/QU7uoxgwFjAUBgNVHREEDTALgglsb2NhbGhvc3Qw
CgYIKoZIzj0EAwIDSAAwRQIhAJwxE2piQjYxPDCWT96MAT6jU1T0Uo441RWTrOxK
Exp2AiASli+WPnMb8buv6fduSwPh4j8c5ixXS+Dx6OtENybHmA==
-----END CERTIFICATE-----
24 changes: 24 additions & 0 deletions docs/libp2p.transport.quic.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
libp2p.transport.quic package
=============================

Submodules
----------

libp2p.transport.quic.transport module
--------------------------------------

.. automodule:: libp2p.transport.quic.transport
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: libp2p.transport.quic
:members:
:undoc-members:
:show-inheritance:

.. toctree::
:maxdepth: 4
1 change: 1 addition & 0 deletions docs/libp2p.transport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Subpackages
:maxdepth: 4

libp2p.transport.tcp
libp2p.transport.quic

Submodules
----------
Expand Down
5 changes: 5 additions & 0 deletions key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIJ+k6P81TkBCH8x9kfYq9dvU3EBT/xp+7VXZ9jNnYKGyoAoGCCqGSM49
AwEHoUQDQgAEzW+ekzvzhIOl2RwIGH1a/LkkgV2eWwxsIMAXBBvonfCqB/2JQBq5
lqBnoi4dsQ4dvWk0sKytgm4iJwnXv0FO7g==
-----END EC PRIVATE KEY-----
3 changes: 3 additions & 0 deletions libp2p/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
Yamux,
)
from libp2p.stream_muxer.yamux.yamux import PROTOCOL_ID as YAMUX_PROTOCOL_ID
from libp2p.transport.quic.transport import (
QuicTransport,
)
from libp2p.transport.tcp.tcp import (
TCP,
)
Expand Down
4 changes: 4 additions & 0 deletions libp2p/transport/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
)


class TransportError(BaseLibp2pError):
"""Raised when there is an error in the transport layer."""


class OpenConnectionError(BaseLibp2pError):
pass

Expand Down
16 changes: 16 additions & 0 deletions libp2p/transport/quic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
QUIC transport implementation for libp2p.

This module provides QUIC transport functionality for libp2p, enabling
high-performance, secure communication between peers using the QUIC protocol.
"""

# Avoid importing Libp2pQuicProtocol to prevent circular dependencies

from .transport import (
QuicTransport,
)

__all__ = [
"QuicTransport",
]
60 changes: 60 additions & 0 deletions libp2p/transport/quic/protocol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from typing import (
TYPE_CHECKING,
Any,
Optional,
)

from aioquic.quic.connection import (
QuicConnection,
)

from libp2p.abc import (
IRawConnection,
)

if TYPE_CHECKING:
from libp2p.transport.quic.transport import (
QuicTransport,
)


class Libp2pQuicProtocol(IRawConnection):
def __init__(self, transport: "QuicTransport") -> None:
self._transport = transport
self._remote_address: Optional[tuple[str, int]] = None
self._connected: bool = False

def get_remote_address(self) -> Optional[tuple[str, int]]:
return self._remote_address

def is_connected(self) -> bool:
return self._connected

async def run(self) -> None:
# Set _connected to True when the connection is established
self._connected = True
print("Protocol run started, connection established") # Add logging
# Your actual logic goes here

def some_method(self) -> None:
# Lazy import to avoid circular dependency
pass

print("Using QuicTransport")
# Use QuicTransport here

def quic_event_received(self, event: Any) -> None:
# Placeholder for handling QUIC events
print("QUIC event received:", event)

# Define _connection attribute
_connection: Optional[QuicConnection] = None

async def read(self, n: int = -1) -> bytes:
raise NotImplementedError("QUIC read not implemented yet")

async def write(self, data: bytes) -> None:
raise NotImplementedError("QUIC write not implemented yet")

async def close(self) -> None:
raise NotImplementedError("QUIC close not implemented yet")
Loading
Loading