server: started ShardServer

- protocol: added GenSerialKey() which securely generates an EnterSerialKey
- login server accepts a shard via LoginServer.AddShard()
- login server will pass LoginMetaData to the selected shard via ShardServer.QueueLogin()
- misc. refactoring
This commit is contained in:
2023-03-17 16:27:47 -05:00
parent 7a26ffdcf7
commit 1357de99aa
11 changed files with 260 additions and 55 deletions

View File

@@ -1,6 +1,7 @@
package protocol
import (
"crypto/rand"
"encoding/binary"
)
@@ -58,3 +59,13 @@ func CreateNewKey(uTime uint64, iv1, iv2 uint64) []byte {
binary.LittleEndian.PutUint64(buf, uint64(key))
return buf
}
func GenSerialKey() (int64, error) {
tmp := [8]byte{}
if _, err := rand.Read(tmp[:]); err != nil {
return 0, err
}
// convert to uint64 && return
return int64(binary.LittleEndian.Uint64(tmp[:])), nil
}