Validate single account domain input (#624)

This commit is contained in:
Maycon Santos 2022-12-13 13:43:29 +01:00 committed by GitHub
parent c0a62b6ddc
commit 6b32e2dc07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -22,9 +22,10 @@ var (
disableSingleAccMode bool
rootCmd = &cobra.Command{
Use: "netbird-mgmt",
Short: "",
Long: "",
Use: "netbird-mgmt",
Short: "",
Long: "",
SilenceUsage: true,
}
// Execution control channel for stopCh signal

View File

@ -449,6 +449,9 @@ func BuildManager(store Store, peersUpdateManager *PeersUpdateManager, idpManage
// enable single account mode only if configured by user and number of existing accounts is not grater than 1
am.singleAccountMode = singleAccountModeDomain != "" && len(allAccounts) <= 1
if am.singleAccountMode {
if !isDomainValid(singleAccountModeDomain) {
return nil, status.Errorf(status.InvalidArgument, "invalid domain \"%s\" provided for single accound mode. Please review your input for --single-account-mode-domain", singleAccountModeDomain)
}
am.singleAccountModeDomain = singleAccountModeDomain
log.Infof("single account mode enabled, accounts number %d", len(allAccounts))
} else {