Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: libp2p/js-libp2p-webrtc-star
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 89cf20c43bd694146325276e4370a8c81d5377e3
Choose a base ref
...
head repository: libp2p/js-libp2p-webrtc-star
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c629cc1b19e36a34340f1b6677ba6739afa834e2
Choose a head ref

Commits on Jan 25, 2021

  1. Copy the full SHA
    11c5c70 View commit details
  2. Copy the full SHA
    fa2d19f View commit details
  3. Copy the full SHA
    3187c2b View commit details

Commits on Feb 10, 2021

  1. Copy the full SHA
    aa770af View commit details
  2. Copy the full SHA
    1f080b2 View commit details
  3. Copy the full SHA
    aa9f08a View commit details

Commits on Feb 24, 2021

  1. chore(deps): bump err-code from 2.0.3 to 3.0.1 (#302)

    Bumps [err-code](https://github.com/IndigoUnited/js-err-code) from 2.0.3 to 3.0.1.
    - [Release notes](https://github.com/IndigoUnited/js-err-code/releases)
    - [Commits](https://github.com/IndigoUnited/js-err-code/commits)
    
    Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
    
    Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
    dependabot-preview[bot] authored Feb 24, 2021
    Copy the full SHA
    8ef0358 View commit details
  2. Copy the full SHA
    b8b3fd0 View commit details
  3. Copy the full SHA
    f644b08 View commit details

Commits on Apr 13, 2021

  1. Copy the full SHA
    44f4232 View commit details
  2. Copy the full SHA
    35ea046 View commit details
  3. Copy the full SHA
    53cbde6 View commit details

Commits on Apr 22, 2021

  1. Copy the full SHA
    5b7b142 View commit details
  2. Copy the full SHA
    68b206f View commit details
  3. Copy the full SHA
    c780457 View commit details

Commits on Apr 23, 2021

  1. Copy the full SHA
    4c82721 View commit details
  2. Copy the full SHA
    4ccf5be View commit details
  3. Copy the full SHA
    2eacc5f View commit details

Commits on Apr 26, 2021

  1. Copy the full SHA
    f61c4a1 View commit details

Commits on May 4, 2021

  1. Copy the full SHA
    1076b5b View commit details
  2. Copy the full SHA
    a046a72 View commit details
  3. Copy the full SHA
    4822c40 View commit details

Commits on Jun 16, 2021

  1. chore: update deps and use socket.io server v4 (#362)

    * chore: update ipfs-utils dep
    
    To reduce dupes in the dep tree
    
    * chore: fix tests
    
    * chore: increase timeout globally
    
    * chore: fix up tests
    
    - Updates all deps
    - Runs client tests with socket.io-client 2, 3 and 4
    - Destroys connection when handshake errors, otherwise they are left open
    
    * chore: update test command
    
    * chore: only use v4 server
    
    * chore: linting
    
    * chore: typos
    achingbrain authored Jun 16, 2021
    Copy the full SHA
    441a34e View commit details
  2. Copy the full SHA
    d01cd4a View commit details
  3. Copy the full SHA
    c629cc1 View commit details
32 changes: 24 additions & 8 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -2,29 +2,45 @@

const sigServer = require('./src/sig-server')
let firstRun = true
let sigS
let sigServers = []

async function boot () {
const options = {
const options1 = {
port: 15555,
host: '127.0.0.1',
metrics: firstRun
}

const options2 = {
port: 15556,
host: '127.0.0.1',
metrics: false
}

const options3 = {
port: 15557,
host: '127.0.0.1',
metrics: false
}

if (firstRun) { firstRun = false }

sigS = await sigServer.start(options)
sigServers.push(await sigServer.start(options1))
sigServers.push(await sigServer.start(options2))
sigServers.push(await sigServer.start(options3))

console.log('signalling on:', sigS.info.uri)
console.log('signalling on:')
sigServers.forEach((sig) => console.log(sig.info.uri))
}

async function stop () {
await sigS.stop()
await Promise.all(sigServers.map(s => s.stop()))
}

/** @type {import('aegir').PartialOptions} */
module.exports = {
hooks: {
pre: boot,
post: stop
test: {
before: boot,
after: stop
}
}
49 changes: 49 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: ci
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir lint
- run: npx aegir dep-check -- -i wrtc -i electron-webrtc
- run: npx aegir build --no-types
test-node:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [14, 16]
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm install @mapbox/node-pre-gyp -g
- run: npm install
- run: npm run test:node -- --cov --bail
- uses: codecov/codecov-action@v1
test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npm run test:browser -- --bail
test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npm run test:browser -- --browser firefox --bail
41 changes: 0 additions & 41 deletions .travis.yml

This file was deleted.

42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
## [0.22.4](https://github.com/libp2p/js-libp2p-webrtc-star/compare/v0.22.3...v0.22.4) (2021-06-16)



## [0.22.3](https://github.com/libp2p/js-libp2p-webrtc-star/compare/v0.22.2...v0.22.3) (2021-05-04)



## [0.22.2](https://github.com/libp2p/js-libp2p-webrtc-star/compare/v0.22.1...v0.22.2) (2021-04-23)



## [0.22.1](https://github.com/libp2p/js-libp2p-webrtc-star/compare/v0.22.0...v0.22.1) (2021-04-22)


### Features

* support multiple listeners ([#330](https://github.com/libp2p/js-libp2p-webrtc-star/issues/330)) ([5b7b142](https://github.com/libp2p/js-libp2p-webrtc-star/commit/5b7b14212615cc789836319694cc0b7c16f8dfe4))



# [0.22.0](https://github.com/libp2p/js-libp2p-webrtc-star/compare/v0.21.2...v0.22.0) (2021-04-13)



## [0.21.2](https://github.com/libp2p/js-libp2p-webrtc-star/compare/v0.21.1...v0.21.2) (2021-02-24)



## [0.21.1](https://github.com/libp2p/js-libp2p-webrtc-star/compare/v0.21.0...v0.21.1) (2021-02-10)


### Bug Fixes

* add error event listener to event emitter ([#303](https://github.com/libp2p/js-libp2p-webrtc-star/issues/303)) ([aa770af](https://github.com/libp2p/js-libp2p-webrtc-star/commit/aa770af369cc215b7981befdbb49f7fee1368f77))



# [0.21.0](https://github.com/libp2p/js-libp2p-webrtc-star/compare/v0.20.8...v0.21.0) (2021-01-25)



## [0.20.8](https://github.com/libp2p/js-libp2p-webrtc-star/compare/v0.20.7...v0.20.8) (2021-01-25)


48 changes: 23 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libp2p-webrtc-star",
"version": "0.20.8",
"version": "0.22.4",
"description": "libp2p WebRTC transport that includes a discovery mechanism provided by the signalling-star",
"leadMaintainer": "Vasco Santos <vasco.santos@moxy.studio>",
"main": "src/index.js",
@@ -17,23 +17,19 @@
"star-signal": "node src/sig-server/bin.js",
"lint": "aegir lint",
"build": "aegir build",
"test": "aegir test -t node -t browser",
"test:node": "aegir test -t node",
"test:browser": "aegir test -t browser",
"test:dns": "WEBRTC_STAR_REMOTE_SIGNAL_DNS=1 aegir test -t browser",
"test:ip": "WEBRTC_STAR_REMOTE_SIGNAL_IP=1 aegir test -t browser",
"test": "aegir test -t node -t browser --timeout 20000 -- --exit",
"test:node": "aegir test -t node --timeout 20000 -- --exit",
"test:browser": "aegir test -t browser --timeout 20000 -- --exit",
"test:dns": "WEBRTC_STAR_REMOTE_SIGNAL_DNS=1 aegir test -t browser --timeout 20000 -- --exit",
"test:ip": "WEBRTC_STAR_REMOTE_SIGNAL_IP=1 aegir test -t browser --timeout 20000 -- --exit",
"release": "aegir release -t node -t browser",
"release-minor": "aegir release --type minor -t node -t browser",
"release-major": "aegir release --type major -t node -t browser",
"coverage": "aegir coverage",
"coverage-publish": "aegir coverage --provider coveralls"
},
"pre-push": [
"lint"
],
"engines": {
"node": ">=10.0.0",
"npm": ">=6.0.0"
"node": ">=14.0.0"
},
"repository": {
"type": "git",
@@ -49,14 +45,16 @@
},
"homepage": "https://github.com/libp2p/js-libp2p-webrtc-star#readme",
"devDependencies": {
"aegir": "^30.2.0",
"chai": "^4.2.0",
"dirty-chai": "^2.0.1",
"aegir": "^33.2.0",
"electron-webrtc": "~0.3.0",
"libp2p-interfaces": "^0.8.1",
"libp2p-interfaces": "^0.11.0",
"node-pre-gyp": "^0.17.0",
"p-wait-for": "^3.1.0",
"sinon": "^9.2.0",
"sinon": "^11.1.0",
"socket.io-client-v2": "npm:socket.io-client@^2.3.0",
"socket.io-client-v3": "npm:socket.io-client@^3.1.2",
"uint8arrays": "^2.0.5",
"util": "^0.12.4",
"wrtc": "^0.4.6"
},
"dependencies": {
@@ -65,31 +63,31 @@
"abortable-iterator": "^3.0.0",
"class-is": "^1.1.0",
"debug": "^4.2.0",
"err-code": "^2.0.3",
"ipfs-utils": "^6.0.0",
"err-code": "^3.0.1",
"ipfs-utils": "^8.1.2",
"it-pipe": "^1.1.0",
"libp2p-utils": "^0.2.1",
"libp2p-utils": "^0.3.0",
"libp2p-webrtc-peer": "^10.0.1",
"mafmt": "^8.0.0",
"mafmt": "^9.0.0",
"menoetius": "0.0.2",
"minimist": "^1.2.5",
"multiaddr": "^8.0.0",
"multiaddr": "^9.0.1",
"p-defer": "^3.0.0",
"peer-id": "^0.14.2",
"prom-client": "^13.0.0",
"socket.io": "^2.3.0",
"socket.io-client": "^2.3.0",
"socket.io": "^4.1.2",
"socket.io-client": "^4.1.2",
"stream-to-it": "^0.2.2",
"streaming-iterables": "^5.0.3"
"streaming-iterables": "^6.0.0"
},
"contributors": [
"David Dias <daviddias.p@gmail.com>",
"Vasco Santos <vasco.santos@moxy.studio>",
"Jacob Heun <jacobheun@gmail.com>",
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
"Yahya <ya7yaz@gmail.com>",
"Pedro Teixeira <i@pgte.me>",
"Alex Potsides <alex@achingbrain.net>",
"Pedro Teixeira <i@pgte.me>",
"Maciej Krüger <mkg20001@gmail.com>",
"Dmitriy Ryajov <dryajov@gmail.com>",
"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>",
25 changes: 15 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -12,14 +12,14 @@ const { AbortError } = require('abortable-iterator')
const SimplePeer = require('libp2p-webrtc-peer')
const { supportsWebRTCDataChannels: webrtcSupport } = require('ipfs-utils/src/supports')

const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')
const mafmt = require('mafmt')
const PeerId = require('peer-id')

const { CODE_CIRCUIT } = require('./constants')
const createListener = require('./listener')
const toConnection = require('./socket-to-conn')
const { cleanMultiaddr } = require('./utils')
const { cleanMultiaddr, cleanUrlSIO } = require('./utils')

function noop () { }

@@ -39,8 +39,6 @@ class WebRTCStar {

this._upgrader = options.upgrader

this._signallingAddr = undefined

this.sioOptions = {
transports: ['websocket'],
'force new connection': true
@@ -50,7 +48,8 @@ class WebRTCStar {
this.wrtc = options.wrtc
}

this.listenersRefs = {}
// Keep Signalling references
this.sigReferences = new Map()

// Discovery
this.discovery = new EventEmitter()
@@ -103,12 +102,17 @@ class WebRTCStar {
if (this.wrtc) { spOptions.wrtc = this.wrtc }

const cOpts = ma.toOptions()

const intentId = (~~(Math.random() * 1e9)).toString(36) + Date.now()
const sioClient = this
.listenersRefs[Object.keys(this.listenersRefs)[0]].io

return new Promise((resolve, reject) => {
const sio = this.sigReferences.get(cleanUrlSIO(ma))

if (!sio || !sio.listener) {
return reject(errcode(new Error('unknown signal server to use'), 'ERR_UNKNOWN_SIGNAL_SERVER'))
}

const sioClient = sio.listener.io

const start = Date.now()
let connected

@@ -162,7 +166,7 @@ class WebRTCStar {
channel.on('signal', (signal) => {
sioClient.emit('ss-handshake', {
intentId: intentId,
srcMultiaddr: this._signallingAddr.toString(),
srcMultiaddr: sio.signallingAddr.toString(),
dstMultiaddr: ma.toString(),
signal: signal
})
@@ -172,6 +176,7 @@ class WebRTCStar {
// are clueless as to why.
sioClient.on('ws-handshake', (offer) => {
if (offer.intentId === intentId && offer.err) {
channel.destroy()
reject(errcode(offer.err instanceof Error ? offer.err : new Error(offer.err), 'ERR_SIGNALLING_FAILED'))
}

@@ -232,7 +237,7 @@ class WebRTCStar {
log('Peer Discovered:', maStr)
maStr = cleanMultiaddr(maStr)

const ma = multiaddr(maStr)
const ma = new Multiaddr(maStr)
const peerId = PeerId.createFromB58String(ma.getPeerId())

this.discovery.emit('peer', {
Loading