Libp2pQuicConnection class
A libp2p-friendly wrapper around a QUIC connection.
Libp2pQuicConnection encapsulates a raw QuicConnection and exposes simple send and close methods compatible with libp2p transport interfaces. The underlying connection object is accessible via quicConnection for callers that need to interact with QUIC-specific APIs (stream allocation, encryption details, etc.).
Example
final transport = Libp2pQuicTransport();
final conn = await transport.dial(multiaddr);
conn.send(Uint8List.fromList([0x01, 0x02]));
print('Underlying QUIC conn: ${conn.quicConnection}');
conn.close();
Constructors
-
Libp2pQuicConnection(Object _quicConnection, {PeerId? peerId, List<
String> alpnProtocols = const ['libp2p']}) - Creates a libp2p wrapper around quicConnection.
Properties
-
alpnProtocols
→ List<
String> -
ALPN protocols advertised by this endpoint during the TLS handshake.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isAlpnValid → bool
-
Whether the peer's selected ALPN matches one of alpnProtocols.
no setter
- negotiatedAlpn → String?
-
The ALPN protocol negotiated by the peer, if available.
no setter
- peerId ↔ PeerId?
-
The authenticated libp2p PeerId of the remote peer.
getter/setter pair
- quicConnection → Object
-
The underlying QUIC connection object.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) → void - Close the underlying QUIC connection.
-
negotiateProtocol(
List< String> protocols) → Future<String?> - Negotiate a protocol using multistream-select.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
send(
Uint8List data) → void -
Send
dataon a new unidirectional stream. -
toString(
) → String -
A string representation of this object.
inherited
-
validateAlpn(
) → void - Validates that the peer's selected ALPN is in alpnProtocols.
-
verifyPeerCertificate(
List< int> certBytes, {PeerId? expectedPeerId, required CryptoBackend backend}) → Future<bool> -
Verifies that
certBytescontains the libp2p TLS extension, derives the remote PeerId from the embedded public key, and assigns it to peerId. -
verifyPeerCertificateFromHandshake(
{PeerId? expectedPeerId, required CryptoBackend backend}) → Future< bool> - Verifies the peer using the certificate received during the handshake.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited