1
0
mirror of https://github.com/fluencelabs/js-libp2p synced 2025-03-16 15:40:49 +00:00

1185 Commits

Author SHA1 Message Date
Rakesh Shrestha
5934b13cce
Protocol muxing docs explanation ()
* update examples

* prettier to single quotes

* protocol-muxing bidirectional code explanation

Co-authored-by: aomini daiki <rakesh.shrestha@hazesoft.co>
2022-05-24 10:34:22 -05:00
Alex Potsides
b09eb8fc53
fix: explicitly close streams when connnections close ()
Make sure we don't leave streams open.

Updates all deps to close multiplexed streams when closing connections.
2022-05-23 13:45:20 +01:00
Robert Kiel
35f9c0c793
fix: fix unintended aborts in dialer ()
Fix a bug where `DialRequest` can abort wrong dial attempts.

Co-authored-by: Robert Kiel <robert.kiel@hoprnet.io>
2022-05-18 14:53:58 +01:00
Alex Potsides
d5386df684
fix: do upnp hole punch after startup ()
The transport manager configures it's addresses during the `start`
phase so access them during `afterStart` so they'll be ready for use.
2022-05-18 13:19:31 +01:00
Steve Loeppky
1f5d5c2de1
Added pubsub to the TOC () 2022-05-16 13:22:41 -05:00
github-actions[bot]
7678156cf3
chore: release 0.37.0 ()
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
v0.37.0
2022-05-16 12:10:31 +01:00
Alex Potsides
f2fd4e30ff
docs: add migration guide ()
Adds migration guide for `libp2p@0.37.x`
2022-05-16 10:58:56 +01:00
Alex Potsides
31480603f3
fix: simplify pnet exports ()
Export the key generator from `libp2p/pnet`
2022-05-16 10:07:32 +01:00
Alex Potsides
4837430d8b
fix: encode enums correctly ()
Updates protons and regenerates protobuf code to encode enums correctly
2022-05-10 12:35:33 +01:00
Alex Potsides
da3d19b309
fix: update interfaces ()
Update to the latest interfaces version
2022-05-04 16:03:43 +01:00
Alex Potsides
a15254fdd4
fix: update to new interfaces ()
Notably removes the `Dialer` interface as the `ConnectionManager` is now in charge of managing connections.
2022-05-04 10:19:04 +01:00
tuyennhv
d16817ca44
fix: emit peer:connect after all ()
**Motivation**

In lodestar, when we handle "peer:connect" event, we dial the peer which gives another "peer:connect" event and it causes other issues

**Motivation**

In `onConnect` function, "peer:connect" event should be emitted after we add connection to the `connections` map so that when app dial the peer in "peer:connect" event handler, it uses the same/existing connection
2022-04-22 20:56:47 +01:00
Alex Potsides
fab4f1385c
fix: update pubsub interfaces ()
Update to latest version of pubsub interface
2022-04-22 20:49:35 +01:00
Alex Potsides
5397137c65
fix: use placeholder dht/pubsub ()
Instead of making the `.dht` and `.pubsub` properties optional, use dummy implementations that throw exceptions if they are not configured.

This way we don't have to null guard everywhere they are accessed.
2022-04-21 15:46:06 +01:00
Alex Potsides
147304449e
fix: expose getPublicKey ()
This is used externally by IPFS so expose the method
2022-04-14 18:00:21 +01:00
Alex Potsides
1b9bab68ed
chore: update deps () 2022-04-14 08:05:43 +01:00
Alex Potsides
c64a586a20
chore: update aegir to the latest version ()
Removes boilerplate config that is no longer necessary
2022-04-09 09:26:25 +01:00
Alex Potsides
64bfcee509
fix: expose metrics and registrar, use dht for peer discovery ()
Exposes fields used by bitswap and also uses dht for peer discovery which was missed.
2022-04-02 10:11:01 +01:00
Alex Potsides
cc60cfde1a
fix: add transport manager to exports map and fix docs ()
Addresses PR comments from  - fixes syntax of examples in docs, adds the transport manager to the exports map and renames fault tolerance enum for consistency.
2022-03-29 15:39:50 +01:00
Alex Potsides
8cca8e4bfc
fix: update deps ()
Update to released versions of interop suite and webrtc-direct
2022-03-28 16:09:43 +01:00
Alex Potsides
199395de4d
feat: convert to typescript ()
Converts this module to typescript.

- Ecosystem modules renamed from (e.g.) `libp2p-tcp` to `@libp2p/tcp`
- Ecosystem module now have named exports
- Configuration has been updated, now pass instances of modules instead of classes:
- Some configuration keys have been renamed to make them more descriptive.  `transport` -> `transports`, `connEncryption` -> `connectionEncryption`.  In general where we pass multiple things, the key is now plural, e.g. `streamMuxer` -> `streamMuxers`, `contentRouting` -> `contentRouters`, etc.  Where we are configuring a singleton the config key is singular, e.g. `connProtector` -> `connectionProtector` etc.
- Properties of the `modules` config key have been moved to the root
- Properties of the `config` config key have been moved to the root
```js
// before
import Libp2p from 'libp2p'
import TCP from 'libp2p-tcp'

await Libp2p.create({
  modules: {
    transport: [
      TCP
    ],
  }
  config: {
    transport: {
      [TCP.tag]: {
        foo: 'bar'
      }
    },
    relay: {
      enabled: true,
      hop: {
        enabled: true,
        active: true
      }
    }
  }
})
```
```js
// after
import { createLibp2p } from 'libp2p'
import { TCP } from '@libp2p/tcp'

await createLibp2p({
  transports: [
    new TCP({ foo: 'bar' })
  ],
  relay: {
    enabled: true,
    hop: {
      enabled: true,
      active: true
    }
  }
})
```
- Use of `enabled` flag has been reduced - previously you could pass a module but disable it with config.  Now if you don't want a feature, just don't pass an implementation.   Eg:
```js
// before
await Libp2p.create({
  modules: {
    transport: [
      TCP
    ],
    pubsub: Gossipsub
  },
  config: {
    pubsub: {
      enabled: false
    }
  }
})
```
```js
// after
await createLibp2p({
  transports: [
    new TCP()
  ]
})
```
- `.multiaddrs` renamed to `.getMultiaddrs()` because it's not a property accessor, work is done by that method to calculate announce addresses, observed addresses, etc
- `/p2p/${peerId}` is now appended to all addresses returned by `.getMultiaddrs()` so they can be used opaquely (every consumer has to append the peer ID to the address to actually use it otherwise).  If you need low-level unadulterated addresses, call methods on the address manager.

BREAKING CHANGE: types are no longer hand crafted, this module is now ESM only
2022-03-28 14:30:27 +01:00
Rakesh Shrestha
3cfe4bbfac
docs: update auto relay example code usage ()
Co-authored-by: aomini daiki <rakesh.shrestha@hazesoft.co>
2022-02-28 17:46:56 +01:00
Aleksei
6a3e37f250
chore: update js-interfaces URL in examples/transports README () 2022-02-01 10:11:19 +01:00
github-actions[bot]
bad9e8c0ff
chore: release 0.36.2 ()
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
v0.36.2
2022-01-26 11:03:09 +00:00
Alex Potsides
902f10d58d
fix: reject connections when not running ()
When the node is shutting down, new connections can still be received.

If this happens we can end up writing into the datastore when it's
been closed which throws an error.

Instead, if we're not running, have the connection manager close new
incoming connections.
2022-01-26 10:52:23 +00:00
github-actions[bot]
fc12973344
chore: release 0.36.1 ()
### [0.36.1](https://www.github.com/libp2p/js-libp2p/compare/v0.36.0...v0.36.1) (2022-01-25)


### Bug Fixes

* await unhandle of protocols ([](https://www.github.com/libp2p/js-libp2p/issues/1144)) ([d44bd90](d44bd9094f))
---

This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
v0.36.1
2022-01-25 20:09:03 +00:00
Alex Potsides
d44bd9094f
fix: await unhandle of protocols ()
To allow us to shut down cleanly, we must wait the unhandling of protocols - this is because they write the new list of protocols into the datastore which might also be in the process of shutting down.
2022-01-25 19:56:56 +00:00
github-actions[bot]
831ed39701
chore: release 0.36.0 ()
## [0.36.0](https://www.github.com/libp2p/js-libp2p/compare/v0.35.8...v0.36.0) (2022-01-25)

### ⚠ BREAKING CHANGES

* abort-controller dep is gone from dependency tree
* `libp2p.handle`, `libp2p.registrar.register` and the peerstore methods have become async

### Features

* add fetch protocol ([](https://www.github.com/libp2p/js-libp2p/issues/1036)) ([d8ceb0b](d8ceb0bc66))
* async peerstore backed by datastores ([](https://www.github.com/libp2p/js-libp2p/issues/1058)) ([978eb36](978eb3676f))
* connection gater ([](https://www.github.com/libp2p/js-libp2p/issues/1142)) ([ff32eba](ff32eba6a0))


### Bug Fixes

* cache build artefacts ([](https://www.github.com/libp2p/js-libp2p/issues/1091)) ([5043cd5](5043cd5643))
* catch errors during identify ([](https://www.github.com/libp2p/js-libp2p/issues/1138)) ([12f1bb0](12f1bb0aee))
* import uint8arrays package in example ([](https://www.github.com/libp2p/js-libp2p/issues/1083)) ([c3700f5](c3700f55d5))
* make tests more reliable ([](https://www.github.com/libp2p/js-libp2p/issues/1139)) ([b7e8706](b7e87066a6))
* prevent auto-dialer from dialing self ([](https://www.github.com/libp2p/js-libp2p/issues/1104)) ([9b22c6e](9b22c6e2f9))
* remove abort-controller dep ([](https://www.github.com/libp2p/js-libp2p/issues/1095)) ([0a4dc54](0a4dc54d08))
* try all peer addresses when dialing a relay ([](https://www.github.com/libp2p/js-libp2p/issues/1140)) ([63aa480](63aa480800))
* update any-signal and timeout-abort-controller ([](https://www.github.com/libp2p/js-libp2p/issues/1128)) ([e0354b4](e0354b4c6b))
* update multistream select ([](https://www.github.com/libp2p/js-libp2p/issues/1136)) ([00e4959](00e49592a3))
* update node-forge ([](https://www.github.com/libp2p/js-libp2p/issues/1133)) ([a4bba35](a4bba35948))
---

This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
v0.36.0
2022-01-25 16:43:46 +00:00
Alex Potsides
ff32eba6a0
feat: connection gater ()
Port of https://github.com/libp2p/go-libp2p-core/blob/master/connmgr/gater.go

Adds a new configuration key `connectionGater` which allows denying the dialing of certain peers, individual multiaddrs and the creation of connections at certain points in the connection flow.

Fixes: https://github.com/libp2p/js-libp2p/issues/175
Refs: https://github.com/libp2p/js-libp2p/issues/744
Refs: https://github.com/libp2p/js-libp2p/issues/769

Co-authored-by: mzdws <8580712+mzdws@user.noreply.gitee.com>
2022-01-25 16:27:01 +00:00
Robert Kiel
9b22c6e2f9
fix: prevent auto-dialer from dialing self ()
Co-authored-by: Robert Kiel <robert.kiel@hoprnet.io>
Co-authored-by: achingbrain <alex@achingbrain.net>
2022-01-24 17:59:14 +00:00
Spencer T Brody
d8ceb0bc66
feat: add fetch protocol ()
Adds three methods to implement the `/libp2p/fetch/0.0.1` protocol:

* `libp2p.fetch(peerId, key) => Promise<Uint8Array>`
* `libp2p.fetchService.registerLookupFunction(prefix, lookupFunction)`
* `libp2p.fetchService.unRegisterLookupFunction(prefix, [lookupFunction])`

Co-authored-by: achingbrain <alex@achingbrain.net>
2022-01-24 17:07:11 +00:00
Alex Potsides
00e49592a3
fix: update multistream select ()
It has types now so the ignore can be removed.
2022-01-21 18:13:33 +00:00
Alex Potsides
63aa480800
fix: try all peer addresses when dialing a relay ()
The order of the addresses can affect our success rate in dialing a
relay - if it's a loopback address or similar it won't work.

Instead try dialing every address.
2022-01-21 11:57:09 -06:00
Alex Potsides
b7e87066a6
fix: make tests more reliable ()
Try to use only public functions and properties to verify test behaviour
2022-01-21 12:58:31 +00:00
Alex Potsides
4c3bf01f35
chore: fix flaky tests ()
These tests are flaky in CI, probably due to differences in timing introduced by 

Fixes 
2022-01-21 08:44:13 +00:00
Alex Potsides
12f1bb0aee
fix: catch errors during identify ()
Sometimes identify can be started while we are shutting down (for
example) - we should just log these errors.
2022-01-21 08:26:21 +00:00
Alex Potsides
a4bba35948
fix: update node-forge ()
Upgrade to 1v of node-forge
2022-01-20 19:23:24 +00:00
achingbrain
fc43db750d chore: fix build on webworkers 2022-01-20 17:33:58 +00:00
achingbrain
bf1fc325b6 chore: add registry 2022-01-20 17:21:48 +00:00
achingbrain
79b356a313 chore: update var name 2022-01-20 16:52:30 +00:00
achingbrain
54e77221eb chore: fix publish command 2022-01-20 16:27:01 +00:00
Alex Potsides
85e23eb1cb
chore: unpack node_module cache before rc publish () 2022-01-20 15:21:42 +00:00
Alex Potsides
cbd9bad86d
chore: run test after build ()
Run CI tests and check at the same time
2022-01-20 14:52:31 +00:00
Alex Potsides
75b922dc21
chore: checkout code and set up node for publishing rc ()
Need to run the checkout and setup-node actions before publishing an RC.
2022-01-20 14:52:12 +00:00
Alex Potsides
280bb1b1f6
chore: autopublish next version ()
If we aren't releasing a version on a given release run, publish an rc under the `next` tag instead.
2022-01-20 14:24:06 +00:00
Alex Potsides
e0354b4c6b
fix: update any-signal and timeout-abort-controller ()
Updates deps to remove abort controller dep

BREAKING CHANGE: abort-controller dep is gone from dependency tree
2022-01-20 14:17:41 +00:00
Alex Potsides
0264eb62ee
chore: update example tests ()
Remove some of the redundancy in the example tests
2022-01-20 13:33:01 +00:00
achingbrain
a0bfe8b534 chore: restore correct cache 2022-01-20 13:32:25 +00:00
Alex Potsides
2963b852db
chore: add automated releases ()
Adds release-please github action to create gated releases and a release issue that tracks all issues that will be in a release.
2022-01-20 13:19:38 +00:00
Alex Potsides
13d45de376
chore: add missing cache dir ()
Fixes ci config
2022-01-20 12:37:52 +00:00