From 0fd4402a44a9f14d575dab82ae6e4a37141482e9 Mon Sep 17 00:00:00 2001 From: Daniel Fenert Date: Wed, 28 Jul 2021 18:42:09 +0200 Subject: [PATCH] Notifications should work without http proxy set Before this change when proxy was not set in config, sending notification resulted in notification error: E0728 16:44:53.027020 1 notifications.go:47] error reporting attack for v1.Deployment to with message send request: http request: Post "": proxyconnect tcp: dial tcp :0: connect: connection refused --- kubemonkey/kubemonkey.go | 4 +++- notifications/client.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kubemonkey/kubemonkey.go b/kubemonkey/kubemonkey.go index 25304d93..ac00a79a 100644 --- a/kubemonkey/kubemonkey.go +++ b/kubemonkey/kubemonkey.go @@ -37,7 +37,9 @@ func Run() error { if config.NotificationsEnabled() { glog.V(1).Infof("Notifications enabled!") proxy := config.NotificationsProxy() - glog.V(1).Infof("Notifications proxy %s!", proxy) + if proxy != "" { + glog.V(1).Infof("Notifications proxy set: %s!", proxy) + } notificationsClient = notifications.CreateClient(&proxy) } diff --git a/notifications/client.go b/notifications/client.go index 0a21c577..a35ee017 100644 --- a/notifications/client.go +++ b/notifications/client.go @@ -25,7 +25,7 @@ func CreateClient(proxy *string) Client { transport := http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } - if proxy != nil { + if proxy != nil && *proxy != "" { proxyUrl, _ := url.Parse(*proxy) transport.Proxy = http.ProxyURL(proxyUrl) }