Skip to content

fix(rpc): cross-platform support for /unix/ socket maddrs in Addresses.API#10019

Merged
gammazero merged 6 commits into
ipfs:masterfrom
djdv:uds-client
Aug 20, 2024
Merged

fix(rpc): cross-platform support for /unix/ socket maddrs in Addresses.API#10019
gammazero merged 6 commits into
ipfs:masterfrom
djdv:uds-client

Conversation

@djdv

@djdv djdv commented Jul 14, 2023

Copy link
Copy Markdown
Contributor

closes: #10018

This simply removes the need to dial the domain by specifying the dialer in the transport.
And removes any concerns in regards to the socket's path containing characters that are not valid HTTP URLs.
We make requests to a made up domain http://unix which the client is happy to engage with.

There may be a better way to do this but I couldn't figure one out.
I considered trying to avoid calling manet.DialArgs since it will be called twice for non-UDS maddrs (once here and again in NewApiWithClient).
But if we do something like multiaddr.ValueForProtocol(multiaddr.P_UNIX), this will cause issues on platforms like Windows.
This is because multiaddr requires / delimiters (/unix/C:/somewhere), while net.Dial and the OS want C:\somewhere.
ValueForProtocol will return C:/somewhere while manet.DialArgs returns C:\somewhere.
So I just stuck with manet.Dial.

As an aside, I don't really understand why NewApiWithClient is converting from a multiaddr, to a string, then back to a multiaddr. But this is out of scope.

@djdv djdv requested a review from a team as a code owner July 14, 2023 18:29
@lidel lidel requested a review from Jorropo September 25, 2023 13:47
@BigLep BigLep mentioned this pull request Nov 9, 2023
11 tasks
@djdv

djdv commented Mar 12, 2024

Copy link
Copy Markdown
Contributor Author

Some other commit was causing a conflict with the import statements, so I rebased and force pushed. No changes to the actual code in this PR though.

@gammazero gammazero self-assigned this Aug 15, 2024
@gammazero gammazero added the skip/changelog This change does NOT require a changelog entry label Aug 20, 2024
Comment thread test/cli/rpc_unixsocket_test.go Outdated
@lidel lidel changed the title rpc: fix - Unix domain socket maddrs used with NewApi fix(rpc): cross-platform support for /unix/ socket maddrs in Addresses.API Aug 20, 2024
Comment thread docs/changelogs/v0.30.md Outdated
Co-authored-by: djdv <ddvpublic@Gmail.com>
@gammazero gammazero merged commit c5b0428 into ipfs:master Aug 20, 2024
@djdv djdv deleted the uds-client branch September 10, 2024 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip/changelog This change does NOT require a changelog entry

Projects

No open projects
Status: 🥞 Todo

Development

Successfully merging this pull request may close these issues.

rpc: NewAPI constructs faulty HTTP client when using Unix Domain sockets

3 participants