mirror of
https://github.com/PretendoNetwork/friends.git
synced 2026-09-10 12:26:03 -05:00
feat(config): add checks for Mii decryption key config
This commit is contained in:
17
init.go
17
init.go
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
@@ -71,5 +72,21 @@ func init() {
|
||||
"X-API-Key", globals.Config.AccountGRPCAPIKey,
|
||||
)
|
||||
|
||||
if strings.TrimSpace(globals.Config.MiiDecryptKey) == "" {
|
||||
globals.Logger.Warning("PN_FRIENDS_CONFIG_MII_DECRYPT_KEY environment variable not set. 3DS Mii data cannot be decrypted")
|
||||
}
|
||||
|
||||
miiKeyBytes, err := hex.DecodeString(globals.Config.MiiDecryptKey)
|
||||
if err != nil {
|
||||
globals.Logger.Criticalf("Failed to decode PN_FRIENDS_CONFIG_MII_DECRYPT_KEY %v", err)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
miiMD5Hash := md5.Sum(miiKeyBytes)
|
||||
if hex.EncodeToString(miiMD5Hash[:]) != "aeb707b225ec0fcd8a503e26e3dcd596" {
|
||||
globals.Logger.Criticalf("PN_FRIENDS_CONFIG_MII_DECRYPT_KEY is incorrect! md5: %s", hex.EncodeToString(miiMD5Hash[:]))
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
database.ConnectPostgres()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user