add --whitelist with a warning; update tests for messages

This commit is contained in:
mik2k2 2022-01-04 15:41:02 +01:00
parent dc6fa21eaa
commit 0b7f1c465f
2 changed files with 8 additions and 3 deletions

View File

@ -37,6 +37,7 @@ type Options struct {
Verbose []bool `short:"v" long:"verbose" description:"Show verbose logging."`
Version bool `long:"version" description:"Print version and exit."`
Allowlist string `long:"allowlist" description:"Optional file of public keys who are allowed to connect."`
Whitelist string `long:"whitelist" dexcription:"Old name for allowlist option"`
Passphrase string `long:"unsafe-passphrase" description:"Require an interactive passphrase to connect. Allowlist feature is more secure."`
}
@ -146,6 +147,10 @@ func main() {
fail(5, "Failed to load admins: %v\n", err)
}
if options.Allowlist == "" && options.Whitelist != "" {
fmt.Println("--whitelist was renamed to --allowlist.")
options.Allowlist = options.Whitelist
}
err = auth.LoadAllowlist(loaderFromFile(options.Allowlist, logger))
if err != nil {
fail(6, "Failed to load allowlist: %v\n", err)

View File

@ -340,13 +340,13 @@ func TestHostAllowlistCommand(t *testing.T) {
assertLineEq("allowlist is disabled, so nobody will be kicked\r")
sendCmd("/allowlist on")
sendCmd("/allowlist reverify")
assertLineEq(" * [bar] were kicked during pubkey reverification.\r", " * bar left. (After 0 seconds)\r")
assertLineEq(" * [bar] were kicked during pubkey reverification.\r", " * bar left. (After 0 seconds)\r")
assertLineEq(" * Kicked during pubkey reverification: bar\r", " * bar left. (After 0 seconds)\r")
assertLineEq(" * Kicked during pubkey reverification: bar\r", " * bar left. (After 0 seconds)\r")
kickSignal <- struct{}{}
sendCmd("/allowlist add " + testKey)
sendCmd("/allowlist status")
assertLineEq("The allowlist is currently enabled.\r")
assertLineEq("allowlist enabled\r")
assertLineEq(fmt.Sprintf("The following keys of not connected users are on the allowlist: [%s]\r", testKeyFP))
sendCmd("/allowlist invalidSubcommand")