From ec7aed8219f8c5cf48756a45ac152cd8c2e0b006 Mon Sep 17 00:00:00 2001 From: "yakumo.izuru" Date: Sun, 24 Mar 2024 23:18:55 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E7=90=86=E6=B8=88=E3=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Izuru Yakumo git-svn-id: file:///srv/svn/repo/yukari/trunk@152 f3bd38d9-da89-464d-a02a-eb04e43141b5 --- CHANGELOG.md | 4 ++++ cmd/yukari/main.go | 24 ++++++++++++++---------- config/config.go | 2 +- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e24aace..0912fbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v0.2.5 - 2024.03.24 +* Rename `config.readConfig` to `config.ReadConfig` +* Assume default values if no `yukari.ini(5)` is loaded + # v0.2.4 - 2024.03.24 * Replace invalid favicon with one sourced from [here](https://en.touhouwiki.net/wiki/File:Th123YukariSigil.png), as well as using `//go:embed` for it * Add rc.d files for FreeBSD and OpenBSD, respectively diff --git a/cmd/yukari/main.go b/cmd/yukari/main.go index b2c6ccf..5b945a0 100644 --- a/cmd/yukari/main.go +++ b/cmd/yukari/main.go @@ -913,16 +913,20 @@ func main() { flag.BoolVar(&version, "version", false, "Show version") flag.Parse() - config.Config.ListenAddress = "127.0.0.1:3000" - config.Config.Key = "" - config.Config.IPV6 = true - config.Config.Debug = false - config.Config.RequestTimeout = 5 - config.Config.FollowRedirect = false - config.Config.UrlParameter = "yukariurl" - config.Config.HashParameter = "yukarihash" - config.Config.MaxConnsPerHost = 5 - config.Config.ProxyEnv = false + if configFile != "" { + config.ReadConfig(configFile) + } else { + config.Config.ListenAddress = "127.0.0.1:3000" + config.Config.Key = "" + config.Config.IPV6 = true + config.Config.Debug = false + config.Config.RequestTimeout = 5 + config.Config.FollowRedirect = false + config.Config.UrlParameter = "yukariurl" + config.Config.HashParameter = "yukarihash" + config.Config.MaxConnsPerHost = 5 + config.Config.ProxyEnv = false + } if version { yukari.FullVersion() diff --git a/config/config.go b/config/config.go index 49b049a..956a819 100644 --- a/config/config.go +++ b/config/config.go @@ -17,7 +17,7 @@ var Config struct { ProxyEnv bool } -func readConfig(file string) error { +func ReadConfig(file string) error { cfg, err := ini.Load(file) if err != nil { return err