From 71ab39586cf788a98647244a121dc34df0f3c370 Mon Sep 17 00:00:00 2001 From: cvarunreddy Date: Tue, 2 Jul 2024 17:31:07 +0530 Subject: [PATCH 1/2] Proxy changes --- hsdp/plugin.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hsdp/plugin.go b/hsdp/plugin.go index f054ea4..e381244 100644 --- a/hsdp/plugin.go +++ b/hsdp/plugin.go @@ -8,6 +8,7 @@ import ( "fmt" "net/http" _ "net/http/pprof" + "net/url" "os" "runtime/debug" "strings" @@ -84,6 +85,15 @@ func FLBPluginRegister(ctx unsafe.Pointer) int { return output.FLBPluginRegister(ctx, "hsdp", "HSDP logging output plugin") } +func GetProxyUrl(proxyUrl string) func(*http.Request) (*url.URL, error) { + if proxyUrl != "" { + return func(req *http.Request) (*url.URL, error) { + return url.Parse(proxyUrl) + } + } + return http.ProxyFromEnvironment +} + //export FLBPluginInit func FLBPluginInit(ctx unsafe.Pointer) int { region := plugin.Environment(ctx, "Region") @@ -105,6 +115,7 @@ func FLBPluginInit(ctx unsafe.Pointer) int { dropMessages := plugin.Environment(ctx, "Drop") synchronous := plugin.Environment(ctx, "SynchronousFlush") retry := plugin.Environment(ctx, "RetryOnError") + proxyUrl := plugin.Environment(ctx, "Proxy") var err error @@ -130,7 +141,7 @@ func FLBPluginInit(ctx unsafe.Pointer) int { c := &http.Client{ Transport: &http.Transport{ - Proxy: http.ProxyFromEnvironment, + Proxy: GetProxyUrl(proxyUrl), }, } if ignoreTLS { From a68976236792f680d20aa894a5cbda9a085fd43e Mon Sep 17 00:00:00 2001 From: cvarunreddy Date: Tue, 2 Jul 2024 18:05:12 +0530 Subject: [PATCH 2/2] Updated Readme file with proxy changes --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0974937..ed24e75 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ These keys are relevant when using either SigningKey or Service identities | InsecureSkipVerify | Skip checking HSDP ingestor TLS cert. Insecure! | HSDP\_INSECURE\_SKIP\_VERIFY | Optional | | SynchronousFlush | Flushes log messages synchronously without batching. By default this is set to *false* | | Optional | | RetryOnError | Returns retry to FLB if flush fails. Applicable only when *SynchronousFlush* option is set. By default this is set to *false* | | Optional | +| Proxy | HTTP Proxy URL in case there is a proxy redirection required | | Optional | ### Signing keys