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

Implement missing protocols #110

Merged
merged 3 commits into from
Sep 2, 2024
Merged

Conversation

Zollerboy1
Copy link
Contributor

@Zollerboy1 Zollerboy1 commented May 21, 2024

This PR implements all protocols listed in https://github.com/multiformats/multiaddr/blob/master/protocols.csv.

Presumably, this PR closes #97.

@umgefahren
Copy link
Contributor

I would like to see that merged especially since we need ip6zone

@umgefahren
Copy link
Contributor

What's the status on this? @jxs

@jxs
Copy link
Contributor

jxs commented Jul 9, 2024

Hi @umgefahren sorry I missed this notification, and I don't seem to have permissions for this repo, I can ask to, meanwhile @Zollerboy1 sorry for the delay, but can we separate this into two PR's one implementing the missing protocols and the other re-ordering them? As it is it's very hard to review.
Thanks!

@Zollerboy1
Copy link
Contributor Author

Hey @jxs, of course, I can do that. I'm on vacation right now, so I probably cannot work on this until next week though.

@Zollerboy1
Copy link
Contributor Author

Hey @jxs, I finally came around to do this, it should be much easier to review now.

I have the code with the reordered protocols in another branch and would create a new PR when (or if) this one gets merged.

Currently, the CI is failing because the new rust-check-cfg feature in Rust 1.80 complains about the use of #[cfg(nightly)] in the test file. I wasn't sure how exactly you'd want to solve this, but this should probably be changed to #[cfg(feature = "nightly")] or similar.

@umgefahren
Copy link
Contributor

umgefahren commented Aug 2, 2024

Currently, the CI is failing because the new rust-check-cfg feature in Rust 1.80 complains about the use of #[cfg(nightly)] in the test file. I wasn't sure how exactly you'd want to solve this, but this should probably be changed to #[cfg(feature = "nightly")] or similar.

I don't think adding an extra feature that only pertains to a test is a good idea. Using this cfg is actually not that uncommon. I would suggest you add the lint exception:

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(nightly)'] }

It might seem like a dirty fix, but it's a widely used workaround:

It's also one of the suggested solutions by rust itself (and it's more efficient then using a build.rs file).

@umgefahren
Copy link
Contributor

I made a quick PR: #112

@jxs
Copy link
Contributor

jxs commented Aug 14, 2024

Hi @Zollerboy1 can you pull the latest changes so we can make CI pass?
Thanks!

@umgefahren
Copy link
Contributor

Hi @Zollerboy1 can you pull the latest changes so we can make CI pass? Thanks!

It passes now.

Copy link
Contributor

@jxs jxs left a comment

Choose a reason for hiding this comment

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

Hi! And sorry for the delay overal LGTM, just one question

Comment on lines +254 to +255
.replace('-', "+")
.replace('~', "/");
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need replacing these characters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The garlic protocols are very weird in that there is almost no documentation of them anywhere. But apparently, garlic64 doesn't use classic Base64 encoding, but a similar encoding where + is replaced with - and / with ~. I don't know why. But to use multibase::Base::Base64.decode on the string, we have to have a proper Base64 encoding, so I'm just replacing these characters. You can see in the multiaddr implementations in Go (https://github.com/multiformats/go-multiaddr/blob/414c602b9282d609668bd58c90c800468816d9f4/transcoders.go#L270-L271) and Java (https://github.com/multiformats/java-multiaddr/blob/ffdc5320b4ccb5d5e490b6bce72a8da5dbe775ae/src/main/java/io/ipfs/multiaddr/Protocol.java#L231) that they're doing the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for taking the time to explain and provide examples!

Copy link
Contributor

@jxs jxs left a comment

Choose a reason for hiding this comment

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

LGTM Thanks! 🚀

Comment on lines +254 to +255
.replace('-', "+")
.replace('~', "/");
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for taking the time to explain and provide examples!

@jxs jxs merged commit acb4df7 into multiformats:master Sep 2, 2024
4 checks passed
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.

Implement /ipcidr
3 participants