mirror of
https://github.com/CPunch/gopenfusion.git
synced 2025-11-13 19:10:05 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user