Skip to content
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

Support dht.unannounce (do not merge yet) #184

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

mafintosh
Copy link
Contributor

Experimental support for a BEP I'm writing to support dht.unannounce(infoHash, [port], [cb]).
Makes the client tell other peers that you wish to unannounce a previous announce. Has the same security semantics internally as announce, so should be good there.

Copy link

@samuelmaddock samuelmaddock left a comment

Choose a reason for hiding this comment

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

Looking forward to this getting merged 👍

this.used--
swap(peers.values, peers.values.length - 1, removed.index)
peers.values.pop()
if (!peers.values.length) this.peers.remove(key)

Choose a reason for hiding this comment

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

Code looks similar to _evict below it, is there a chance for reuse?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up writing a new simple module that encapsulates this instead. https://github.com/mafintosh/record-cache. Wanna use this here and get rid of peer store in general

if (!this._validateToken(host, token)) {
return this._rpc.error(peer, query, [203, 'cannot `announce_peer` with bad token'])
}
if (!this._validateToken(host, token)) return null

Choose a reason for hiding this comment

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

Drop null to match code above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It still does the same. Kinda hard to see from the diff. Returning null in here triggers the .error handler in the caller

@resession
Copy link

when will this be added? i can really use this.

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.

3 participants