-
Notifications
You must be signed in to change notification settings - Fork 31
config: respect proxy_* settings in agent #251
Conversation
when [proxy settings](https://github.com/DataDog/dd-agent/blob/master/datadog.conf.example#L7-L10) are defined in datadog.conf update the default client in the writer to submit to a proxy. fixes #245
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.
Cool! I think we should add some special chars handling.
config/proxy.go
Outdated
var userpass string | ||
if p.User != "" { | ||
if p.Password != "" { | ||
userpass = fmt.Sprintf("%s:%s@", p.User, p.Password) |
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 think we could URL encode here (cf https://www.cyberciti.biz/faq/unix-linux-export-variable-http_proxy-with-special-characters/ or http://unix.stackexchange.com/questions/42273/export-http-proxy-and-special-characters-in-passwd ). Probably using https://golang.org/pkg/net/url/#UserPassword would do the job.
@@ -0,0 +1,59 @@ | |||
package config |
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 like the idea of having a separate chunk of code / struct to handle this. Indeed, it is not really agent specific.
"proxy_host = https://myhost", | ||
"proxy_port = 3129", | ||
"proxy_user = aaditya", | ||
"proxy_password = password_12", |
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.
You should probably add a test with some special chars such as /:\!?&;=@éÔγλῶσσα
, and test that ProxySettings.URL()
returns the expected value.
Yes good catch on the special chars handling. I've addressed this in 9486db3 |
assert.Nil(err) | ||
|
||
// password is url-encoded and decodes to the original string | ||
assert.Equal("https://aaditya:%2F%3A%21%3F&=%40%C3%A9%C3%94%CE%B3%CE%BB%E1%BF%B6%CF%83%CF%83%CE%B1@myhost:3129", s.String()) |
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.
Github highlights some of this in red, dunno why, but LGTM anyway.
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.
LGTM!
when proxy
settings are defined in datadog.conf
update the default client in the writer to submit to a proxy.
fixes #245