-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
client: fix "unix" scheme handling for some corner cases #4021
Changes from 1 commit
06c753c
b9b89fd
8fbca88
62ccdd1
e3221bd
69696f9
ecbb2d3
7472fbc
e602bd7
894d568
72a6753
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,9 +60,17 @@ func ParseTarget(target string, skipUnixColonParsing bool) (ret resolver.Target) | |
return resolver.Target{Endpoint: target} | ||
} | ||
if ret.Scheme == "unix" { | ||
// Prevents behavior change in "unix:///[...]" case. | ||
if skipUnixColonParsing && ret.Authority == "" { | ||
return resolver.Target{Endpoint: target} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not be here; instead make the transport invoke the user's dialer after prepending "unix://" to the address string. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed that part and am now appending to the address in transport. |
||
} | ||
// Add the "/" back in the unix case, so the unix resolver receives the | ||
// actual endpoint. | ||
ret.Endpoint = "/" + ret.Endpoint | ||
} | ||
// Prevents behavior change in "passthrough:///unix:///a/b/c" case. | ||
if !skipUnixColonParsing && ret.Scheme == "passthrough" && strings.HasPrefix(ret.Endpoint, "unix:") { | ||
return ParseTarget(ret.Endpoint, false) | ||
} | ||
return ret | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,17 +70,21 @@ func TestParseTargetString(t *testing.T) { | |
// If we can only parse part of the target. | ||
{targetStr: "://", want: resolver.Target{Scheme: "", Authority: "", Endpoint: "://"}}, | ||
{targetStr: "unix://domain", want: resolver.Target{Scheme: "", Authority: "", Endpoint: "unix://domain"}}, | ||
{targetStr: "unix://a/b/c", want: resolver.Target{Scheme: "unix", Authority: "a", Endpoint: "/b/c"}}, | ||
{targetStr: "a:b", want: resolver.Target{Scheme: "", Authority: "", Endpoint: "a:b"}}, | ||
{targetStr: "a/b", want: resolver.Target{Scheme: "", Authority: "", Endpoint: "a/b"}}, | ||
{targetStr: "a:/b", want: resolver.Target{Scheme: "", Authority: "", Endpoint: "a:/b"}}, | ||
{targetStr: "a//b", want: resolver.Target{Scheme: "", Authority: "", Endpoint: "a//b"}}, | ||
{targetStr: "a://b", want: resolver.Target{Scheme: "", Authority: "", Endpoint: "a://b"}}, | ||
|
||
// Unix cases without custom dialer. | ||
// unix:[local_path] and unix:[/absolute] have different behaviors with | ||
// a custom dialer, to prevent behavior changes with custom dialers. | ||
{targetStr: "unix:domain", want: resolver.Target{Scheme: "unix", Authority: "", Endpoint: "domain"}, wantWithDialer: resolver.Target{Scheme: "", Authority: "", Endpoint: "unix:domain"}}, | ||
{targetStr: "unix:/domain", want: resolver.Target{Scheme: "unix", Authority: "", Endpoint: "/domain"}, wantWithDialer: resolver.Target{Scheme: "", Authority: "", Endpoint: "unix:/domain"}}, | ||
// unix:[local_path], unix:[/absolute], and unix://[/absolute] have different | ||
// behaviors with a custom dialer, to prevent behavior changes with custom dialers. | ||
{targetStr: "unix:a/b/c", want: resolver.Target{Scheme: "unix", Authority: "", Endpoint: "a/b/c"}, wantWithDialer: resolver.Target{Scheme: "", Authority: "", Endpoint: "unix:a/b/c"}}, | ||
{targetStr: "unix:/a/b/c", want: resolver.Target{Scheme: "unix", Authority: "", Endpoint: "/a/b/c"}, wantWithDialer: resolver.Target{Scheme: "", Authority: "", Endpoint: "unix:/a/b/c"}}, | ||
{targetStr: "unix:///a/b/c", want: resolver.Target{Scheme: "unix", Authority: "", Endpoint: "/a/b/c"}, wantWithDialer: resolver.Target{Scheme: "", Authority: "", Endpoint: "unix:///a/b/c"}}, | ||
|
||
{targetStr: "passthrough:///unix:///a/b/c", want: resolver.Target{Scheme: "unix", Authority: "", Endpoint: "/a/b/c"}, wantWithDialer: resolver.Target{Scheme: "passthrough", Authority: "", Endpoint: "unix:///a/b/c"}}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should always be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed this, that is what it is in both cases now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like you have omitted There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh.. that makes sense. Thanks. |
||
} { | ||
got := ParseTarget(test.targetStr, false) | ||
if got != test.want { | ||
|
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.
Why does this check
skipUnixColonParsing
? That only impactsunix:<path>
, right?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.
The check is still there just moved (and'd with the =="unix" check). This is so I don't append a "/" to the address when it isn't going to the resolver, since that is only so the resolver gets the right address.