You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Add encryption and multiplexing capabilities to libp2p transport connections
11
11
12
-
This package provides the necessary logic to upgrade [multiaddr-net][manet] connections listeners into full [libp2p-transport][tpt] connections and listeners.
12
+
This package is a component of [libp2p](https://libp2p.io), a modular networking
13
+
stack for building peer-to-peer applications.
13
14
14
-
To use, construct a new `Upgrader` with:
15
+
For two libp2p peers to communicate, the connection between them must be secure,
16
+
and each peer must be able to open multiple independent streams of communication
17
+
over a single channel. We call connections with these features "capable"
18
+
connections.
15
19
16
-
* An optional [pnet][pnet]`Protector`.
17
-
* An optional [multiaddr-net][manet] address `Filter`.
18
-
* A mandatory [stream security transport][ss].
19
-
* A mandatory [stream multiplexer transport][smux].
20
+
Many of the underlying [transport protocols][docs-transport] that are used by
21
+
libp2p do not provide the required capabilities "out of the box."
22
+
`go-libp2p-transport-upgrader` provides the necessary logic to upgrade
23
+
connections and listeners into fully capable connections and connection
In order to be upgraded, the underlying connection or listener must be a
27
+
[`multiaddr-net`][manet][`Conn`][manet-conn] or [`Listener`][manet-listener].
28
+
The `multiaddr-net` types integrate the Go standard library connection types
29
+
with [`multiaddr`][multiaddr], an extensible addressing format used throughout
30
+
libp2p.
26
31
27
-
Note: This package largely replaces the functionality of [go-libp2p-conn](https://github.com/libp2p/go-libp2p-conn) but with half the code.
32
+
As well as the mandatory capabilities of security and multiplexing, the upgrader
33
+
can optionally apply a `Protector` for [private networking][pnet], as well as an
34
+
[address filter][maddr-filter] to prevent connections to specific addresses.
28
35
29
36
## Install
30
37
31
-
`go-libp2p-transport-upgrader` is a standard Go module which can be installed with:
38
+
Most people building applications with libp2p will have no need to install
39
+
`go-libp2p-transport-upgrader` directly. It is included as a dependency of the
40
+
main [`go-libp2p`][go-libp2p] "entry point" module and is integrated into the
41
+
libp2p `Host`.
42
+
43
+
For users who do not depend on `go-libp2p` and are managing their libp2p module
44
+
dependencies in a more manual fashion, `go-libp2p-transport-upgrader` is a
45
+
standard Go module which can be installed with:
32
46
33
47
```sh
34
48
go get github.com/libp2p/go-libp2p-transport-upgrader
@@ -41,9 +55,26 @@ or by editing your `go.mod` file as [described by the gomod documentation](https
41
55
42
56
## Usage
43
57
58
+
To use, construct a new `Upgrader` with:
59
+
60
+
* An optional [pnet][pnet]`Protector`.
61
+
* An optional [go-maddr-filter][maddr-filter] address `Filter`.
62
+
* A mandatory [stream security transport][ss].
63
+
* A mandatory [stream multiplexer][smux].
64
+
65
+
In practice, most users will not need to construct an `Upgrader` directly.
66
+
Instead, when constructing a libp2p [`Host`][godoc-host], you can pass in some
67
+
combination of the [`PrivateNetwork`][godoc-pnet-option],
68
+
[`Filters`][godoc-filters-option], [`Security`][godoc-security-option], and
69
+
[`Muxer`][godoc-muxer-option]`Option`s. This will configure the `Upgrader` that
70
+
is created and used by the `Host` internally.
71
+
44
72
## Example
45
73
46
-
Below is a simplified TCP transport implementation using the transport upgrader. In practice, you'll want to use [go-tcp-transport](https://github.com/libp2p/go-tcp-transport) (which has reuseport support).
74
+
Below is a simplified TCP transport implementation using the transport upgrader.
75
+
In practice, you'll want to use
76
+
[go-tcp-transport](https://github.com/libp2p/go-tcp-transport), which is
0 commit comments