-
Notifications
You must be signed in to change notification settings - Fork 190
enables firewalling replication on a per-peer basis #364
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
Conversation
index.js
Outdated
| this.replicator.attachTo(mux, session) | ||
|
|
||
| const maybeAttach = (allow) => { | ||
| if (!allow) return mux.destroy() |
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.
@mafintosh I don't think this is correct. Suppose someone passes replicate a Protomux instance, should we really destroy if replication is firewalled? What if they are running other protocols on the mux instance? It would be nice to signal firewalling a bit more responsibly. If we noop, the caller has no indication that replication has been firewalled. We can't throw because the chain of methods is sync and throwing is ugly, no need to panic on getting firewalled. We could emit a firewalled event or error on mux.stream...that's the best I can come up with right now. Some guidance would be appreciated.
|
Updated so a user can set or pass down an |
|
|
||
| mux.stream.noiseStream.opened.then(() => { | ||
| const { remotePublicKey } = mux.stream.noiseStream | ||
| opts.firewall(remotePublicKey, this).then(maybeAttach, mux.destroy.bind(mux)) |
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 we are unable to successfully return a firewall verdict, it feels right to panic on the mux and destroy.
| this.wait = opts.wait !== false | ||
| this.timeout = opts.timeout || 0 | ||
| this.firewall = opts.firewall || null | ||
| this.onfirewalled = opts.onfirewalled || noop |
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.
Should the default implementation be (mux) => mux.destroy()?
This pull request captures the work required to firewall peers on replication, effectively re-implements #291 for v10.
It works by:
This allows for finer-grained firewalling of individual hypercores, it mirrors the hyperdht firewall api.
open questions
open work