chore(deps): update webtorrent (#445)

* chore(deps): update webtorrent

* fix: dependencies (#446)

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Cas <6506529+ThaUnknown@users.noreply.github.com>
This commit is contained in:
renovate[bot] 2023-02-01 03:43:44 +01:00 committed by GitHub
parent 138c6e7327
commit b72d226ed8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 12 deletions

View File

@ -159,13 +159,13 @@ class HTTPTracker extends Tracker {
} catch (err) { } catch (err) {
return cb(new Error(`Error decoding tracker response: ${err.message}`)) return cb(new Error(`Error decoding tracker response: ${err.message}`))
} }
const failure = data['failure reason'] const failure = data['failure reason'] && Buffer.from(data['failure reason']).toString()
if (failure) { if (failure) {
debug(`failure from ${requestUrl} (${failure})`) debug(`failure from ${requestUrl} (${failure})`)
return cb(new Error(failure)) return cb(new Error(failure))
} }
const warning = data['warning message'] const warning = data['warning message'] && Buffer.from(data['warning message']).toString()
if (warning) { if (warning) {
debug(`warning from ${requestUrl} (${warning})`) debug(`warning from ${requestUrl} (${warning})`)
self.client.emit('warning', new Error(warning)) self.client.emit('warning', new Error(warning))
@ -194,10 +194,10 @@ class HTTPTracker extends Tracker {
this.client.emit('update', response) this.client.emit('update', response)
let addrs let addrs
if (Buffer.isBuffer(data.peers)) { if (ArrayBuffer.isView(data.peers)) {
// tracker returned compact response // tracker returned compact response
try { try {
addrs = compact2string.multi(data.peers) addrs = compact2string.multi(Buffer.from(data.peers))
} catch (err) { } catch (err) {
return this.client.emit('warning', err) return this.client.emit('warning', err)
} }
@ -211,10 +211,10 @@ class HTTPTracker extends Tracker {
}) })
} }
if (Buffer.isBuffer(data.peers6)) { if (ArrayBuffer.isView(data.peers6)) {
// tracker returned compact response // tracker returned compact response
try { try {
addrs = compact2string.multi6(data.peers6) addrs = compact2string.multi6(Buffer.from(data.peers6))
} catch (err) { } catch (err) {
return this.client.emit('warning', err) return this.client.emit('warning', err)
} }

View File

@ -27,7 +27,7 @@
}, },
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"bencode": "^3.0.0", "bencode": "^3.0.3",
"bittorrent-peerid": "^1.3.3", "bittorrent-peerid": "^1.3.3",
"bn.js": "^5.2.0", "bn.js": "^5.2.0",
"chrome-dgram": "^3.0.6", "chrome-dgram": "^3.0.6",
@ -54,11 +54,11 @@
"devDependencies": { "devDependencies": {
"@mapbox/node-pre-gyp": "1.0.10", "@mapbox/node-pre-gyp": "1.0.10",
"@webtorrent/semantic-release-config": "1.0.8", "@webtorrent/semantic-release-config": "1.0.8",
"magnet-uri": "7.0.1", "magnet-uri": "7.0.2",
"semantic-release": "20.1.0", "semantic-release": "20.1.0",
"standard": "*", "standard": "*",
"tape": "5.6.3", "tape": "5.6.3",
"webtorrent-fixtures": "2.0.0", "webtorrent-fixtures": "2.0.2",
"wrtc": "0.4.7" "wrtc": "0.4.7"
}, },
"engines": { "engines": {

View File

@ -351,7 +351,7 @@ class Server extends EventEmitter {
} }
createSwarm (infoHash, cb) { createSwarm (infoHash, cb) {
if (Buffer.isBuffer(infoHash)) infoHash = infoHash.toString('hex') if (ArrayBuffer.isView(infoHash)) infoHash = infoHash.toString('hex')
process.nextTick(() => { process.nextTick(() => {
const swarm = this.torrents[infoHash] = new Server.Swarm(infoHash, this) const swarm = this.torrents[infoHash] = new Server.Swarm(infoHash, this)
@ -360,7 +360,7 @@ class Server extends EventEmitter {
} }
getSwarm (infoHash, cb) { getSwarm (infoHash, cb) {
if (Buffer.isBuffer(infoHash)) infoHash = infoHash.toString('hex') if (ArrayBuffer.isView(infoHash)) infoHash = infoHash.toString('hex')
process.nextTick(() => { process.nextTick(() => {
cb(null, this.torrents[infoHash]) cb(null, this.torrents[infoHash])

View File

@ -47,7 +47,7 @@ function testRequestHandler (t, serverType) {
client1.once('update', data => { client1.once('update', data => {
t.equal(data.complete, 246) t.equal(data.complete, 246)
t.equal(data.extraData.toString(), 'hi') t.equal(Buffer.from(data.extraData).toString(), 'hi')
client1.destroy(() => { client1.destroy(() => {
t.pass('client1 destroyed') t.pass('client1 destroyed')