speedtest-go icon indicating copy to clipboard operation
speedtest-go copied to clipboard

Fix initialization of conf for stats

Open balki opened this issue 2 years ago • 1 comments

Problem

Even though I set statistics_password in my config (which is /etc/speedtest-settings.toml), I got the message 'Please set statistics_password in settings.toml to enable access'.

Root cause

In stats.go, global var conf is initialized even before main is called. At this time configFile is empty as it is not set yet. If the config path is not explicitly set using -c flag, viper initializes from settings.toml in current folder. If no settings.toml files is found, conf is initialized with default values and thus does not use the password set in config file.

balki avatar May 10 '23 02:05 balki

Unintentionally pushed a different change to same branch. Let me know if need to recreate PR with just the original change.

balki avatar May 11 '23 01:05 balki