From dbec2d6a052047ef5bef02e800e2b1a1d85df433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Sun, 3 May 2020 11:01:04 +0200 Subject: [PATCH] Allow HTTP listen address configuration --- README.md | 1 + config.toml.sample | 1 + main.go | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a4a64d8..1839f50 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ TargetRoomID = "!jHFKHemgIAaDJekoxN:matrix-staging.ungleich.ch" MXID = "@fnux:matrix-staging.ungleich.ch" MXToken = "secretsecretsecret" HTTPPort = 9088 +HTTPAddress = "" I (master|✚1) ~/W/f/matrix-alertmanager-receiver » ./matrix-alertmanager-receiver -config config.toml 2020/05/03 10:50:47 Reading configuration from config.toml. 2020/05/03 10:50:47 Connecting to Matrix Homserver https://staging.matrix.ungleich.cloud as @fnux:matrix-staging.ungleich.ch. diff --git a/config.toml.sample b/config.toml.sample index c7613ef..85962a3 100644 --- a/config.toml.sample +++ b/config.toml.sample @@ -3,3 +3,4 @@ TargetRoomID = "!jHFKHemgIAaDJekoxN:matrix-staging.ungleich.ch" MXID = "@fnux:matrix-staging.ungleich.ch" MXToken = "secret" HTTPPort = 9088 +HTTPAddress = "" diff --git a/main.go b/main.go index ab64cc6..9e59c0d 100644 --- a/main.go +++ b/main.go @@ -23,7 +23,7 @@ type Configuration struct { MXToken string HTTPPort int - HTTPToken string + HTTPAddress string } func getMatrixMessageFor(alert template.Alert) gomatrix.HTMLMessage { @@ -129,7 +129,7 @@ func main() { handleIncomingHooks(w, r, matrixClient, config.TargetRoomID) }) - var listenAddr = fmt.Sprintf(":%v", config.HTTPPort) + var listenAddr = fmt.Sprintf("%v:%v", config.HTTPAddress, config.HTTPPort) logger.Printf("Listening for HTTP requests (webhooks) on %v", listenAddr) logger.Fatal(http.ListenAndServe(listenAddr, nil)) }