Skip to content

Commit

Permalink
feat: turn on WebTransport by default
Browse files Browse the repository at this point in the history
Fixes #9292
  • Loading branch information
Jorropo committed Dec 12, 2022
1 parent 3a3a971 commit 16d189b
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 30 deletions.
4 changes: 4 additions & 0 deletions config/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ func addressesConfig() Addresses {
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic",
"/ip4/0.0.0.0/udp/4001/quic-v1",
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
"/ip6/::/udp/4001/quic",
"/ip6/::/udp/4001/quic-v1",
"/ip6/::/udp/4001/quic-v1/webtransport",
},
Announce: []string{},
AppendAnnounce: []string{},
Expand Down
2 changes: 1 addition & 1 deletion core/node/libp2p/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func Transports(tptConfig config.Transports) interface{} {
}

// TODO(9292): Remove the false && to allows it enabled by default
if tptConfig.Network.WebTransport.WithDefault(false && !privateNetworkEnabled) {
if tptConfig.Network.WebTransport.WithDefault(!privateNetworkEnabled) {
if privateNetworkEnabled {
return opts, fmt.Errorf(
"WebTransport transport does not support private networks, please disable Swarm.Transports.Network.WebTransport",
Expand Down
35 changes: 35 additions & 0 deletions docs/changelogs/v0.18.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Below is an outline of all that is in this release, so you get a sense of all th
- [🔦 Highlights](#-highlights)
- [(DAG-)JSON and (DAG-)CBOR Response Formats on Gateways](#dag-json-and-dag-cbor-response-formats-on-gateways)
- [Content Routing](#content-routing)
- [WebTransport enabled by default](#webtransport-enabled-by-default)
- [QUICv1 & WebTransport Config Migration](#quicv1--webtransport-config-migration)
- [Provider Record Republish and Expiration](#provider-record-republish-and-expiration)
- [Lowered `ConnMgr`](#lowered-connmgr)
- [Changelog](#changelog)
Expand Down Expand Up @@ -89,6 +91,39 @@ Alternative routing rules, including alternative IPNI endpoints, can be configur

Learn more in [`Routing` docs](https://github.com/ipfs/kubo/blob/master/docs/config.md#routing).

#### WebTransport enabled by default

[WebTransport](https://github.com/libp2p/go-libp2p/issues/1717) is a new libp2p transport that [has been introduced in v0.16](v0.16.md#-webtransport-new-experimental-transport) that is based on top of QUIC and HTTP3.

This allows browsers to contact Kubo nodes, so now instead of just serving requests for other system level applicative nodes, you can also serve requests directly to a browser.
For the full story see [connectivity.libp2p.io](https://connectivity.libp2p.io/).

##### WebTransport + QUIC on one single port

The new feature that allows us to ship WebTransport by default is that [go-libp2p now supports running WebTransport and QUIC transports on the same QUIC listener](https://github.com/libp2p/go-libp2p/issues/1759).

To use this feature, you just have to register two listen address on the same `/ipX/.../udp/XXX` prefix.

#### QUICv1 & WebTransport Config Migration

Go-libp2p now differentiate the first version of QUIC we implemented (and were using until then), `Draft-29`, and the ratified protocol in RFC9000, `QUICv1`.
This manifest as two different multiaddr components `/quic` (old Draft-29) and `/quic-v1`.

Even tho Draft-29 and QUICv1 are similar they are not fully inter-compatible, go-libp2p do supports listening with both versions on one single listener.

`/webtransport` now also need to be prefixed by a `/quic-v1` instead of `/quic` component.
This has no protocol change, WebTransport only supports QUICv1 and were running on QUICv1 already.

To support QUICv1 and WebTransport by default we run a new migration (n°`13`) which automatically add entries in addresses related fields in the config:
- Replace all `/quic/webtransport` to `/quic-v1/webtransport`.
- For all `/quic` listener, keep the Draft-29 listener, and on the same ip and port, add `/quic-v1` and `/quic-v1/webtransport` listeners.

##### `/quic` (Draft-29) early-deprecation

We plan to remove support for QUIC Draft-29 in the mid to long term future.

You must not use `/quic` for new deployements and use `/quic-v1` instead.

#### Provider Record Republish and Expiration

Default `Reprovider.Interval` changed from 12h to 22h to match new defaults for the Provider Record Expiration (48h) in [go-libp2p-kad-dht v0.20.0](https://github.com/libp2p/go-libp2p-kad-dht/releases/tag/v0.20.0).
Expand Down
41 changes: 12 additions & 29 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,21 @@ Supported Transports:

* tcp/ip{4,6} - `/ipN/.../tcp/...`
* websocket - `/ipN/.../tcp/.../ws`
* quic - `/ipN/.../udp/.../quic`
* webtransport (*experiemental*) - `/ipN/.../udp/.../quic/webtransport` - require using a different port than the QUIC listener for now
* quic (Draft-29) - `/ipN/.../udp/.../quic` - can share the same two tuple with `/quic-v1` and `/quic-v1/webtransport`
* quicv1 (RFC9000) - `/ipN/.../udp/.../quic-v1` - can share the same two tuple with `/quic` and `/quic-v1/webtransport`
* webtransport `/ipN/.../udp/.../quic-v1/webtransport` - can share the same two tuple with `/quic` and `/quic-v1`

Default:
```json
[
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic",
"/ip6/::/udp/4001/quic"
"/ip4/0.0.0.0/udp/4001/quic-v1",
"/ip4/0.0.0.0/udp/4001/quic-v1/webtransport",
"/ip6/::/udp/4001/quic",
"/ip6/::/udp/4001/quic-v1",
"/ip6/::/udp/4001/quic-v1/webtransport"
]
```

Expand Down Expand Up @@ -1209,7 +1214,7 @@ forgotten about.
A smaller value for this parameter means that Pubsub messages in the cache will
be garbage collected sooner, which can result in a smaller cache. At the same
time, if there are slower nodes in the network that forward older messages,
this can cause more duplicates to be propagated through the network.
this can cause more duplicates to be propagated through the network.

Conversely, a larger value for this parameter means that Pubsub messages in the
cache will be garbage collected later, which can result in a larger cache for
Expand Down Expand Up @@ -1812,7 +1817,7 @@ Type: `flag`

This is the max amount of memory to allow libp2p to use.
libp2p's resource manager will prevent additional resource creation while this limit is reached.
This value is also used to scale the limit on various resources at various scopes
This value is also used to scale the limit on various resources at various scopes
when the default limits (discussed in [libp2p resource management](./libp2p-resource-management.md)) are used.
For example, increasing this value will increase the default limit for incoming connections.

Expand All @@ -1837,7 +1842,7 @@ The map supports fields from the [`LimitConfig` struct](https://github.com/libp2

[`BaseLimit`s](https://github.com/libp2p/go-libp2p/blob/master/p2p/host/resource-manager/limit.go#L89) can be set for any scope, and within the `BaseLimit`, all limit <key,value>s are optional.

The `Swarm.ResourceMgr.Limits` override the default limits described above.
The `Swarm.ResourceMgr.Limits` override the default limits described above.
Any override `BaseLimits` or limit <key,value>s from `Swarm.ResourceMgr.Limits`
that aren't specified will use the [computed default limits](./libp2p-resource-management.md#computed-default-limits).

Expand Down Expand Up @@ -1992,38 +1997,16 @@ Since this runs on top of `HTTP/3` it uses `QUIC` under the hood.
We expect it to perform worst than `QUIC` because of the extra overhead,
this transport is really meant at agents that cannot do `TCP` or `QUIC` (like browsers).

For now it is **disabled by default** and considered **experimental**.
If you find issues running it please [report them to us](https://github.com/ipfs/kubo/issues/new).

In the future Kubo will listen on WebTransport by default for anyone already listening on QUIC addresses.

WebTransport is a new transport protocol currently under development by the IETF and the W3C, and already implemented by Chrome.
Conceptually, it’s like WebSocket run over QUIC instead of TCP. Most importantly, it allows browsers to establish (secure!) connections to WebTransport servers without the need for CA-signed certificates,
thereby enabling any js-libp2p node running in a browser to connect to any kubo node, with zero manual configuration involved.

The previous alternative is websocket secure, which require installing a reverse proxy and TLS certificates manually.

Default: Disabled
Default: Enabled

Type: `flag`


##### How to enable WebTransport

Thoses steps are temporary and wont be needed once we make it enabled by default.

1. Enable the WebTransport transport:
`ipfs config Swarm.Transports.Network.WebTransport --json true`
1. Add a listener address for WebTransport to your `Addresses.Swarm` key, for example:
```json
[
"/ip4/0.0.0.0/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic",
"/ip4/0.0.0.0/udp/4002/quic/webtransport"
]
```
1. Restart your daemon to apply the config changes.

### `Swarm.Transports.Security`

Configuration section for libp2p _security_ transports. Transports enabled in
Expand Down

0 comments on commit 16d189b

Please sign in to comment.