Only call AuthLoadFile() once at startup

This commit is contained in:
Jonathon Reinhart
2021-02-15 00:01:02 -05:00
parent 7fa0eebf95
commit 70dfe6b128

12
main.go
View File

@@ -257,6 +257,13 @@ func main() {
log.SetOutput(io.MultiWriter(os.Stdout, f)) log.SetOutput(io.MultiWriter(os.Stdout, f))
} }
// Load allowed users file
if *allowedUsers != "" {
err := AuthLoadFile(*allowedUsers)
if err != nil {
log.Fatalf("Authentication file: %s\n", err)
}
}
// Create a server for each desired listen address // Create a server for each desired listen address
for _, listenAddr := range strings.Split(*listen, " ") { for _, listenAddr := range strings.Split(*listen, " ") {
@@ -270,11 +277,6 @@ func main() {
} }
if *allowedUsers != "" { if *allowedUsers != "" {
err := AuthLoadFile(*allowedUsers)
if err != nil {
log.Fatalf("Authentication file: %s\n", err)
}
server.Authenticator = authChecker server.Authenticator = authChecker
} }