forked from Mrs4s/MiraiGo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
t544.go
38 lines (33 loc) · 1.33 KB
/
t544.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package tlv
import "github.com/Sunakier/MiraiGo/binary"
// temporary solution
func T544(userId uint64, moduleId string, subCmd uint32, sdkVersion string, guid []byte, appVersion string, signer func(uint64, string, string, []byte) ([]byte, error)) []byte {
salt := binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt64(userId)
w.WriteBytesShort(guid)
w.WriteBytesShort([]byte(sdkVersion))
w.WriteUInt32(subCmd)
})
return T544Custom(userId, moduleId, appVersion, salt, signer)
}
func T544v2(userId uint64, moduleId string, subCmd uint32, sdkVersion string, guid []byte, appVersion string, signer func(uint64, string, string, []byte) ([]byte, error)) []byte {
salt := binary.NewWriterF(func(w *binary.Writer) {
// w.Write(binary.NewWriterF(func(w *binary.Writer) { w.WriteUInt64(userId) })[:4])
w.WriteUInt32(0)
w.WriteBytesShort(guid)
w.WriteBytesShort([]byte(sdkVersion))
w.WriteUInt32(subCmd)
w.WriteUInt32(0)
})
return T544Custom(userId, moduleId, appVersion, salt, signer)
}
func T544Custom(userId uint64, moduleId string, appVersion string, salt []byte, signer func(uint64, string, string, []byte) ([]byte, error)) []byte {
sign, err := signer(userId, moduleId, appVersion, salt)
if err != nil {
return nil
}
return binary.NewWriterF(func(w *binary.Writer) {
w.WriteUInt16(0x544)
w.WriteBytesShort(sign)
})
}