mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-09-10 04:40:08 -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."`
|
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)
|
||||||
|
@ -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")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user