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."` Verbose []bool `short:"v" long:"verbose" description:"Show verbose logging."`
Version bool `long:"version" description:"Print version and exit."` Version bool `long:"version" description:"Print version and exit."`
Allowlist string `long:"allowlist" description:"Optional file of public keys who are allowed to connect."` 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."` 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) 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)) err = auth.LoadAllowlist(loaderFromFile(options.Allowlist, logger))
if err != nil { if err != nil {
fail(6, "Failed to load allowlist: %v\n", err) 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") assertLineEq("allowlist is disabled, so nobody will be kicked\r")
sendCmd("/allowlist on") sendCmd("/allowlist on")
sendCmd("/allowlist reverify") sendCmd("/allowlist reverify")
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(" * [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")
kickSignal <- struct{}{} kickSignal <- struct{}{}
sendCmd("/allowlist add " + testKey) sendCmd("/allowlist add " + testKey)
sendCmd("/allowlist status") 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)) assertLineEq(fmt.Sprintf("The following keys of not connected users are on the allowlist: [%s]\r", testKeyFP))
sendCmd("/allowlist invalidSubcommand") sendCmd("/allowlist invalidSubcommand")