-
-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accept spec compliant BEP44 mutable get replies with salt #190
Accept spec compliant BEP44 mutable get replies with salt #190
Conversation
@mafintosh I've created a small project which reliably replicates the buggy condition and demonstrates that this patch fixes the situation: https://github.com/chr15m/bittorrent-dht-salt-bug Hope this helps! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it isn't spec compliant to return the salt let's not do it at all. Great work :)
@mafintosh ok cool. Should I update the PR to make it completely spec compliant throughout? |
@chr15m that'd be cool. ping me when you want a review |
9daba5a
to
b9f711c
Compare
@mafintosh updated PR to a) not send The tests pass but note that there is not actually test coverage of this part of the code. |
@mafintosh sorry to bug you I know you must be very busy - did you get a chance to review this PR? Is there anything I can do to help? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems good, it allows the get executor to set the required salt. It removes the salt from the get response.
Great job.
@mafintosh Do you think we should merge this? |
client.js
Outdated
@@ -387,6 +387,8 @@ DHT.prototype.get = function (key, opts, cb) { | |||
|
|||
var isMutable = r.k || r.sig | |||
|
|||
if (opts.salt) r.salt = Buffer(opts.salt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Buffer.from insted of Buffer
@feross LGTM, added a tiny comment about using the new buffer api, but no biggie |
@mafintosh excellent, thank you, will fix the PR(s). |
b9f711c
to
667dca9
Compare
@mafintosh updated PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Released as 8.4.0 |
hmmm... a few libs we have built rely on the behaviour, thats quite a breaking change. |
what we observe now is that data we did store with salts that we try to receive by hash (we just track hashes) is not possible any more and we get empty results |
seems there was a bug: #199 i'm chatting with mathias about it, lets see |
@robertkowalski if you put some The most robust solution is to re-architect your app such that the That said, I don't think it would be a terrible thing for WebTorrent to maintain backwards compatibility with the broken previous version for a while if this was documented. In that instance the documentation should tell users of the library that they are only using a broken subset of the DHT and that mutable get/put will be less reliable, only using a subset of the DHT. The way to maintain backwards compatibility would be:
This change would allow apps like @robertkowalski to continue to function in a limited capacity (using only a subset of the DHT responses) until they upgrade their model, and also allow people who want full use of the DHT to do so by including the The most important thing is that the user is able to continue to manually override the salt value in opts to get better DHT performance from spec compliant nodes. @mafintosh let me know if you want a patch to support this backwards compatability of the previous buggy behaviour. |
@mafintosh this supercedes PR #176 and addresses #167 without the other cruft introduced by that patch set.
Summary
salt
in a mutabledht.get
response.salt
in the response.salt
.Because of this bittorrent-dht treats most correct mutable-
dht.get
responses as invalid as it is expectingsalt
to come back and match, but real-world DHT nodes do not return it.This patch allows the user to specify the expected
salt
as adht.get
option and uses it in validating remote responses even if they do not include thesalt
field. This allows bittorrent-dht to at least accept valid responses from other nodes instead of rejecting them as it does currently.The user will always know the
salt
value that they expect at call time because it is required to compute the correcthash
value anyway.Let me know if you need more information or any changes. Thanks!
Fixes #167.