Implemented /profile/{username} endpoint to get complete profile with signed by the current server textures.

Implemented /signing-key endpoint to get public key in der format, used to sign the textures.
Improved logging of errors from http package.
Changed behavior of the /cloaks endpoint
This commit is contained in:
ErickSkrauch
2021-02-26 02:45:45 +01:00
parent 247499df6a
commit 6f148a8791
15 changed files with 1001 additions and 243 deletions

View File

@@ -5,6 +5,7 @@ import (
"time"
"github.com/elyby/chrly/api/mojang"
"github.com/elyby/chrly/utils"
)
type inMemoryItem struct {
@@ -53,7 +54,7 @@ func (s *InMemoryTexturesStorage) StoreTextures(uuid string, textures *mojang.Si
s.data[uuid] = &inMemoryItem{
textures: textures,
timestamp: unixNanoToUnixMicro(time.Now().UnixNano()),
timestamp: utils.UnixMillisecond(time.Now()),
}
}
@@ -89,9 +90,5 @@ func (s *InMemoryTexturesStorage) gc() {
}
func (s *InMemoryTexturesStorage) getMinimalNotExpiredTimestamp() int64 {
return unixNanoToUnixMicro(time.Now().Add(s.Duration * time.Duration(-1)).UnixNano())
}
func unixNanoToUnixMicro(unixNano int64) int64 {
return unixNano / 10e5
return utils.UnixMillisecond(time.Now().Add(s.Duration * time.Duration(-1)))
}