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

WIP - feat: add TCP and WS filtering with /ipfs fragment #16

Closed
wants to merge 4 commits into from

Conversation

dryajov
Copy link
Member

@dryajov dryajov commented Aug 3, 2017

No description provided.

@coveralls
Copy link

coveralls commented Aug 3, 2017

Coverage Status

Coverage increased (+0.7%) to 91.837% when pulling 94142af on dryajov:feat/ipfs-filter into 0101bd2 on whyrusleeping:master.

@daviddias daviddias mentioned this pull request Aug 3, 2017
53 tasks
@dryajov dryajov mentioned this pull request Aug 16, 2017
48 tasks
src/index.js Outdated
@@ -18,21 +18,45 @@ const TCP = and(IP, base('tcp'))
const UDP = and(IP, base('udp'))
const UTP = and(UDP, base('utp'))

const TCP_IPFS = or(
Copy link
Member

Choose a reason for hiding this comment

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

What is the use case for TCP_IPFS, utility method? This might replicate faster, why not do

mafmt.IPFS(ma) && mafmt.TCP(ma)

Copy link
Member Author

Choose a reason for hiding this comment

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

IPFS(ma) would match WS and WebRTC addrs as well, I believe?

Copy link
Member

Choose a reason for hiding this comment

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

Well, then you do a match for those and negate their values, this is all booleans anyway, you can compose things

Copy link
Member Author

Choose a reason for hiding this comment

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

mafmt.IPFS(ma) would match TCP, WebRTC and WS, even if I do something like

!mafmt.WS(ma) && !mafmt.<some other transport/proto>(ma) && mafmt.IPFS(ma)

mafmt.IPFS(ma) would still match them, since it matches everything that has /ipfs in it. I think a better way would be to allow mafmt.TCP(), mafmt.WS(), etc... to also match /ipfs fragments. The reason I did it in this way is to avoid breaking some other functionality, but I think I'm being overly cautious, don't think anything else would break.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, sounds about right. A TCP multiaddr is still valid if it has a IPFS hash in it.

@dryajov
Copy link
Member Author

dryajov commented Sep 3, 2017

@whyrusleeping @diasdavid I don't seem to have perms to push to this repo anymore... I have some changes sitting locally that resolve the merge conflicts.

@daviddias
Copy link
Member

@dryajov I believe you never had, the PR is coming from your fork
image

@dryajov
Copy link
Member Author

dryajov commented Sep 4, 2017

@diasdavid ugh, you're right 🥗 , somehow I repointed origin locally. Thanks!

@coveralls
Copy link

coveralls commented Sep 4, 2017

Coverage Status

Coverage increased (+0.5%) to 91.837% when pulling 0673ac2 on dryajov:feat/ipfs-filter into 41a8a85 on whyrusleeping:master.

@coveralls
Copy link

coveralls commented Sep 4, 2017

Coverage Status

Coverage increased (+0.5%) to 91.837% when pulling b1e01b9 on dryajov:feat/ipfs-filter into 41a8a85 on whyrusleeping:master.

@dryajov
Copy link
Member Author

dryajov commented Sep 4, 2017

@diasdavid latest changes introduced in #18 don't seem to work with circuit addrs, i.e. /p2p-circuit/ip4/1.2.3.4/tcp/3456/ws/p2p-webrtc-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4. I'm looking into what the issue is, but this is not ready to merge yet.

@dryajov dryajov changed the title feat: add TCP and WS filtering with /ipfs fragment WIP - feat: add TCP and WS filtering with /ipfs fragment Sep 4, 2017
@daviddias
Copy link
Member

@dryajov see: ipfs/js-ipfs#981 and https://github.com/ipfs/pm/pull/492/files#r136710447, you probably need to update your forks with master

@dryajov
Copy link
Member Author

dryajov commented Sep 4, 2017

@diasdavid I pulled (rebase) latest master into it, so it should have all the changes...

@dryajov
Copy link
Member Author

dryajov commented Sep 9, 2017

@diasdavid just want to get some feedback on the latest changes.

I've implemented what we discussed above (#16 (comment)), but this is a breaking change as most addrs would now match the /ipfs fragment. Could you please take a look an let me know? This would require changes to how we detect if an addr has the /ipfs fragment (multiaddr.getPeerId() should work well). So far I've identified libp2p and js-ipfs, but there might be others.

NOTE: WebRTC addrs are still breaking with this change, but I haven't spent time understanding what the issue might be.

Copy link
Member

@daviddias daviddias left a comment

Choose a reason for hiding this comment

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

NOTE: WebRTC addrs are still breaking with this change, but I haven't spent time understanding what the issue might be.

Have you rebased master onto this branch and did an npm fresh install?

const DNS = or(
const _UDP = and(IP, base('udp'))
const UDP = or(
and(_UDP, base('ipfs')),
Copy link
Member

Choose a reason for hiding this comment

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

Without wanting to go back and forth. Is there any reason why a transport code itself wouldn't be able to make two assertions .matchIPFS and .matchUDP so that if the first one happen, it decapsulates IPFS first and then does the matchUDP?

Note, that is how all the transports have been working:

There is a separation between what is a valid addr for a spec transport (i.e TCP was here before) and there is the addrs that our libp2p- accept.

libp2p-tcp accepts TCP multiaddrs or TCP + IPFS, but that assertion should happen on the filter function and not in mafmt, which is a utility to check capabilities/presence of certain addrs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Basically because of this - https://github.com/libp2p/js-libp2p-tcp/pull/80/files, we though at the time that having mafmt handle those special circuit cases such as /ip4/127.0.0.1/tcp/4001/ws/ipfs/QmRelay/p2p-circuit/ipfs/QmDst would be a better approach. I'm not so sure anymore, I think the initial approach of handling the special cases might be simpler and safer.

The two relevant PR that lead to this change are -

Copy link
Member Author

@dryajov dryajov Sep 11, 2017

Choose a reason for hiding this comment

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

Also, I think that since then, we've also scratched listening on circuit addresses and the more advanced circuit-relay features - we might not even need this anymore (for now) because we're not going to be using that kind of addressing right now. I would say we leave it alone and revisit when we actually need this feature.

Glad you asked the question tho!

Copy link
Member Author

Choose a reason for hiding this comment

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

@diasdavid seems like I spoke too soon, we still need this as we are supporting specific relay addrs. We can go with this approach or reopen the PRs linked above (handle circuit as a special case in .filter). I'm not so sure of which one is better. This PR is definitely higher risk as it affects everything that uses mafmt, handling a special case in .filter is uglier, but might be safer for the time being?

Here is @vyzo response regarding Go's handling of specific circuit addrs.

dryajov: it accepts them
10:13 but unless it's an active relay it's pretty much a hint
10:13 if it's an active relay, then it adds the address to its peerstore for the dial attempt
10:13 so it will honor them
10:14 ah,the dialer
10:14 sorry, i was mislieading
10:14 it handles them just fine
10:14 it adds to the peerstore for the dial attempt
10:14 so it's a hint
10:14 may or may not be used by the dialer
10:14 and maybe there is already an existing connection

@dryajov
Copy link
Member Author

dryajov commented Sep 14, 2017

After a conversation with @diasdavid we've decided to handle this in the filter function of each transport.

@dryajov dryajov closed this Sep 14, 2017
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