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

chore: update deps #329

Merged
merged 3 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, 15]
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: npx aegir test -t 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: npx aegir test -t browser --bail
test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir test -t browser --bail -- --browser firefox
41 changes: 0 additions & 41 deletions .travis.yml

This file was deleted.

19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"lint"
],
"engines": {
"node": ">=10.0.0",
"npm": ">=6.0.0"
"node": ">=14.0.0"
},
"repository": {
"type": "git",
Expand All @@ -49,13 +48,13 @@
},
"homepage": "https://github.com/libp2p/js-libp2p-webrtc-star#readme",
"devDependencies": {
"aegir": "^30.2.0",
"chai": "^4.2.0",
"aegir": "^30.3.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updating to aegir 31+ causes a segmentation fault running the tests. I think this is related to wrtc, but I will create an issue and investigate this separately to avoid blocking the dependencies updates in the bundle

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"chai": "^4.3.4",
"dirty-chai": "^2.0.1",
"electron-webrtc": "~0.3.0",
"libp2p-interfaces": "^0.8.1",
"libp2p-interfaces": "^0.9.0",
"p-wait-for": "^3.1.0",
"sinon": "^9.2.0",
"sinon": "^10.0.1",
"socket.io-client": "^2.3.0",
"uint8arrays": "^2.0.5",
"wrtc": "^0.4.6"
Expand All @@ -69,18 +68,18 @@
"err-code": "^3.0.1",
"ipfs-utils": "^6.0.0",
"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",
vasco-santos marked this conversation as resolved.
Show resolved Hide resolved
"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-next": "npm:socket.io@^3.0.4",
"socket.io-client-next": "npm:socket.io-client@^3.0.4",
"socket.io-next": "npm:socket.io@^3.1.2",
"socket.io-client-next": "npm:socket.io-client@^3.1.2",
"stream-to-it": "^0.2.2",
"streaming-iterables": "^5.0.3"
},
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ 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')

Expand Down Expand Up @@ -232,7 +232,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', {
Expand Down
14 changes: 10 additions & 4 deletions src/listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const debug = require('debug')
const log = debug('libp2p:webrtc-star:listener')
log.error = debug('libp2p:webrtc-star:listener:error')

const multiaddr = require('multiaddr')

const { Multiaddr } = require('multiaddr')
const io = require('socket.io-client-next')
const SimplePeer = require('libp2p-webrtc-peer')
const pDefer = require('p-defer')
Expand Down Expand Up @@ -149,16 +148,23 @@ module.exports = ({ handler, upgrader }, WebRTCStar, options = {}) => {
}

listener.close = async () => {
listener.io && listener.io.emit('ss-leave')
if (listener.io) {
listener.io.emit('ss-leave')
listener.io.close()
}

await Promise.all(listener.__connections.map(maConn => maConn.close()))
listener.emit('close')

listener.removeAllListeners()
}

listener.getAddrs = () => {
return [listeningAddr]
}

WebRTCStar.listenersRefs[multiaddr.toString()] = listener
WebRTCStar.listenersRefs[Multiaddr.toString()] = listener

return listener
}

Expand Down
4 changes: 2 additions & 2 deletions src/sig-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ module.exports = {
log('signaling server has started on: ' + http.info.uri)

const peers = require('./routes-ws')(http, options.metrics).peers
const next = require('./routes-ws/next')(http, options.metrics).peers
const nextPeers = require('./routes-ws/next')(http, options.metrics).peers

http.peers = () => ({
...peers(),
...next()
...nextPeers()
})

http.route({
Expand Down
6 changes: 6 additions & 0 deletions src/sig-server/routes-ws/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module.exports = (http, hasMetrics) => {
const io = new SocketIO(http.listener)
io.on('connection', handle)

http.events.on('stop', () => io.close())

const peers = {}

const peersMetric = hasMetrics ? new client.Gauge({ name: 'webrtc_star_peers', help: 'peers online now' }) : fake.gauge
Expand All @@ -30,6 +32,10 @@ module.exports = (http, hasMetrics) => {

const refreshMetrics = () => peersMetric.set(Object.keys(peers).length)

this.io = () => {
return io
}

this.peers = () => {
return peers
}
Expand Down
6 changes: 6 additions & 0 deletions src/sig-server/routes-ws/next.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ module.exports = (http, hasMetrics) => {
path: '/socket.io-next/' // This should be removed when socket.io@2 support is removed
})

http.events.on('stop', () => io.close())

io.on('connection', handle)

const peers = {}
Expand All @@ -33,6 +35,10 @@ module.exports = (http, hasMetrics) => {

const refreshMetrics = () => peersMetric.set(Object.keys(peers).length)

this.io = () => {
return io
}

this.peers = () => {
return peers
}
Expand Down
10 changes: 5 additions & 5 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')

function cleanUrlSIO (ma) {
const maStrSplit = ma.toString().split('/')
Expand All @@ -12,16 +12,16 @@ function cleanUrlSIO (ma) {
throw new Error('invalid multiaddr: ' + ma.toString())
}

if (!multiaddr.isName(ma)) {
if (!Multiaddr.isName(ma)) {
return 'http://' + maStrSplit[2] + ':' + maStrSplit[4]
}

if (wsProto === 'ws') {
return 'http://' + maStrSplit[2] + (tcpPort === 80 ? '' : ':' + tcpPort)
return 'http://' + maStrSplit[2] + (tcpPort === '80' ? '' : ':' + tcpPort)
}

if (wsProto === 'wss') {
return 'https://' + maStrSplit[2] + (tcpPort === 443 ? '' : ':' + tcpPort)
return 'https://' + maStrSplit[2] + (tcpPort === '443' ? '' : ':' + tcpPort)
}
}

Expand All @@ -30,7 +30,7 @@ function cleanMultiaddr (maStr) {

if (maStr.indexOf(legacy) !== -1) {
maStr = maStr.substring(legacy.length, maStr.length)
let ma = multiaddr(maStr)
let ma = new Multiaddr(maStr)
const tuppleIPFS = ma.stringTuples().filter((tupple) => {
return tupple[0] === 421 // ipfs code
})[0]
Expand Down
8 changes: 4 additions & 4 deletions test/compliance.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const wrtc = require('wrtc')
const sinon = require('sinon')
const testsTransport = require('libp2p-interfaces/src/transport/tests')
const testsDiscovery = require('libp2p-interfaces/src/peer-discovery/tests')
const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')

const WStar = require('../src')

Expand All @@ -21,9 +21,9 @@ describe('interface-transport compliance', function () {
}

const addrs = [
multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooo2a')),
multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooo2b')),
multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooo2c'))
new Multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooo2a')),
new Multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooo2b')),
new Multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSooo2c'))
]

// Used by the dial tests to simulate a delayed connect
Expand Down
13 changes: 8 additions & 5 deletions test/sig-server-next.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const { expect } = require('aegir/utils/chai')
const io = require('socket.io-client-next')
const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')

const sigServer = require('../src/sig-server')

Expand All @@ -25,10 +25,10 @@ describe('signalling', () => {
return `/ip4/127.0.0.1/tcp/9090/ws/p2p-webrtc-star/ipfs/${id}`
}

const c1mh = multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo1'))
const c2mh = multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo2'))
const c3mh = multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo3'))
const c4mh = multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4'))
const c1mh = new Multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo1'))
const c2mh = new Multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo2'))
const c3mh = new Multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo3'))
const c4mh = new Multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4'))

it('start and stop signalling server (default port)', async () => {
const server = await sigServer.start()
Expand Down Expand Up @@ -56,6 +56,9 @@ describe('signalling', () => {

await server.stop()
})
cl.on('disconnect', () => {
cl.close()
})
})

it('start and stop signalling server (custom port)', async () => {
Expand Down
13 changes: 8 additions & 5 deletions test/sig-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const { expect } = require('aegir/utils/chai')
const io = require('socket.io-client')
const multiaddr = require('multiaddr')
const { Multiaddr } = require('multiaddr')

const sigServer = require('../src/sig-server')

Expand All @@ -24,10 +24,10 @@ describe('signalling', () => {
return `/ip4/127.0.0.1/tcp/9090/ws/p2p-webrtc-star/ipfs/${id}`
}

const c1mh = multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo1'))
const c2mh = multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo2'))
const c3mh = multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo3'))
const c4mh = multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4'))
const c1mh = new Multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo1'))
const c2mh = new Multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo2'))
const c3mh = new Multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo3'))
const c4mh = new Multiaddr(base('QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4'))

it('start and stop signalling server (default port)', async () => {
const server = await sigServer.start()
Expand Down Expand Up @@ -55,6 +55,9 @@ describe('signalling', () => {

await server.stop()
})
cl.on('disconnect', () => {
cl.close()
})
})

it('start and stop signalling server (custom port)', async () => {
Expand Down
Loading