Set ArgonMaxInstances to number of cores

pull/6/head
maru 2024-05-08 20:08:10 -04:00
parent 7dbcb18ebf
commit 192b777ac3
No known key found for this signature in database
GPG Key ID: 37689350E9CD0F0D
1 changed files with 3 additions and 2 deletions

View File

@ -19,6 +19,7 @@ package account
import ( import (
"regexp" "regexp"
"runtime"
"golang.org/x/crypto/argon2" "golang.org/x/crypto/argon2"
) )
@ -34,13 +35,13 @@ const (
ArgonKeySize = 32 ArgonKeySize = 32
ArgonSaltSize = 16 ArgonSaltSize = 16
ArgonMaxInstances = 16
UUIDSize = 16 UUIDSize = 16
TokenSize = 32 TokenSize = 32
) )
var ( var (
ArgonMaxInstances = runtime.NumCPU()
isValidUsername = regexp.MustCompile(`^\w{1,16}$`).MatchString isValidUsername = regexp.MustCompile(`^\w{1,16}$`).MatchString
semaphore = make(chan bool, ArgonMaxInstances) semaphore = make(chan bool, ArgonMaxInstances)
) )