-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
refactor: support percent-encoded /unix paths #10833
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
base: master
Are you sure you want to change the base?
Conversation
This is a PoC that aims to support multiformats/multiaddr#174 while not breaking existing Kubo users. See TODO in daemon.go – likely we want to move this to https://github.com/multiformats/go-multiaddr
// TODO: should a version of this live in https://github.com/multiformats/go-multiaddr | ||
// so we dont need to duplicate code here and in client/rpc/api.go ? | ||
func NormalizeUnixMultiaddr(address string) string { | ||
// Support legacy and modern /unix addrs | ||
// https://github.com/multiformats/multiaddr/pull/174 | ||
socketPath, err := url.PathUnescape(address) | ||
if err != nil { | ||
return address // nil, fmt.Errorf("failed to unescape /unix socket path: %w", err) | ||
} | ||
// Ensure the path is absolute | ||
if !strings.HasPrefix(socketPath, string(filepath.Separator)) { | ||
socketPath = string(filepath.Separator) + socketPath | ||
} | ||
// Normalize path | ||
socketPath = filepath.Clean(socketPath) | ||
return socketPath | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IF It does not live in https://github.com/multiformats/go-multiaddr then multiformats/multiaddr#174 is effectively a dead spec IMO, because nobody will use percent-encoded version.
if err != nil { | ||
return address // nil, fmt.Errorf("failed to unescape /unix socket path: %w", err) | ||
} | ||
// Ensure the path is absolute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
N.b. in the latest version of the spec pr, relative paths are supported
Why
/unix
multiformats/multiaddr#174is breaking spec change that is incompatible with existing feature in Kubo, where users were able to provide old notation of
/unix
multiaddrs in both Addresses.API and Addresses.Gateway.How
This is a PoC that aims to support
multiformats/multiaddr#174 while not breaking existing Kubo users.
TODO