Make listen address configurable

master
Thorben Günther 2021-02-27 18:55:37 +01:00 zatwierdzone przez Thomas Maier
rodzic dd30c9c50f
commit a7b897434e
2 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

@ -17,6 +17,7 @@ Check https://github.com/tmsmr/xmpp-webhook/blob/master/parser/ to learn how to
- `XMPP_RECEIVERS` - Comma-seperated list of JID's
- `XMPP_SKIP_VERIFY` - Skip TLS verification (Optional)
- `XMPP_OVER_TLS` - Use dedicated TLS port (Optional)
- `XMPP_WEBHOOK_LISTEN_ADDRESS` - Bind address (Optional)
- After startup, `xmpp-webhook` tries to connect to the XMPP server and provides the implemented HTTP enpoints (on `:4321`). e.g.:
```

Wyświetl plik

@ -75,6 +75,12 @@ func main() {
_, skipTLSVerify := os.LookupEnv("XMPP_SKIP_VERIFY")
_, useXMPPS := os.LookupEnv("XMPP_OVER_TLS")
// get listen address
listenAddress := os.Getenv("XMPP_WEBHOOK_LISTEN_ADDRESS")
if len(listenAddress) == 0 {
listenAddress = ":4321"
}
// check if xmpp credentials and receiver list are supplied
if xi == "" || xp == "" || xr == "" {
log.Fatal("XMPP_ID, XMPP_PASS or XMPP_RECEIVERS not set")
@ -157,5 +163,5 @@ func main() {
http.Handle("/alertmanager", newMessageHandler(messages, parser.AlertmanagerParserFunc))
// listen for requests
_ = http.ListenAndServe(":4321", nil)
_ = http.ListenAndServe(listenAddress, nil)
}