From cfc413f1a928e2f36b80efe914d8c6d7a07deee6 Mon Sep 17 00:00:00 2001 From: handlerug Date: Tue, 6 Jul 2021 02:47:07 +0700 Subject: [PATCH] Add a -listen-addr flag, remove LISTEN_ADDR/PORT --- cfg/config.go | 12 +++--------- flag.go | 1 + 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/cfg/config.go b/cfg/config.go index 2e1c748..affc8eb 100644 --- a/cfg/config.go +++ b/cfg/config.go @@ -137,21 +137,15 @@ func ReadConfigFile(path string) error { // doesn't exist or is empty. f.MapTo(cfg) - if os.Getenv("LISTEN_ADDR") != "" { - cfg.Network.ListenAddr = os.Getenv("LISTEN_ADDR") - } - - if os.Getenv("PORT") != "" { - cfg.Network.ListenAddr = "127.0.0.1:" + os.Getenv("PORT") - } - // Map the struct to the global variables WikiName = cfg.WikiName NaviTitleIcon = cfg.NaviTitleIcon HomeHypha = cfg.HomeHypha UserHypha = cfg.UserHypha HeaderLinksHypha = cfg.HeaderLinksHypha - ListenAddr = cfg.ListenAddr + if ListenAddr == "" { + ListenAddr = cfg.ListenAddr + } URL = cfg.URL UseAuth = cfg.UseAuth AllowRegistration = cfg.AllowRegistration diff --git a/flag.go b/flag.go index 420c0b6..14341d8 100644 --- a/flag.go +++ b/flag.go @@ -36,6 +36,7 @@ type CreateUserCommand struct { func parseCliArgs() { var createAdminName string + flag.StringVar(&cfg.ListenAddr, "listen-addr", "", "Address to listen on. For example, 127.0.0.1:1737 or /run/mycorrhiza.sock.") flag.StringVar(&createAdminName, "create-admin", "", "Create a new admin. The password will be prompted in the terminal.") flag.Usage = printHelp flag.Parse()