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.9.0
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.9.1
Choose a head ref
  • 7 commits
  • 5 files changed
  • 1 contributor

Commits on Apr 30, 2018

  1. server: Improve style of announce/filter logic

    - Filter before potentially creating a swarm that is not needed
    - Unify getSwarm()/createSwarm() into a getOrCreateSwarm() function
    feross authored Apr 30, 2018
    Copy the full SHA
    65c02dd View commit details
  2. standard

    feross authored Apr 30, 2018
    Copy the full SHA
    afcb6df View commit details

Commits on May 1, 2018

  1. authors

    feross committed May 1, 2018
    Copy the full SHA
    338a059 View commit details
  2. Copy the full SHA
    c2177d2 View commit details
  3. npmignore

    feross committed May 1, 2018
    Copy the full SHA
    3968a80 View commit details
  4. Merge pull request #275 from webtorrent/feross-patch-1

    server: Improve style of announce/filter logic
    feross authored May 1, 2018
    Copy the full SHA
    b3400a9 View commit details
  5. 9.9.1

    feross committed May 1, 2018
    Copy the full SHA
    f9d9fa5 View commit details
Showing with 30 additions and 24 deletions.
  1. +3 −2 .npmignore
  2. +2 −1 AUTHORS.md
  3. +2 −2 package.json
  4. +22 −18 server.js
  5. +1 −1 {bin → tools}/update-authors.sh
5 changes: 3 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.travis.yml
CONTRIBUTING.md
test/
img/
examples/
img/
test/
tools/
3 changes: 2 additions & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
@@ -41,5 +41,6 @@
- Brian Clifton (brian@clifton.me)
- James M Snell (jasnell@gmail.com)
- crapthings (crapthings@gmail.com)
- daiyu (qqdaiyu55@gmail.com)

#### Generated by bin/update-authors.sh.
#### Generated by tools/update-authors.sh.
4 changes: 2 additions & 2 deletions 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.9.0",
"version": "9.9.1",
"author": {
"name": "WebTorrent, LLC",
"email": "feross@webtorrent.io",
@@ -71,7 +71,7 @@
"url": "git://github.com/webtorrent/bittorrent-tracker.git"
},
"scripts": {
"update-authors": "./bin/update-authors.sh",
"update-authors": "./tools/update-authors.sh",
"test": "standard && tape test/*.js"
}
}
40 changes: 22 additions & 18 deletions server.js
Original file line number Diff line number Diff line change
@@ -657,31 +657,35 @@ Server.prototype._onRequest = function (params, cb) {
Server.prototype._onAnnounce = function (params, cb) {
var self = this

self.getSwarm(params.info_hash, function (err, swarm) {
if (err) return cb(err)
if (self._filter) {
self._filter(params.info_hash, params, function (err) {
// Presence of `err` means that this announce request is disallowed
if (err) return cb(err)

if (self._filter) {
self._filter(params.info_hash, params, function (err) {
// Precense of err means that this torrent or user is disallowd
if (err) cb(err)
else {
if (swarm) announce(swarm)
else createSwarm()
}
getOrCreateSwarm(function (err, swarm) {
if (err) return cb(err)
announce(swarm)
})
} else {
if (swarm) announce(swarm)
else createSwarm()
}
})

function createSwarm () {
self.createSwarm(params.info_hash, function (err, swarm) {
})
} else {
getOrCreateSwarm(function (err, swarm) {
if (err) return cb(err)
announce(swarm)
})
}

// Get existing swarm, or create one if one does not exist
function getOrCreateSwarm (cb) {
self.getSwarm(params.info_hash, function (err, swarm) {
if (err) return cb(err)
if (swarm) return cb(null, swarm)
self.createSwarm(params.info_hash, function (err, swarm) {
if (err) return cb(err)
cb(null, swarm)
})
})
}

function announce (swarm) {
if (!params.event || params.event === 'empty') params.event = 'update'
swarm.announce(params, function (err, response) {
2 changes: 1 addition & 1 deletion bin/update-authors.sh → tools/update-authors.sh
Original file line number Diff line number Diff line change
@@ -18,6 +18,6 @@ END {
print "# Authors\n\n";
print "#### Ordered by first contribution.\n\n";
print @authors, "\n";
print "#### Generated by bin/update-authors.sh.\n";
print "#### Generated by tools/update-authors.sh.\n";
}
' > AUTHORS.md