Crates.io | libp2p-combined-transport |
lib.rs | libp2p-combined-transport |
version | 0.1.2 |
source | src |
created_at | 2021-08-22 17:36:53.646679 |
updated_at | 2021-09-10 14:50:16.546672 |
description | libp2p combined transport |
homepage | |
repository | https://github.com/wngr/libp2p-combined-transport/ |
max_upload_size | |
id | 440776 |
size | 105,938 |
Libp2p Transport combining two other transports. One of which is the
base transport (like TCP), and another one is a higher-level transport
(like WebSocket). Similar to [OrTransport
], this tries to dial first
with the outer connection, and if that fails, with the base one. The
main difference is that incoming connections can be accepted on either
one of them. For this to work, a switch must be provided when handling
incoming connections. For example for TCP, this can be achieved with
the peek
method on the underlying [TcpStream
].
[ListenerEvent
]s from the base transport are cloned and routed to
the outer transport via the [ProxyTransport
], with the exception of
upgrades.
For a usage example, have a look at the TCP-Websocket example.