diff --git a/prober/handler.go b/prober/handler.go index f449cace2..830c8572a 100644 --- a/prober/handler.go +++ b/prober/handler.go @@ -107,6 +107,14 @@ func Handler(w http.ResponseWriter, r *http.Request, c *config.Config, logger lo } } + if module.Prober == "tcp" && hostname != "" { + err = setTLSServerName(hostname, &module) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + } + sl := newScrapeLogger(logger, moduleName, target) level.Info(sl).Log("msg", "Beginning probe", "probe", module.Prober, "timeout_seconds", timeoutSeconds) @@ -137,6 +145,15 @@ func Handler(w http.ResponseWriter, r *http.Request, c *config.Config, logger lo h.ServeHTTP(w, r) } +func setTLSServerName(hostname string, module *config.Module) error { + // By creating a new hashmap and copying values there we + // ensure that the initial configuration remain intact. + if module.TCP.TLSConfig.ServerName == "" { + module.TCP.TLSConfig.ServerName = hostname + } + return nil +} + func setHTTPHost(hostname string, module *config.Module) error { // By creating a new hashmap and copying values there we // ensure that the initial configuration remain intact.