Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hostname parameter for TCP probe #981

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 != "" {
electron0zero marked this conversation as resolved.
Show resolved Hide resolved
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 {
electron0zero marked this conversation as resolved.
Show resolved Hide resolved
// 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