Skip to content

Commit

Permalink
chore(deps): update webtorrent (#445)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
renovate[bot] and ThaUnknown committed Feb 1, 2023
1 parent 138c6e7 commit b72d226
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions lib/client/http-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ class HTTPTracker extends Tracker {
} catch (err) {
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) {
debug(`failure from ${requestUrl} (${failure})`)
return cb(new Error(failure))
}

const warning = data['warning message']
const warning = data['warning message'] && Buffer.from(data['warning message']).toString()
if (warning) {
debug(`warning from ${requestUrl} (${warning})`)
self.client.emit('warning', new Error(warning))
Expand Down Expand Up @@ -194,10 +194,10 @@ class HTTPTracker extends Tracker {
this.client.emit('update', response)

let addrs
if (Buffer.isBuffer(data.peers)) {
if (ArrayBuffer.isView(data.peers)) {
// tracker returned compact response
try {
addrs = compact2string.multi(data.peers)
addrs = compact2string.multi(Buffer.from(data.peers))
} catch (err) {
return this.client.emit('warning', err)
}
Expand All @@ -211,10 +211,10 @@ class HTTPTracker extends Tracker {
})
}

if (Buffer.isBuffer(data.peers6)) {
if (ArrayBuffer.isView(data.peers6)) {
// tracker returned compact response
try {
addrs = compact2string.multi6(data.peers6)
addrs = compact2string.multi6(Buffer.from(data.peers6))
} catch (err) {
return this.client.emit('warning', err)
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"type": "module",
"dependencies": {
"bencode": "^3.0.0",
"bencode": "^3.0.3",
"bittorrent-peerid": "^1.3.3",
"bn.js": "^5.2.0",
"chrome-dgram": "^3.0.6",
Expand All @@ -54,11 +54,11 @@
"devDependencies": {
"@mapbox/node-pre-gyp": "1.0.10",
"@webtorrent/semantic-release-config": "1.0.8",
"magnet-uri": "7.0.1",
"magnet-uri": "7.0.2",
"semantic-release": "20.1.0",
"standard": "*",
"tape": "5.6.3",
"webtorrent-fixtures": "2.0.0",
"webtorrent-fixtures": "2.0.2",
"wrtc": "0.4.7"
},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class Server extends EventEmitter {
}

createSwarm (infoHash, cb) {
if (Buffer.isBuffer(infoHash)) infoHash = infoHash.toString('hex')
if (ArrayBuffer.isView(infoHash)) infoHash = infoHash.toString('hex')

process.nextTick(() => {
const swarm = this.torrents[infoHash] = new Server.Swarm(infoHash, this)
Expand All @@ -360,7 +360,7 @@ class Server extends EventEmitter {
}

getSwarm (infoHash, cb) {
if (Buffer.isBuffer(infoHash)) infoHash = infoHash.toString('hex')
if (ArrayBuffer.isView(infoHash)) infoHash = infoHash.toString('hex')

process.nextTick(() => {
cb(null, this.torrents[infoHash])
Expand Down
2 changes: 1 addition & 1 deletion test/request-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function testRequestHandler (t, serverType) {

client1.once('update', data => {
t.equal(data.complete, 246)
t.equal(data.extraData.toString(), 'hi')
t.equal(Buffer.from(data.extraData).toString(), 'hi')

client1.destroy(() => {
t.pass('client1 destroyed')
Expand Down

0 comments on commit b72d226

Please sign in to comment.