-
Notifications
You must be signed in to change notification settings - Fork 2
Dial using proxyless in parallel with proxies #1492
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
Conversation
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.
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- go.mod: Language not supported
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Gotta fix one quirk with the outline stuff. |
dialer/proxyless.go
Outdated
configBytes, err := embedFS.ReadFile("smart_dialer_config.yml") | ||
if err != nil { | ||
log.Errorf("Failed to read smart dialer config: %v", err) | ||
return nil, err | ||
} |
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.
We probably want to load this file once instead of reading every dial, so we could move this to newProxylessDialer
and add a attribute for config on proxylessDialer
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.
I guess it would be interesting to have a map of proxyless techniques per country and maybe provide them at the global config, but for now this is good
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.
@myleshorton what do you think about adding the smart dialer config as part of the global config? We could add different techniques later and it wouldn't be hard-coded
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.
I'm afraid that users in the future might stop updating on this version (by any random reason which happens) and the techniques implemented here would be frozen
dialer/proxyless.go
Outdated
var addr string | ||
var host string | ||
var port string | ||
var err error | ||
if host, port, err = net.SplitHostPort(address); err != nil { | ||
addr = fmt.Sprintf("%s:%s", host, "443") | ||
} else if port == "" || port == "443" { | ||
addr = fmt.Sprintf("%s:%s", host, "443") | ||
} else { | ||
return nil, fmt.Errorf("proxyless can only dial 443: %s", addr) | ||
} |
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.
It's not really important but, this can all be simplified to:
host, port, _ := net.SplitHostPort(address)
if port != "" && port != "443" {
return nil, fmt.Errorf("proxyless can only dial 443: %s", addr)
}
addr := host + ":443"
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.
Just a couple of comments, but otherwise LGTM!
dialer/proxyless.go
Outdated
} | ||
|
||
domains := []string{host} | ||
dialer, err := d.strategyFinder.NewDialer(context.Background(), domains, d.configBytes) |
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.
Shouldn't we also use the provided ctx here?
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.
yes!
I'm taking another pass at this to parallelize it...will have it in tomorrow! |
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.
Pull Request Overview
This PR refactors the dialing logic to prioritize direct dialing via proxyless connections while maintaining fallbacks using a parallel dialer approach. Key changes include removing the two-phase dialer implementation, introducing a new smart dialer configuration file, and updating various dialer and client components to integrate the new approach.
Reviewed Changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
dialer/two_phase_dialer.go | Removed obsolete two-phase dialer implementation |
dialer/smart_dialer_config.yml | Added new configuration for smart/proxyless dialing |
dialer/proxyless.go | Introduced proxylessDialer with enhanced error handling and reset |
dialer/parallel_dialer.go | Added a parallel dialer that chooses between proxyless and fallback |
dialer/fastconnect.go | Updated cancellation logging in parallelDial routine |
dialer/dialer.go | Refactored dialer creation to prioritize direct dialing |
dialer/bandit.go | Minor update to error messaging in bandit dialer |
client/client_test.go | Adjusted error message expectations in tests |
client/client.go | Improved cancellation logging for dial contexts |
.github/workflows/go.yml | Updated test workflow to remove deprecated reporter usage |
Files not reviewed (1)
- go.mod: Language not supported
Comments suppressed due to low confidence (1)
dialer/dialer.go:49
- [nitpick] The variable name 'pd' is ambiguous; consider renaming it to 'parallelDialer' to improve clarity.
pd := newParallelPreferProxyless(pdialer, fcd)
with: | ||
go-version-file: "go.mod" | ||
- name: Install go go-ctrf-json-reporter | ||
run: go install github.com/ctrf-io/go-ctrf-json-reporter/cmd/go-ctrf-json-reporter@latest |
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.
They updated this repo/GH action, so this started failing.
Hey @WendelHime and @garmr-ulfr I ended up making a bunch of changes here to try proxyless in parallel to make sure this only improves upon the current situation for users. I ended up giving the proxyless dialers their own context because otherwise the context from the proxied dialer would cancel the proxyless whenever it succeeded first. |
Reviewing now |
I just realized I think I lost track of the state change in there -- i.e. FastConnect has the logic to switch to the Bandit, but Bandit doesn't actually get used I don't think! Will fix! |
client/client_test.go
Outdated
require.NoError(t, err) | ||
resp, err := roundTrip(client, req) | ||
require.Contains(t, err.Error(), "deadline") | ||
require.Contains(t, err.Error(), "any dialers") |
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.
Is error non-nil on success?
dialer/parallel_dialer.go
Outdated
if err != nil { | ||
errCh <- err | ||
} | ||
connCh <- conn |
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.
This should be wrapped in an else
. Currently, it still sends a value (nil
) on error and so the following select statement will sometimes read from connCh
, instead of errCh
, returning nil,nil
.
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.
oooh good catch!!
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.
Pull Request Overview
This PR refactors the dialing logic to always attempt a direct proxyless connection first before falling back to traditional proxied dialing. Key changes include:
- Removal of the two-phase dialer implementation.
- Introduction of a dedicated proxyless dialer and corresponding configuration.
- Updates to fast connect, parallel dialer, and client initialization to support the new proxyless-first approach.
Reviewed Changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
dialer/two_phase_dialer.go | Removed obsolete two-phase dialing logic. |
dialer/smart_dialer_config.yml | Added configuration for smart/proxyless dialing. |
dialer/proxyless_test.go | Added tests for proxyless dialer behavior. |
dialer/proxyless.go | Introduced proxyless dialer implementation with error handling. |
dialer/parallel_dialer.go | Added parallel dialing combining proxyless and default dialers. |
dialer/fastconnect_test.go | Updated tests to match refactored fast connect dialer signature. |
dialer/fastconnect.go | Modified fast connect dialer initialization and dialer switch logic. |
dialer/dialer.go | Updated dialer initialization to use the new proxyless dialer. |
dialer/bandit.go | Adjusted bandit dialer options to align with the new proxyless strategy. |
client/client_test.go | Updated expectations to reflect the revised error message wording. |
client/client.go | Modified client dialer integration and improved context cancellation. |
.github/workflows/go.yml | Simplified the Go workflow by removing extra test report steps. |
Files not reviewed (1)
- go.mod: Language not supported
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.
Copilot reviewed 15 out of 16 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- go.mod: Language not supported
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This first always tries to dial directly using proxyless if we can.