mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-09-08 03:40:26 -04:00
add --whitelist with a warning; update tests for messages
This commit is contained in:
parent
dc6fa21eaa
commit
0b7f1c465f
@ -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)
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user