Skip to content

Commit

Permalink
add hostname parameter for tcp probe
Browse files Browse the repository at this point in the history
  • Loading branch information
lyasspiehler committed Oct 25, 2022
1 parent 0e044cf commit 4b0fc5e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions prober/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 4b0fc5e

Please sign in to comment.