Skip to content

Restore Unix socket support#498

Merged
dragonsinth merged 6 commits intofullstorydev:masterfrom
zhyuri:remove-unix-opt
Mar 18, 2025
Merged

Restore Unix socket support#498
dragonsinth merged 6 commits intofullstorydev:masterfrom
zhyuri:remove-unix-opt

Conversation

@zhyuri
Copy link
Contributor

@zhyuri zhyuri commented Dec 19, 2024

Fixes #496

Context

#480 introduced a behaviour change by replacing custom dialer with the default one from grpc-go, where grpcurl -unix /path/to/proxy no longer works because the address isn't a RFC 3986 compliant URI for unix sockets.
The fix aims to restore the previous behaviour in both grpcurl CLI and package API BlockingDial.

Changes

CLI

  • Prepend unix:// to the address if -unix option is used but the address is not a RFC 3986 compliant URI. This change restored the previous behaviour for -unix.
  • Removed default authority localhost for -unix. This default option was added in 149a93e in order to align the behaviour with popular grpc clients/servers in the customized dialer. Because we now use the grpc-go default dialer, which sets localhost as the default authority for unix networktype, this default option is no longer needed.
  • Always use empty string as network in grpcurl.BlockingDial.

grpcurl package

Depending on the network, the BlockingDial API performs different actions

  • When empty, use address as is. CLI prepends unix:// to the -unix address and always sets network to empty.
  • When tcp, validate the address doesn't have unix:// prefix.
  • When 'unix, prepend unix://` if missing.
  • Otherwise use custom dialer with provided network.

Test

  • grpcurl -unix unix:///path/to/proxy - works
  • grpcurl -unix /path/to/proxy - works, this is the behaviour before feat: 166: Proxy support #480
  • grpcurl unix://path/to/proxy - works
  • grpcurl /path/to/proxy - does not work with expected error missing port in address

@zhyuri zhyuri changed the title Remove unix option from CLI Deprecate unix option from CLI Dec 19, 2024
@zhyuri zhyuri marked this pull request as ready for review December 19, 2024 19:47
@zhyuri zhyuri requested a review from jhump December 20, 2024 01:53
@zhyuri zhyuri changed the title Deprecate unix option from CLI fix: 496: Restore Unix socket support Dec 20, 2024
@zhyuri zhyuri changed the title fix: 496: Restore Unix socket support Restore Unix socket support Dec 20, 2024
Copy link
Contributor

@jhump jhump left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me. I'm not actually a maintainer anymore, so you'll also need a review from the likes of @dragonsinth or @gpassini.

Comment on lines +486 to +492
if isUnixSocket != nil && isUnixSocket() && !strings.HasPrefix(target, "unix://") {
// prepend unix:// to the address if it's not already there
// this is to maintain backwards compatibility because the custom dialer is replaced by
// the default dialer in grpc-go.
// https://github.com/fullstorydev/grpcurl/pull/480
target = "unix://" + target
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You could instead set a network local variable (that defaults to empty string) to "unix" and then pass to BlockingDial below. That way, you aren't duplicating the logic that also lives in BlockingDial for this scenario.

Copy link
Member

@dragonsinth dragonsinth left a comment

Choose a reason for hiding this comment

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

LGTM, sorry I was on sabbatical when this PR was happening.

@dragonsinth dragonsinth merged commit 614b168 into fullstorydev:master Mar 18, 2025
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.

Unix socket support broken in 1.9.2

3 participants