general cleanup
Some checks failed
Build and publish the docker image / build (push) Failing after 13s
Some checks failed
Build and publish the docker image / build (push) Failing after 13s
Signed-off-by: ngn <ngn@ngn.tf>
This commit is contained in:
24
src/auth.nim
24
src/auth.nim
@ -185,22 +185,22 @@ proc setRateLimit*(account: GuestAccount; api: Api; remaining, reset: int) =
|
||||
|
||||
account.apis[api] = RateLimit(remaining: remaining, reset: reset)
|
||||
|
||||
proc initAccountPool*(cfg: Config; path: string) =
|
||||
proc initAccountPool*(cfg: Config) =
|
||||
let path = cfg.accountsFile
|
||||
enableLogging = cfg.enableDebug
|
||||
|
||||
let jsonlPath = if path.endsWith(".json"): (path & 'l') else: path
|
||||
|
||||
if fileExists(jsonlPath):
|
||||
log "Parsing JSONL guest accounts file: ", jsonlPath
|
||||
for line in jsonlPath.lines:
|
||||
accountPool.add parseGuestAccount(line)
|
||||
elif fileExists(path):
|
||||
log "Parsing JSON guest accounts file: ", path
|
||||
accountPool = parseGuestAccounts(path)
|
||||
else:
|
||||
echo "[accounts] ERROR: ", path, " not found. This file is required to authenticate API requests."
|
||||
if !path.endswith(".jsonl"):
|
||||
log "Accounts file should be formated with JSONL"
|
||||
quit 1
|
||||
|
||||
if !fileExists(path):
|
||||
log "Failed to access the accounts file (", path, ")"
|
||||
quit 1
|
||||
|
||||
log "Parsing JSONL accounts file: ", path
|
||||
for line in path.lines:
|
||||
accountPool.add parseGuestAccount(line)
|
||||
|
||||
let accountsPrePurge = accountPool.len
|
||||
#accountPool.keepItIf(not it.hasExpired)
|
||||
|
||||
|
Reference in New Issue
Block a user