Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2018-03-03 01:35:09 +0300
committerGitHub <noreply@github.com>2018-03-03 01:35:09 +0300
commite7d6e4f06d1d4ebb9935d8745607a6d5b8054c16 (patch)
treea7c3dbfabade25657aef43c49304106fb71fcb99 /lib/server.js
parentfb20cfd2f470540e01a0d8a1dbfa0b509a10dc1a (diff)
parent7c107e6d47415d72ca7fd075fc8f78aaae548908 (diff)
Merge pull request #1260 from diracdeltas/fix/add-hostname-opt
Add hostname option to mitigate DNS rebinding
Diffstat (limited to 'lib/server.js')
-rw-r--r--lib/server.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/server.js b/lib/server.js
index 739933f..d2a9a60 100644
--- a/lib/server.js
+++ b/lib/server.js
@@ -51,6 +51,13 @@ 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