Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: webtorrent/bittorrent-tracker
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v9.0.1
Choose a base ref
...
head repository: webtorrent/bittorrent-tracker
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v9.0.2
Choose a head ref
  • 4 commits
  • 3 files changed
  • 1 contributor

Commits on Mar 7, 2017

  1. authors

    feross committed Mar 7, 2017
    Copy the full SHA
    1631f61 View commit details
  2. Copy the full SHA
    a09158b View commit details

Commits on Mar 8, 2017

  1. Merge pull request #215 from feross/upgradereq

    Delete `socket.upgradeReq` when it is no longer needed to reduce memory usage
    feross authored Mar 8, 2017
    Copy the full SHA
    0c97366 View commit details
  2. 9.0.2

    feross committed Mar 8, 2017
    Copy the full SHA
    4e75a11 View commit details
Showing with 21 additions and 8 deletions.
  1. +1 −0 AUTHORS.md
  2. +19 −7 lib/server/parse-websocket.js
  3. +1 −1 package.json
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -33,5 +33,6 @@
- Nick Frost (nickfrostatx@gmail.com)
- ZunSThy (zunsthy@gmail.com)
- vijayanand nandam (vijay@cybrilla.com)
- Luigi Pinca (luigipinca@gmail.com)

#### Generated by bin/update-authors.sh.
26 changes: 19 additions & 7 deletions lib/server/parse-websocket.js
Original file line number Diff line number Diff line change
@@ -52,15 +52,27 @@ function parseWebSocketRequest (socket, opts, params) {
throw new Error('invalid action in WS request: ' + params.action)
}

params.ip = opts.trustProxy
? socket.upgradeReq.headers['x-forwarded-for'] || socket.upgradeReq.connection.remoteAddress
: socket.upgradeReq.connection.remoteAddress.replace(common.REMOVE_IPV4_MAPPED_IPV6_RE, '') // force ipv4
params.port = socket.upgradeReq.connection.remotePort
if (params.port) {
params.addr = (common.IPV6_RE.test(params.ip) ? '[' + params.ip + ']' : params.ip) + ':' + params.port
// On first parse, save important data from `socket.upgradeReq` and delete it
// to reduce memory usage.
if (socket.upgradeReq) {
socket.ip = opts.trustProxy
? socket.upgradeReq.headers['x-forwarded-for'] || socket.upgradeReq.connection.remoteAddress
: socket.upgradeReq.connection.remoteAddress.replace(common.REMOVE_IPV4_MAPPED_IPV6_RE, '') // force ipv4
socket.port = socket.upgradeReq.connection.remotePort
if (socket.port) {
socket.addr = (common.IPV6_RE.test(socket.ip) ? '[' + socket.ip + ']' : socket.ip) + ':' + socket.port
}

socket.headers = socket.upgradeReq.headers

// Delete `socket.upgradeReq` when it is no longer needed to reduce memory usage
socket.upgradeReq = null
}

params.headers = socket.upgradeReq.headers
params.ip = socket.ip
params.port = socket.port
params.addr = socket.addr
params.headers = socket.headers

return params
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bittorrent-tracker",
"description": "Simple, robust, BitTorrent tracker (client & server) implementation",
"version": "9.0.1",
"version": "9.0.2",
"author": {
"name": "Feross Aboukhadijeh",
"email": "feross@feross.org",