-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
feat(inputs/memcached): Support client TLS origination to memcached #10642
Conversation
Download PR build artifacts for linux_amd64.tar.gz, darwin_amd64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
"github.com/influxdata/telegraf/plugins/inputs" | ||
"golang.org/x/net/proxy" |
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.
One (maybe off-topic) question, could this eliminate the need for https://github.com/influxdata/telegraf/tree/master/plugins/common/proxy?
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.
Thanks for the review. Looks like the common/proxy
package is mostly just a wrapper around x/net/proxy
to generate a SOCKS5 or HTTP Dialer
from a Telegraf TOML config. I haven't touched that part of the codebase before but I imagine it's useful to keep around.
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 reason I'm asking is that I'm a bit hesitant to have both ways in the code-base as it calls for confusion. So ideally you should use common/proxy
or we should remove common/proxy
altogether (if it replicates an upstream package). Do you think that's possible?
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.
Oh, I see. The usage of golang.org/x/net/proxy
in this PR is just to type the dialer
variable against the proxy.Dialer
interface type. There isn't any actual usage of proxy logic.
If you like, I can restructure the logic so that the golang.org/x/net/proxy
import is no longer needed. But there would be more code duplication. Something like
plaintextDialer := ...
var tlsDialer *tls.Dialer
if enable tls {
tlsCfg, err := m.ClientConfig.TLSConfig()
...
tlsDialer = ...
}
...
// following repeated twice, for each of unix socket and TCP address endpoints
if enable tls {
conn, err := tlsDialer.Dial(...)
...
} else {
conn, err := plaintextDialer.Dial(...)
...
}
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.
Looks good to me. Thanks @LINKIWI!
Required for all PRs:
This change adds support for client TLS origination to memcached, leveraging the common TLS plugin library in
plugins/common/tls
. I also addedtoml
struct tags to make the TOML parsing behavior explicit, which seems to be more in line with other plugins as well.Test and verification:
Collection with server TLS enabled, using the memcached test fixture certificates in
t/server_crt.pem
et al.:Collection with server TLS disabled, to verify backwards compatibility: