Skip to content

Conversation

@yciabaud
Copy link
Contributor

This PR makes the scrape function available on websocket server. I chose to add a property named action in the payload to filter requests on server side.

There are a lot of diffs but it is mainly copies from http server and refactoring.

PS: I was able to test it with the WS suite I am willing to integrate (but that's another PR ;) )

var self = this
// NOTE: the unofficial spec says to use the 'files' key, 'host' has been
// seen in practice
data = data.files || data.host || {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just use files since this is the first implementation. We don't need to support hacks for bad tracker servers.

feross added a commit that referenced this pull request Mar 16, 2016
Scrape implementation for websocket. Issue #116
@feross feross merged commit 3d753ab into webtorrent:master Mar 16, 2016
@feross
Copy link
Member

feross commented Mar 16, 2016

I will make the changes that I suggested in inline comments and do a release.

@feross
Copy link
Member

feross commented Mar 16, 2016

Released as 7.5.0.

feross added a commit that referenced this pull request Mar 16, 2016
} else if (data.action === common.ACTIONS.SCRAPE) {
self._onScrapeResponse(data)
} else {
throw new Error('invalid action in WS response: ' + data.action)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed this: Throwing is a bad idea. That means that any tracker that sends back an invalid response will cause an uncaught exception in the client. This should just call self._onSocketError

@yciabaud yciabaud deleted the ws-scrape branch June 7, 2016 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants