175 Commits

Author SHA1 Message Date
Didrik Nordström
ea0621b2f6
fix: reset discovery services upon stop (#618) 2020-04-27 12:07:30 +02:00
Hugo Dias
9b13fe321a
fix: remove node global (#587)
* fix: use new libp2p-crypto

* fix: remove node globals and reduce size

- adds buffer require
- adds globalThis where needed
- streaming-iterables was remove and new utils created, this will be consolidated in `ipfs-utils` and backported here to normalize all these iterator helper functions
- latency-monitor was copied inside the repo
- iso-random-stream is now used instead of node crypto
- the test `should ignore self on discovery` was moved to node only

Size: 172.97KB
47.03KB below the 220KB limit.

`aegir build --node false` and `aegir test -t browser --node false` now work 🎉

* fix: fix require path

* fix: feedback

* fix: update deps and bundle size

* chore: bump interfaces

* chore: update size
2020-04-24 17:10:40 +02:00
robertkiel
c940f2d384
fix: add null check in libp2p.hangUp()
test: add hangup test and fix linting
2020-04-15 14:49:47 +02:00
Jacob Heun
e192eb6508
fix: make circuit relay listening addresses more forgiving (#604)
* test: dont be strict on nock mocking

* fix: be more forgiving with circuit listening addresses
2020-04-14 12:37:52 +02:00
Jacob Heun
0fd5188176
test: dont use mdns in browser tests (#602)
* test(fix): dont use mdns in browser tests

* refactor: use async await consistently for _setupPeerDiscovery
2020-04-06 13:22:12 +02:00
Cayman
bd7fd0f755
fix: await peer discovery start in libp2p start (#600) 2020-04-06 12:32:12 +02:00
Jacob Heun
9e35fbc316
fix: pass libp2p to discovery services (#597)
* fix: include libp2p in the options passed to discovery creation

* fix: handle multiple peer addresses in get multiaddrs for peers

* test(peer-store): add test to verify returned relay multiaddrs
2020-03-31 13:43:27 +02:00
Jacob Heun
30728753cf
fix: only use a single export (#596) 2020-03-31 13:01:06 +02:00
Vasco Santos
4bce6aa0b9
chore: use libp2p utils (#559)
* chore: use libp2p utils

* chore: update libp2p-utils
2020-02-18 07:45:26 -05:00
Alex Potsides
a8984c6cd3
fix: remove use of assert module (#561)
* fix: remove use of assert module

The polyfill is big, we can simulate it by throwing an Error and it doesn't work under React Native.

* chore: fix linting

* chore: export invalid param code

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
2020-02-14 14:42:23 +01:00
Jacob Heun
a317a8b011
fix: dont allow multiaddr dials without a peer id (#558)
* fix: require peer ids when dialing multiaddrs

* chore: fix lint

* docs: add more info about multiaddr peer ids
2020-02-11 16:32:40 +01:00
Jacob Heun
f662fdcf36
fix: ensure identify streams are closed (#551)
* fix: ensure identify streams are closed

* fix: call connection.addStream properly

* chore: simplify stream closure

* test: improve durability of identify push test
2020-02-05 17:35:27 +01:00
Alex Potsides
be8fc9daf1
fix: stop stream after first pong received (#545)
When connecting to go-IPFS from a webworker, the stream opened by
the ping protocol is never closed.

The change here uses `take` to only receive one buffer from the
remote node before closing the stream.
2020-02-03 15:50:40 +01:00
Vasco Santos
560d7084fe refactor: examples-browser (#508)
* refactor: examples-browser

* chore: add information to use signalling server

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>

* chore: update deps

* docs: refactor libp2p browser example

* docs(examples): add back websockets and boostrap nodes

docs(examples): redo the browser readme

* fix: handle edge case of connections closing early

* chore: fix lint

* chore: update example deps and readme

* chore: update webrtc-star

* chore: apply suggestions from code review

Co-Authored-By: Alan Shaw <alan.shaw@protocol.ai>

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
2020-01-24 14:40:40 +01:00
Jacob Heun
c1038bec92 fix: use toB58String everywhere to be consistent (#537)
* chore: update deps

* fix: consistently use b58 peerid string

The migration to base32 will happen at a later date
2020-01-24 14:40:40 +01:00
Vasco Santos
bb2e56e6c7 fix: registrar should filter the disconnected conn (#532)
* fix: registrar on disconnect only when no connections

* chore: add test
2020-01-24 14:40:40 +01:00
Alan Shaw
4222c49556 fix: stop discoveries (#530)
* fix: stop discoveries

* test: add discovery stop test

* chore: fix lint

Co-authored-by: Jacob Heun <jacobheun@gmail.com>
2020-01-24 14:40:40 +01:00
Alan Shaw
ba4681b312 fix: conn mngr min/max connection values (#528)
Fixes the case when options are passed with `maxConnections` and/or `minConnections` set to `undefined`:

```console
{
  defaultOptions: {
    maxConnections: Infinity,
    minConnections: 0,
    maxData: Infinity,
    maxSentData: Infinity,
    maxReceivedData: Infinity,
    maxEventLoopDelay: Infinity,
    pollInterval: 2000,
    movingAverageInterval: 60000,
    defaultPeerValue: 1
  },
  options: {
    minPeers: 25,
    maxConnections: undefined,
    minConnections: undefined
  }
}
{ maxConnections: undefined, minConnections: undefined }
      1) "before all" hook in "custom config"
(node:67176) UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: Connection Manager maxConnections must be greater than minConnections
    at new ConnectionManager (node_modules/libp2p/src/connection-manager/index.js:43:5)
    at new Libp2p (node_modules/libp2p/src/index.js:92:30)
    at Object.module.exports [as libp2p] (src/core/components/libp2p.js:27:10)
    at Proxy.start (src/core/components/start.js:48:31)
    at async Daemon.start (src/cli/daemon.js:63:31)
    at async startHttpAPI (test/http-api/routes.js:29:5)
    at async Context.<anonymous> (test/http-api/routes.js:48:7)
```
2020-01-24 14:40:40 +01:00
Jacob Heun
c339be10ee feat: allow transport options to be passed on creation (#524)
* feat: allow transport options to be passed on creation

* fix: only add circuit transport if enabled

* chore: fix lint
2020-01-24 14:40:40 +01:00
Jacob Heun
6445fda050 feat: add libp2p.connections getter (#522)
* fix: make hangup accept what the API says it does

* feat: add libp2p.connections getter

* chore: fix typo
2020-01-24 14:40:40 +01:00
Jacob Heun
4ca481b869 fix: make dialer configurable (#521)
docs: update configuration and api docs
2020-01-24 14:40:40 +01:00
Vasco Santos
5d7ee50e76 fix: upgrader should not need muxers (#517)
* fix: upgrader should not need muxers

* chore: address review

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
2020-01-24 14:40:40 +01:00
Jacob Heun
15f7c2a974 feat: coalescing dial support (#518)
* docs: fix spelling in api

* fix: dont create peerstore twice

* feat: add support for dial coalescing

* doc(fix): add setPeerValue to API TOC

* docs: add more jsdocs to dialer

* chore: remove old comment

* fix: ensure connections are closed

* fix: registrar.getConnections returns first open conn

* fix: directly set the closed status

* chore: remove unneeded log

* refactor: peerStore.put takes an options object
2020-01-24 14:40:40 +01:00
Jacob Heun
14a1955a78 refactor: connection manager (#511)
* refactor: initial refactor of the connection manager

* fix: start/stop issues

* fix: add tests and resolve pruning issues

* chore: fix lint

* test: move conn manager tests to node only for now

* chore: apply suggestions from code review

Co-Authored-By: Vasco Santos <vasco.santos@moxy.studio>

* fix: assert min max connection options

* test: fix assertion check for browser

* docs: add api and config docs for conn manager
2020-01-24 14:40:40 +01:00
Vasco Santos
f1eb373235 feat: discovery modules from transports should be added (#510)
* feat: discovery modules from transports should be added

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>

* chore: address review

* chore: apply suggestions from code review

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
2020-01-24 14:40:40 +01:00
Jacob Heun
dabee00127 refactor: stats (#501)
* docs: add initial notes on stats

* feat: initial refactor of stats to metrics

* feat: add support for placeholder metrics

This is helpful for tracking metrics prior to knowing the remote peers id

* fix: add metrics tests and fix issues

* fix: always clear the dial timeout timer

* docs: add metrics to api doc

* chore: apply suggestions from code review

Co-Authored-By: Vasco Santos <vasco.santos@moxy.studio>

* docs: update metrics docs

* fix: call metrics.onDisconnect

* docs(config): add example headers so they appear in the TOC

* docs(config): add metrics configuration

* docs(relay): fix relay configuration docs
2020-01-24 14:40:40 +01:00
Vasco Santos
4f7586886c refactor: ping (#505)
* refactor: ping

* chore: ping is now a function

* chore: address review
2020-01-24 14:40:40 +01:00
Jacob Heun
71f46bf4a6 chore: it-all over async-iterator-all 2020-01-24 14:40:40 +01:00
Jacob Heun
9e1a9f04ae chore: move stats folder and delete old switch code 2020-01-24 14:40:40 +01:00
Jacob Heun
90ecc57dbc fix: token release logic 2020-01-24 14:40:40 +01:00
Jacob Heun
2570a1ba30 fix: release tokens as soon as they are available 2020-01-24 14:40:40 +01:00
Jacob Heun
633b0c291f fix: clean up pending dials abort per feedback 2020-01-24 14:40:40 +01:00
Jacob Heun
7d505494be docs: add DialRequest description 2020-01-24 14:40:40 +01:00
Jacob Heun
ba02764c5f feat: abort all pending dials on stop 2020-01-24 14:40:40 +01:00
Jacob Heun
def3574ba0 test: add tests for DialRequest 2020-01-24 14:40:40 +01:00
Jacob Heun
466b4dfd70 chore: update per feedback 2020-01-24 14:40:40 +01:00
Jacob Heun
98e82df5e1 refactor: cleanup and reorganize 2020-01-24 14:40:40 +01:00
Jacob Heun
6ad840c3f3 chore: update docs
fix: protect against duplicate token releases
2020-01-24 14:40:40 +01:00
Jacob Heun
7ac5e42a1a chore: fix linting 2020-01-24 14:40:40 +01:00
Jacob Heun
b86ef64904 refactor: consolidation multiaddr dial methods 2020-01-24 14:40:40 +01:00
Jacob Heun
b6cd48b798 refactor: clean up dial timeout abort 2020-01-24 14:40:40 +01:00
Jacob Heun
a5b54a7017 feat: add early token recycling in 2020-01-24 14:40:40 +01:00
Jacob Heun
e1e3be8106 refactor: simplify DialRequest logic per feedback 2020-01-24 14:40:40 +01:00
Jacob Heun
b7432bd02b chore: use any-signal module 2020-01-24 14:40:40 +01:00
Jacob Heun
7c2fefda46 refactor: PER_PEER_LIMIT is now MAX_PER_PEER_DIALS 2020-01-24 14:40:40 +01:00
Jacob Heun
2788982c53 chore: apply suggestions from code review
Co-Authored-By: Vasco Santos <vasco.santos@moxy.studio>
Co-Authored-By: Alan Shaw <alan.shaw@protocol.ai>
2020-01-24 14:40:40 +01:00
Jacob Heun
76ec1ccd21 chore: remove commented code 2020-01-24 14:40:40 +01:00
Jacob Heun
e445a17278 feat: add token based dialer 2020-01-24 14:40:40 +01:00
Jacob Heun
12fc069873 fix: clean up peer discovery flow (#494)
* fix: clean up peer discovery flow

* test(fix): let libp2p start after connecting

* test(fix): dont auto dial in disco tests
2020-01-24 14:40:40 +01:00
Vasco Santos
9a6e07d70b chore: update pubsub implementations (#493) 2020-01-24 14:40:40 +01:00