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

feat: custom announce filter #783

Merged
merged 4 commits into from
Nov 10, 2020
Merged

Conversation

vasco-santos
Copy link
Member

@vasco-santos vasco-santos commented Oct 15, 2020

This PR adds a custom announce multiaddrs filter. The default is kept, but users can easily change it to not announce private addresses via config.

This PR also changes the chai requires on all the codebase to leverage aegir

Closes #769

@vasco-santos vasco-santos force-pushed the feat/custom-announce-filter branch from b4cf337 to 86a42a8 Compare October 15, 2020 14:31
@vasco-santos vasco-santos force-pushed the feat/custom-announce-filter branch from 86a42a8 to 6faf350 Compare October 26, 2020 15:30

await keychainWithPassword.createKey(id, 'ed25519')
const { id } = await keychainWithPassword.createKey(name, 'ed25519')
Copy link
Member Author

Choose a reason for hiding this comment

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

This was not failing in the past, but the promise below would return undefined. I think that the reason behind it was not using chai-as-promised. Leveraging the aegir chai that uses if every time was causing this to fail.

@vasco-santos vasco-santos force-pushed the feat/custom-announce-filter branch from 6faf350 to 7c401e9 Compare October 26, 2020 18:30
@vasco-santos vasco-santos force-pushed the feat/custom-announce-filter branch from 7c401e9 to 614c2ea Compare October 26, 2020 19:02
@vasco-santos vasco-santos marked this pull request as ready for review October 26, 2020 19:36
doc/CONFIGURATION.md Outdated Show resolved Hide resolved
src/index.js Outdated
// Filter noAnnounce multiaddrs
const filterMa = this.addressManager.getNoAnnounceAddrs()

// Create advertising list
return this.transportManager.getAddrs()
return announceFilter(this.transportManager.getAddrs()
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at this code I realized the announce behavior is not the same as go. Go doesn't concat the listen and announce addresses. If you provide announce addresses, they are the only addresses that get advertised.

So the behavior should likely be:

  • If announce addresses are provided, only they will be announced (no filters are applied)
  • If announce is not provided, the transport addresses will be filtered
    • If noAnnounce is provided it will be applied as a filter
    • if the announceFilter is provide it will be run

I feel like with announceFilter we should just drop support for noAnnounce. Downstream projects like js-ipfs can use the filter to do achieve the same end, but with more control.

Additionally, something to think about for js-ipfs that we can use the announceFilter for, is that go-ipfs takes noAnnounce from the config and applies those as net masks. It leverages https://github.com/whyrusleeping/multiaddr-filter, so you can more easily filter out ip ranges.

Copy link
Member Author

Choose a reason for hiding this comment

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

yap, I will change this accordingly. I agree on deprecating noAnnounce

Copy link
Member Author

Choose a reason for hiding this comment

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

The multiaddr-filter with the net masks is Interesting. I will create an issue in libp2p-utils for us to discuss it better later on.

@vasco-santos vasco-santos force-pushed the feat/custom-announce-filter branch 2 times, most recently from c69f7d2 to 8cbac36 Compare October 28, 2020 12:50
@vasco-santos vasco-santos mentioned this pull request Oct 28, 2020
2 tasks
@vasco-santos vasco-santos force-pushed the feat/custom-announce-filter branch from 652aaa9 to dc6a53e Compare November 9, 2020 13:24
Copy link
Contributor

@jacobheun jacobheun left a comment

Choose a reason for hiding this comment

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

LGTM, looks like there is an empty file added though test/dialing/utils.js

@vasco-santos vasco-santos force-pushed the feat/custom-announce-filter branch from f897dc2 to 4e1fc90 Compare November 10, 2020 08:16
@vasco-santos vasco-santos merged commit e1ffee1 into 0.30.x Nov 10, 2020
@vasco-santos vasco-santos deleted the feat/custom-announce-filter branch November 10, 2020 08:33
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