Allow HTTP listen address configuration

This commit is contained in:
Timothée Floure 2020-05-03 11:01:04 +02:00
parent 4e6971b837
commit dbec2d6a05
3 changed files with 4 additions and 2 deletions

View file

@ -33,6 +33,7 @@ TargetRoomID = "!jHFKHemgIAaDJekoxN:matrix-staging.ungleich.ch"
MXID = "@fnux:matrix-staging.ungleich.ch" MXID = "@fnux:matrix-staging.ungleich.ch"
MXToken = "secretsecretsecret" MXToken = "secretsecretsecret"
HTTPPort = 9088 HTTPPort = 9088
HTTPAddress = ""
I (master|✚1) ~/W/f/matrix-alertmanager-receiver » ./matrix-alertmanager-receiver -config config.toml 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 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. 2020/05/03 10:50:47 Connecting to Matrix Homserver https://staging.matrix.ungleich.cloud as @fnux:matrix-staging.ungleich.ch.

View file

@ -3,3 +3,4 @@ TargetRoomID = "!jHFKHemgIAaDJekoxN:matrix-staging.ungleich.ch"
MXID = "@fnux:matrix-staging.ungleich.ch" MXID = "@fnux:matrix-staging.ungleich.ch"
MXToken = "secret" MXToken = "secret"
HTTPPort = 9088 HTTPPort = 9088
HTTPAddress = ""

View file

@ -23,7 +23,7 @@ type Configuration struct {
MXToken string MXToken string
HTTPPort int HTTPPort int
HTTPToken string HTTPAddress string
} }
func getMatrixMessageFor(alert template.Alert) gomatrix.HTMLMessage { func getMatrixMessageFor(alert template.Alert) gomatrix.HTMLMessage {
@ -129,7 +129,7 @@ func main() {
handleIncomingHooks(w, r, matrixClient, config.TargetRoomID) 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.Printf("Listening for HTTP requests (webhooks) on %v", listenAddr)
logger.Fatal(http.ListenAndServe(listenAddr, nil)) logger.Fatal(http.ListenAndServe(listenAddr, nil))
} }