feat: add host flag to configure web UI listen address

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Sarto
2026-04-26 16:50:47 +03:30
parent 6b58b2ad0e
commit f40af8fbb1
2 changed files with 15 additions and 5 deletions
+9 -2
View File
@@ -15,6 +15,7 @@ import (
func main() {
dataDir := flag.String("data-dir", "./thefeeddata", "Data directory for config, cache, and sessions")
port := flag.Int("port", 8080, "Web UI port")
host := flag.String("host", "127.0.0.1", "Web UI listen address (host), use 0.0.0.0 to expose to LAN")
password := flag.String("password", "", "Admin password for web UI (empty = no auth)")
showVersion := flag.Bool("version", false, "Show version and exit")
flag.Usage = func() {
@@ -28,13 +29,19 @@ func main() {
os.Exit(0)
}
srv, err := web.New(*dataDir, *port, *password)
srv, err := web.New(*dataDir, *port, *host, *password)
if err != nil {
log.Fatalf("Failed to start: %v", err)
}
// Try to open browser automatically
url := fmt.Sprintf("http://127.0.0.1:%d", *port)
// Open browser on the chosen host (localhost if default)
browserHost := *host
if browserHost == "0.0.0.0" {
browserHost = "127.0.0.1"
}
url := fmt.Sprintf("http://%s:%d", browserHost, *port)
go openBrowser(url)
if err := srv.Run(); err != nil {