summaryrefslogtreecommitdiff
path: root/internal/router/client-cache.go
diff options
from:
to:
context:
space:
mode:
authorGravatar SayaAndy <saya.andy@posteo.com> 2025-08-26 11:13:07 +0700
committerGravatar SayaAndy <saya.andy@posteo.com> 2025-08-26 11:13:07 +0700
commit6af3f70cf878b3adaeb63f0fabc61f9e482ca216 (patch)
tree224ca3b4ffc01cd7c1d98b6fb7f4700288b714b5 /internal/router/client-cache.go
parent5ed2499a1d8806fe78369b5b492d7990218131c9 (diff)
downloadweb-6af3f70cf878b3adaeb63f0fabc61f9e482ca216.tar.gz
web-6af3f70cf878b3adaeb63f0fabc61f9e482ca216.zip
refactor: log only num of enlisted pages for catalogue
refactor: encode client hash with base64
Diffstat (limited to 'internal/router/client-cache.go')
-rw-r--r--internal/router/client-cache.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/internal/router/client-cache.go b/internal/router/client-cache.go
index 192d2ed..a4a0cc2 100644
--- a/internal/router/client-cache.go
+++ b/internal/router/client-cache.go
@@ -1,6 +1,7 @@
package router
import (
+ "encoding/base64"
"log/slog"
"sync"
@@ -24,8 +25,9 @@ func NewClientCache(salt []byte) *ClientCache {
}
func (c *ClientCache) GetHash(id string) []byte {
+
if val, ok := c.hashMap[id]; ok {
- slog.Debug("gave an old hash", slog.String("hash", string(val)))
+ slog.Debug("gave an old hash", slog.String("hash", base64.RawStdEncoding.EncodeToString(val)))
return val
}
@@ -36,11 +38,11 @@ func (c *ClientCache) GetHash(id string) []byte {
defer c.mutexMap[id].Unlock()
if val, ok := c.hashMap[id]; ok {
- slog.Debug("gave a newly generated hash", slog.String("hash", string(val)))
+ slog.Debug("gave a newly generated hash", slog.String("hash", base64.RawStdEncoding.EncodeToString(val)))
return val
}
c.hashMap[id] = argon2.IDKey([]byte(id), c.salt, 1, 64*1024, 4, 32)
- slog.Debug("generated hash", slog.String("hash", string(c.hashMap[id])))
+ slog.Debug("generated hash", slog.String("hash", base64.RawStdEncoding.EncodeToString(c.hashMap[id])))
return c.hashMap[id]
}