From 0b7f1c465fca9f27f399a34c53497456a271c372 Mon Sep 17 00:00:00 2001 From: mik2k2 <44849223+mik2k2@users.noreply.github.com> Date: Tue, 4 Jan 2022 15:41:02 +0100 Subject: [PATCH] add --whitelist with a warning; update tests for messages --- cmd/ssh-chat/cmd.go | 5 +++++ host_test.go | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/ssh-chat/cmd.go b/cmd/ssh-chat/cmd.go index 4e3343a..96e5a5a 100644 --- a/cmd/ssh-chat/cmd.go +++ b/cmd/ssh-chat/cmd.go @@ -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) diff --git a/host_test.go b/host_test.go index 34641e5..51ff8f4 100644 --- a/host_test.go +++ b/host_test.go @@ -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")