diff --git a/cmd/converge/converge.go b/cmd/converge/converge.go index f93a228..8a592a4 100644 --- a/cmd/converge/converge.go +++ b/cmd/converge/converge.go @@ -97,7 +97,6 @@ func main() { notifications := NewStateNotifier() admin := converge.NewAdmin(notifications) websessions := converge.NewWebSessions(notifications.webNotificationChannel) - setupPrometheus(notifications.prometheusNotificationChannel) // For agents connecting registrationService := websocketutil.WebSocketService{ @@ -166,6 +165,13 @@ func main() { http.HandleFunc("/", catchAllHandler(contextpath)) + // monitoring + mux := http.NewServeMux() + setupPrometheus(mux, notifications.prometheusNotificationChannel) + go func() { + log.Fatal(http.ListenAndServe(":8001", mux)) + }() + // Start HTTP server fmt.Println("Rendez-vous server listening on :8000") log.Fatal(http.ListenAndServe(":8000", nil)) diff --git a/cmd/converge/prometheus.go b/cmd/converge/prometheus.go index 9e59c61..3aa16b1 100644 --- a/cmd/converge/prometheus.go +++ b/cmd/converge/prometheus.go @@ -86,14 +86,14 @@ func clientActive(client models.Client) { clientInfo.With(clientLabels(client)).Set(1) } -func setupPrometheus(notifications chan *models.State) { +func setupPrometheus(mux *http.ServeMux, notifications chan *models.State) { go func() { for { state := <-notifications updateMetrics(state) } }() - http.Handle("/metrics", promhttp.Handler()) + mux.Handle("/metrics", promhttp.Handler()) } func updateMetrics(state *models.State) { diff --git a/cmd/converge/usage.go b/cmd/converge/usage.go index cae5df1..9b57eb6 100644 --- a/cmd/converge/usage.go +++ b/cmd/converge/usage.go @@ -32,9 +32,10 @@ func generateCLIExammple(w http.ResponseWriter, r *http.Request) { access := getConvergeAccess(r) downloadCommand := r.FormValue("download-command") - + certificateValidation := r.FormValue("certificate-validation") != "" sshPublicKeys := strings.Split(keysString, "\n") - usageInputs := templates.NewUsageInputs(id, sshPublicKeys, remoteShells, localShells, downloadCommand) + usageInputs := templates.NewUsageInputs(id, sshPublicKeys, remoteShells, localShells, downloadCommand, + certificateValidation) matched, _ := regexp.MatchString("^[a-zA-Z0-9-_]+$", id) if !matched { usageInputs.ErrorMessages = append(usageInputs.ErrorMessages, "ID may consist only of alphanumeric characters, '-', and '_'") diff --git a/kubernetes/deployment.yaml b/kubernetes/deployment.yaml index da44e01..e1b2539 100644 --- a/kubernetes/deployment.yaml +++ b/kubernetes/deployment.yaml @@ -4,7 +4,6 @@ metadata: labels: app: converge name: converge - namespace: wamblee-org spec: replicas: 1 selector: @@ -22,5 +21,7 @@ spec: name: converge ports: - containerPort: 8000 - + name: http + - containerPort: 8001 + name: prometheus diff --git a/kubernetes/service.yaml b/kubernetes/service.yaml index c9f09d5..8a5fe8d 100644 --- a/kubernetes/service.yaml +++ b/kubernetes/service.yaml @@ -9,5 +9,8 @@ spec: - port: 8000 protocol: TCP targetPort: 8000 + - port: 8001 + protocol: TCP + targetPort: prometheus selector: app: converge diff --git a/pkg/server/templates/basepage.templ b/pkg/server/templates/basepage.templ index af13fbf..ea5f3d5 100644 --- a/pkg/server/templates/basepage.templ +++ b/pkg/server/templates/basepage.templ @@ -49,7 +49,6 @@ templ BasePage(tab int) { return Intl.DateTimeFormat().resolvedOptions().timeZone; } if (!window.originalWebSocket) { - console.log("timezone override for websockets") window.originalWebSocket = htmx.createWebSocket htmx.createWebSocket = function(url) { url = new URL(url, window.location.href).href @@ -62,7 +61,7 @@ templ BasePage(tab int) { document.body.addEventListener( "htmx:configRequest", function(evt) { - console.log("Adding timezone to htmx request headers and making URL absolute"); + //console.log("Adding timezone to htmx request headers and making URL absolute"); evt.detail.headers["X-Timezone"] = getTimezone(); } ); diff --git a/pkg/server/templates/usage.templ b/pkg/server/templates/usage.templ index ca45631..8958010 100644 --- a/pkg/server/templates/usage.templ +++ b/pkg/server/templates/usage.templ @@ -19,23 +19,23 @@ templ AgentUsage(access models.ConvergeAccess, usageInputs UsageInputs) { if usageInputs.RemoteShells[BASH] { @templ.Raw(addSshKeys(BASH, usageInputs.SshKeys))
- {DOWNLOAD_COMMAND[usageInputs.DownloadCommand]} agent http{access.Secure}://{access.BaseUrl}/downloads/agent
+ {DOWNLOAD_COMMAND[usageInputs.DownloadCommand]} agent {GetDownloadSecureOption(usageInputs)} http{access.Secure}://{access.BaseUrl}/downloads/agent
chmod 755 agent
- ./agent --id {usageInputs.Id} ws{access.Secure}://{access.BaseUrl}
+ ./agent {GetAgentSecureOption(usageInputs)} --id {usageInputs.Id} ws{access.Secure}://{access.BaseUrl}
rm -f agent
} if usageInputs.RemoteShells[CMD] { @templ.Raw(addSshKeys(CMD, usageInputs.SshKeys))
- {DOWNLOAD_COMMAND[usageInputs.DownloadCommand]} agent.exe http{access.Secure}://{access.BaseUrl}/downloads/agent.exe
- .\agent --id {usageInputs.Id} ws{access.Secure}://{access.BaseUrl}
+ {DOWNLOAD_COMMAND[usageInputs.DownloadCommand]} agent.exe {GetDownloadSecureOption(usageInputs)} http{access.Secure}://{access.BaseUrl}/downloads/agent.exe
+ .\agent {GetAgentSecureOption(usageInputs)} --id {usageInputs.Id} ws{access.Secure}://{access.BaseUrl}
del agent.exe
} if usageInputs.RemoteShells[POWERSHELL] { @templ.Raw(addSshKeys(POWERSHELL, usageInputs.SshKeys))
- {DOWNLOAD_COMMAND[usageInputs.DownloadCommand]} agent.exe http{access.Secure}://{access.BaseUrl}/downloads/agent.exe
- .\agent --id {usageInputs.Id} ws{access.Secure}://{access.BaseUrl}
+ {DOWNLOAD_COMMAND[usageInputs.DownloadCommand]} agent.exe {GetDownloadSecureOption(usageInputs)} http{access.Secure}://{access.BaseUrl}/downloads/agent.exe
+ .\agent {GetAgentSecureOption(usageInputs)} --id {usageInputs.Id} ws{access.Secure}://{access.BaseUrl}
del agent.exe
} @@ -190,6 +190,12 @@ templ Usage(access models.ConvergeAccess) { + + + + + +