-
Notifications
You must be signed in to change notification settings - Fork 183
cli: fix --resolve-host to preserve hostname for SNI, S3 signing, and Host header #454
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?
Changes from all commits
437bdaa
934ec35
dfb62fa
226346e
a1137f2
b196621
456af06
8eb6336
73500c2
563c250
8025a12
49c0078
c2c90d1
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 |
|---|---|---|
|
|
@@ -23,6 +23,10 @@ import ( | |
| "github.com/minio/cli" | ||
| ) | ||
|
|
||
| func clientTransportDefault(ctx *cli.Context, localIP string) http.RoundTripper { | ||
| func clientTransportDefault(ctx *cli.Context, localIP, resolvedHost, originalHost string) http.RoundTripper { | ||
| dialer := makeDialer(localIP) | ||
| if resolvedHost != "" { | ||
| return newClientTransport(ctx, withResolveHost(resolvedHost, originalHost, dialer, false)) | ||
| } | ||
|
Comment on lines
+28
to
+30
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. Line 28: Gate resolve-host transport setup on
Suggested fix func clientTransportDefault(ctx *cli.Context, localIP, resolvedHost, originalHost string) http.RoundTripper {
dialer := makeDialer(localIP)
- if resolvedHost != "" {
+ if originalHost != "" && resolvedHost != "" {
return newClientTransport(ctx, withResolveHost(resolvedHost, originalHost, dialer, false))
}
return newClientTransport(ctx, withLocalAddr(localIP))
}🤖 Prompt for AI Agents |
||
| return newClientTransport(ctx, withLocalAddr(localIP)) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -217,7 +217,7 @@ var ioFlags = []cli.Flag{ | |
| }, | ||
| cli.BoolFlag{ | ||
| Name: "resolve-host", | ||
| Usage: "Resolve the host(s) ip(s) (including multiple A/AAAA records). This can break SSL certificates, use --insecure if so", | ||
| Usage: "Resolve the host(s) ip(s) (including multiple A/AAAA records)", | ||
|
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. Sync Line 220 removes the stale SSL warning, but 🤖 Prompt for AI Agents |
||
| Hidden: true, | ||
| }, | ||
| cli.IntFlag{ | ||
|
|
||
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.
Random start offset is not actually randomizing the initial host.
On Line 111,
i + off%len(pairs)adds the same constant shift to all entries, so relative order is unchanged and index 0 still starts earliest.Suggested fix
{ // Start with a random host now := time.Now() off := rand.New(rand.NewSource(time.Now().UnixNano())).Intn(len(pairs)) for i := range lastFinished { - lastFinished[i] = now.Add(time.Duration(i + off%len(pairs))) + lastFinished[(i+off)%len(pairs)] = now.Add(time.Duration(i)) } }📝 Committable suggestion
🤖 Prompt for AI Agents