Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3 from brave/upgrade_to_0.105.2
Browse files Browse the repository at this point in the history
Upgrade to 0.105.2
  • Loading branch information
yrliou authored Jul 30, 2019
2 parents 6dae42c + 3f70177 commit 423f1fa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ function Server (torrent, opts = {}) {
// deny them
if (req.headers.origin == null) return false

// If a 'hostname' string is specified, deny requests with a 'Host'
// header that does not match the origin of the torrent server to prevent
// DNS rebinding attacks.
if (opts.hostname && req.headers.host !== `${opts.hostname}:${server.address().port}`) {
return false
}

// The user allowed all origins
if (opts.origin === '*') return true

Expand All @@ -77,6 +70,13 @@ function Server (torrent, opts = {}) {
}

function onRequest (req, res) {
// If a 'hostname' string is specified, deny requests with a 'Host'
// header that does not match the origin of the torrent server to prevent
// DNS rebinding attacks.
if (opts.hostname && req.headers.host !== `${opts.hostname}:${server.address().port}`) {
return req.destroy()
}

const pathname = new URL(req.url, 'http://example.com').pathname

if (pathname === '/favicon.ico') {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "webtorrent",
"description": "Streaming torrent client",
"version": "0.105.1",
"version": "0.105.2",
"author": {
"name": "WebTorrent, LLC",
"email": "[email protected]",
Expand Down
6 changes: 3 additions & 3 deletions webtorrent.min.js

Large diffs are not rendered by default.

0 comments on commit 423f1fa

Please sign in to comment.