From c810d27375c39a9938ad4bde433dfe5997d56bfa Mon Sep 17 00:00:00 2001 From: Gareth George Date: Tue, 26 Nov 2024 00:26:17 -0800 Subject: [PATCH] fix: tray app infers UI port from BACKREST_PORT or --bind-address if available --- cmd/backrestmon/backrestmon.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/backrestmon/backrestmon.go b/cmd/backrestmon/backrestmon.go index 5eb01757..cc85821e 100644 --- a/cmd/backrestmon/backrestmon.go +++ b/cmd/backrestmon/backrestmon.go @@ -6,6 +6,7 @@ package main import ( "context" "fmt" + "net" "os" "os/exec" "path/filepath" @@ -52,7 +53,15 @@ func main() { mOpenUI.ClickedCh = make(chan struct{}) go func() { for range mOpenUI.ClickedCh { - if err := openBrowser("http://localhost:9898"); err != nil { + bindaddr := env.BindAddress() + if bindaddr == "" { + bindaddr = ":9898" + } + _, port, err := net.SplitHostPort(bindaddr) + if err != nil { + port = "9898" // try the default + } + if err := openBrowser(fmt.Sprintf("http://localhost:%v", port)); err != nil { reportError(err) } }