From 6af3f70cf878b3adaeb63f0fabc61f9e482ca216 Mon Sep 17 00:00:00 2001 From: SayaAndy Date: Tue, 26 Aug 2025 11:13:07 +0700 Subject: refactor: log only num of enlisted pages for catalogue refactor: encode client hash with base64 --- internal/router/client-cache.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'internal/router/client-cache.go') 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] } -- cgit v1.3.1+13