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

Define /unix #174

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

Define /unix #174

wants to merge 2 commits into from

Conversation

achingbrain
Copy link
Member

Summary

Adds a protocol note for how to encode paths to Unix domain sockets as strings, that may include the delimiting character of /.

This allows us to append other tuples to the multiaddr while also ensuring we can round-trip the address to a string and back.

This doesn't affect the binary representation of the multiaddr since everything is length-delimited.

Takes inspiration from #164 and proposes using URI encoding for the segment, the same as the /http-path component.

One difference is if the path is to represent the filesystem root, it must be included in the value portion of the tuple, otherwise it can be omitted.

Before Merge

Adds a protocol note for how to encode paths to Unix domain sockets
as strings, that may include the delimiting character of `/`.

This allows us to append other tuples to the multiaddr while also
ensuring we can round-trip the address to a string and back.

This doesn't affect the binary representation of the multiaddr since
everything is length-delimited.

Takes inspiration from #164 and proposes using URI encoding for the
segment, the same as the `/http-path` component.

One difference is if the path is to represent the filesystem root, it
must be included in the value portion of the tuple, otherwise it can
be omitted.
protocols/unix.md Outdated Show resolved Hide resolved
achingbrain added a commit to multiformats/js-multiaddr-matcher that referenced this pull request Nov 4, 2024
Need to resolve how to encode unix paths so peer ids can be appended
to them - multiformats/multiaddr#174
@MarcoPolo
Copy link
Contributor

Are there any backwards compatibility issues? Is anyone using this multiaddr currently?

@aschmahmann
Copy link

Is anyone using this multiaddr currently

I'm not sure how heavily it's utilized, but kubo can use those addresses. e.g. https://github.com/ipfs/kubo/blob/4009ad3e5a502518ddc7d48a888707f812ddc629/docs/config.md?plain=1#L219

@aschmahmann
Copy link

Are there any backwards compatibility issues?

I haven't looked too deeply at usage, but I'd suspect so. The question is what to do about it. There are a bunch of issues that are basically about the failures related to protocols (like http or unix) in taking unescaped paths like #139 #55. They were also known from the earliest days multiformats/go-multiaddr#31.

Maybe the answer is to just break it, or to say that implementations MAY/SHOULD/MUST preferentially try looking for the entire path as a socket and if that fails will try with just the first path segment as a socket.


Not specific to this PR, but between http-path and this perhaps worth biting the bullet on specifying how "path" types should be done in general. Maybe the answer is just to require them all to be escaped, maybe it's something else (e.g. closer to @Stebalien's proposal in multiformats/multiformats#55).

@achingbrain
Copy link
Member Author

There will be backwards compatibility issues with the string representation of the path due to the escaping, though not with the binary representation.

I think this is used but not very commonly. The js stack can also use unix addresses but currently only as a terminal element, that is no tuples can follow it.

Arguably the lack of escaping has harmed it's use - I know I've tried to use it a few times over the years but always come up hard against the inability to append anything else to the address and the various issues asking for clarification etc speak to a need for this.

or to say that implementations MAY/SHOULD/MUST preferentially try looking for the entire path as a socket and if that fails will try with just the first path segment as a socket

I wonder if this could get exploited by making longer paths with segments that mirror tuples after the unix section? Possibly with .. in them that go somewhere bad?

Maybe the answer is to just break it

I kind of think so. The original PR was merged in haste, the question about if we need to append things to it was unresolved.

It was flagged as experimental and subject to change so..

proposal in multiformats/multiformats#55

It's interesting that - it seems to mandate parsing paths left to right, we recently switched multiaddr-to-uri to parsing right to left to support some forms of multiaddr.

It also doesn't seem to say much about escaping so we'd probably still need to solve the same problem there.

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