diff --git a/client/builders.go b/client/builders.go index 48f6dfea9..5364af687 100644 --- a/client/builders.go +++ b/client/builders.go @@ -112,7 +112,9 @@ func (c *QQClient) buildLoginPacket() (uint16, []byte) { w.WriteUInt32(9) // sub command w.WriteUInt32(0) // 被演了 }) - t.Append(tlv.T544Custom("810_9", salt, wrapper.DandelionEnergy)) + if t544 := tlv.T544Custom(uint64(c.Uin), "810_9", salt, wrapper.DandelionEnergy); t544 != nil { + t.Append(t544) + } } if c.Device().QImei36 != "" { t.Append(tlv.T545([]byte(c.Device().QImei36))) @@ -366,7 +368,9 @@ func (c *QQClient) buildSMSCodeSubmitPacket(code string) (uint16, []byte) { }, } if wrapper.DandelionEnergy != nil { - t.Append(tlv.T544(uint64(c.Uin), "810_7", 7, c.version().SdkVersion, c.Device().Guid, wrapper.DandelionEnergy)) + if t544 := tlv.T544(uint64(c.Uin), "810_7", 7, c.version().SdkVersion, c.Device().Guid, wrapper.DandelionEnergy); t544 != nil { + t.Append(t544) + } } req := c.buildOicqRequestPacket(c.Uin, 0x0810, t) r := network.Request{ @@ -395,7 +399,9 @@ func (c *QQClient) buildTicketSubmitPacket(ticket string) (uint16, []byte) { t.Append(tlv.T(0x547, c.sig.T547)) } if wrapper.DandelionEnergy != nil { - t.Append(tlv.T544(uint64(c.Uin), "810_2", 2, c.version().SdkVersion, c.Device().Guid, wrapper.DandelionEnergy)) + if t544 := tlv.T544(uint64(c.Uin), "810_2", 2, c.version().SdkVersion, c.Device().Guid, wrapper.DandelionEnergy); t544 != nil { + t.Append(t544) + } } req := c.buildOicqRequestPacket(c.Uin, 0x0810, t) r := network.Request{ diff --git a/internal/tlv/t544.go b/internal/tlv/t544.go index f1415a1fa..fd71f6f8b 100644 --- a/internal/tlv/t544.go +++ b/internal/tlv/t544.go @@ -2,22 +2,32 @@ package tlv import "github.com/Mrs4s/MiraiGo/binary" -func T544(userId uint64, moduleId string, subCmd uint32, sdkVersion string, guid []byte, signer func(string, []byte) []byte) []byte { +// temporary solution + +func T544(userId uint64, moduleId string, subCmd uint32, sdkVersion string, guid []byte, signer func(uint64, 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) + }) + sign, err := signer(userId, moduleId, salt) + if err != nil { + return nil + } return binary.NewWriterF(func(w *binary.Writer) { w.WriteUInt16(0x544) - salt := binary.NewWriterF(func(w *binary.Writer) { - w.WriteUInt64(userId) - w.WriteBytesShort(guid) - w.WriteBytesShort([]byte(sdkVersion)) - w.WriteUInt32(subCmd) - }) - w.WriteBytesShort(signer(moduleId, salt)) // temporary solution + w.WriteBytesShort(sign) }) } -func T544Custom(moduleId string, salt []byte, signer func(string, []byte) []byte) []byte { +func T544Custom(userId uint64, moduleId string, salt []byte, signer func(uint64, string, []byte) ([]byte, error)) []byte { + sign, err := signer(userId, moduleId, salt) + if err != nil { + return nil + } return binary.NewWriterF(func(w *binary.Writer) { w.WriteUInt16(0x544) - w.WriteBytesShort(signer(moduleId, salt)) + w.WriteBytesShort(sign) }) } diff --git a/wrapper/codec.go b/wrapper/codec.go index 5f6fc7043..b0b9055f9 100644 --- a/wrapper/codec.go +++ b/wrapper/codec.go @@ -1,3 +1,3 @@ package wrapper -var DandelionEnergy func(string, []byte) []byte +var DandelionEnergy func(uint64, string, []byte) ([]byte, error)