1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 11:07:40 +08:00

client: move device&version into c.transport

This commit is contained in:
wdvxdr 2023-02-16 18:40:56 +08:00
parent cfd7d92d1f
commit ed15fbca26
13 changed files with 159 additions and 160 deletions

View File

@ -49,55 +49,55 @@ func (c *QQClient) buildLoginPacket() (uint16, []byte) {
Command: 9, Command: 9,
List: [][]byte{ List: [][]byte{
tlv.T18(16, uint32(c.Uin)), tlv.T18(16, uint32(c.Uin)),
tlv.T1(uint32(c.Uin), c.device.IpAddress), tlv.T1(uint32(c.Uin), c.Device().IpAddress),
tlv.T106(uint32(c.Uin), 0, c.version.AppId, c.version.SSOVersion, c.PasswordMd5, true, c.device.Guid, c.device.TgtgtKey, 0), tlv.T106(uint32(c.Uin), 0, c.version().AppId, c.version().SSOVersion, c.PasswordMd5, true, c.Device().Guid, c.Device().TgtgtKey, 0),
tlv.T116(c.version.MiscBitmap, c.version.SubSigmap), tlv.T116(c.version().MiscBitmap, c.version().SubSigmap),
tlv.T100(c.version.SSOVersion, c.version.SubAppId, c.version.MainSigMap), tlv.T100(c.version().SSOVersion, c.version().SubAppId, c.version().MainSigMap),
tlv.T107(0), tlv.T107(0),
tlv.T142(c.version.ApkId), tlv.T142(c.version().ApkId),
tlv.T144( tlv.T144(
[]byte(c.device.IMEI), []byte(c.Device().IMEI),
c.device.GenDeviceInfoData(), c.Device().GenDeviceInfoData(),
c.device.OSType, c.Device().OSType,
c.device.Version.Release, c.Device().Version.Release,
c.device.SimInfo, c.Device().SimInfo,
c.device.APN, c.Device().APN,
false, true, false, tlv.GuidFlag(), false, true, false, tlv.GuidFlag(),
c.device.Model, c.Device().Model,
c.device.Guid, c.Device().Guid,
c.device.Brand, c.Device().Brand,
c.device.TgtgtKey, c.Device().TgtgtKey,
), ),
tlv.T145(c.device.Guid), tlv.T145(c.Device().Guid),
tlv.T147(16, []byte(c.version.SortVersionName), c.version.ApkSign), tlv.T147(16, []byte(c.version().SortVersionName), c.version().ApkSign),
/* /*
if (miscBitMap & 0x80) != 0{ if (miscBitMap & 0x80) != 0{
w.Write(tlv.T166(1)) w.Write(tlv.T166(1))
} }
*/ */
tlv.T154(seq), tlv.T154(seq),
tlv.T141(c.device.SimInfo, c.device.APN), tlv.T141(c.Device().SimInfo, c.Device().APN),
tlv.T8(2052), tlv.T8(2052),
tlv.T511([]string{ tlv.T511([]string{
"tenpay.com", "openmobile.qq.com", "docs.qq.com", "connect.qq.com", "tenpay.com", "openmobile.qq.com", "docs.qq.com", "connect.qq.com",
"qzone.qq.com", "vip.qq.com", "gamecenter.qq.com", "qun.qq.com", "game.qq.com", "qzone.qq.com", "vip.qq.com", "gamecenter.qq.com", "qun.qq.com", "game.qq.com",
"qqweb.qq.com", "office.qq.com", "ti.qq.com", "mail.qq.com", "mma.qq.com", "qqweb.qq.com", "office.qq.com", "ti.qq.com", "mail.qq.com", "mma.qq.com",
}), }),
tlv.T187(c.device.MacAddress), tlv.T187(c.Device().MacAddress),
tlv.T188(c.device.AndroidId), tlv.T188(c.Device().AndroidId),
}, },
} }
if len(c.device.IMSIMd5) != 0 { if len(c.Device().IMSIMd5) != 0 {
t.Append(tlv.T194(c.device.IMSIMd5)) t.Append(tlv.T194(c.Device().IMSIMd5))
} }
if c.AllowSlider { if c.AllowSlider {
t.Append(tlv.T191(0x82)) t.Append(tlv.T191(0x82))
} }
if len(c.device.WifiBSSID) != 0 && len(c.device.WifiSSID) != 0 { if len(c.Device().WifiBSSID) != 0 && len(c.Device().WifiSSID) != 0 {
t.Append(tlv.T202(c.device.WifiBSSID, c.device.WifiSSID)) t.Append(tlv.T202(c.Device().WifiBSSID, c.Device().WifiSSID))
} }
t.Append( t.Append(
tlv.T177(c.version.BuildTime, c.version.SdkVersion), tlv.T177(c.version().BuildTime, c.version().SdkVersion),
tlv.T516(), tlv.T516(),
tlv.T521(0), tlv.T521(0),
tlv.T525(tlv.T536([]byte{0x01, 0x00})), tlv.T525(tlv.T536([]byte{0x01, 0x00})),
@ -121,7 +121,7 @@ func (c *QQClient) buildDeviceLockLoginPacket() (uint16, []byte) {
List: [][]byte{ List: [][]byte{
tlv.T8(2052), tlv.T8(2052),
tlv.T104(c.sig.T104), tlv.T104(c.sig.T104),
tlv.T116(c.version.MiscBitmap, c.version.SubSigmap), tlv.T116(c.version().MiscBitmap, c.version().SubSigmap),
tlv.T401(c.sig.G), tlv.T401(c.sig.G),
}, },
}) })
@ -137,8 +137,9 @@ func (c *QQClient) buildDeviceLockLoginPacket() (uint16, []byte) {
} }
func (c *QQClient) buildQRCodeFetchRequestPacket(size, margin, ecLevel uint32) (uint16, []byte) { func (c *QQClient) buildQRCodeFetchRequestPacket(size, margin, ecLevel uint32) (uint16, []byte) {
old := c.version()
watch := auth.AndroidWatch.Version() watch := auth.AndroidWatch.Version()
c.transport.Version = &watch c.transport.Version = watch
seq := c.nextSeq() seq := c.nextSeq()
req := oicq.Message{ req := oicq.Message{
Command: 0x0812, Command: 0x0812,
@ -154,11 +155,11 @@ func (c *QQClient) buildQRCodeFetchRequestPacket(size, margin, ecLevel uint32) (
w.WriteBytesShort(EmptyBytes) w.WriteBytesShort(EmptyBytes)
w.WriteUInt16(6) w.WriteUInt16(6)
w.Write(tlv.T16(watch.SSOVersion, 16, watch.AppId, c.device.Guid, []byte(watch.ApkId), []byte(watch.SortVersionName), watch.ApkSign)) w.Write(tlv.T16(watch.SSOVersion, 16, watch.AppId, c.Device().Guid, []byte(watch.ApkId), []byte(watch.SortVersionName), watch.ApkSign))
w.Write(tlv.T1B(0, 0, size, margin, 72, ecLevel, 2)) w.Write(tlv.T1B(0, 0, size, margin, 72, ecLevel, 2))
w.Write(tlv.T1D(watch.MiscBitmap)) w.Write(tlv.T1D(watch.MiscBitmap))
w.Write(tlv.T1F(false, c.device.OSType, []byte("7.1.2"), []byte("China Mobile GSM"), c.device.APN, 2)) w.Write(tlv.T1F(false, c.Device().OSType, []byte("7.1.2"), []byte("China Mobile GSM"), c.Device().APN, 2))
w.Write(tlv.T33(c.device.Guid)) w.Write(tlv.T33(c.Device().Guid))
w.Write(tlv.T35(8)) w.Write(tlv.T35(8))
})) }))
}), }),
@ -172,13 +173,13 @@ func (c *QQClient) buildQRCodeFetchRequestPacket(size, margin, ecLevel uint32) (
Body: c.oicq.Marshal(&req), Body: c.oicq.Marshal(&req),
} }
payload := c.transport.PackPacket(&r) payload := c.transport.PackPacket(&r)
c.transport.Version = &c.version c.transport.Version = old
return seq, payload return seq, payload
} }
func (c *QQClient) buildQRCodeResultQueryRequestPacket(sig []byte) (uint16, []byte) { func (c *QQClient) buildQRCodeResultQueryRequestPacket(sig []byte) (uint16, []byte) {
watch := auth.AndroidWatch.Version() old := c.version()
c.transport.Version = &watch c.transport.Version = auth.AndroidWatch.Version()
seq := c.nextSeq() seq := c.nextSeq()
req := oicq.Message{ req := oicq.Message{
Command: 0x0812, Command: 0x0812,
@ -208,7 +209,7 @@ func (c *QQClient) buildQRCodeResultQueryRequestPacket(sig []byte) (uint16, []by
Body: c.oicq.Marshal(&req), Body: c.oicq.Marshal(&req),
} }
payload := c.transport.PackPacket(&r) payload := c.transport.PackPacket(&r)
c.transport.Version = &c.version c.transport.Version = old
return seq, payload return seq, payload
} }
@ -218,43 +219,43 @@ func (c *QQClient) buildQRCodeLoginPacket(t106, t16a, t318 []byte) (uint16, []by
Command: 9, Command: 9,
List: [][]byte{ List: [][]byte{
tlv.T18(16, uint32(c.Uin)), tlv.T18(16, uint32(c.Uin)),
tlv.T1(uint32(c.Uin), c.device.IpAddress), tlv.T1(uint32(c.Uin), c.Device().IpAddress),
tlv.T(0x106, t106), tlv.T(0x106, t106),
// tlv.T106(uint32(c.Uin), 0, c.version.AppId, c.version.SSOVersion, c.PasswordMd5, true, c.device.Guid, c.device.TgtgtKey, 0), // tlv.T106(uint32(c.Uin), 0, c.version.AppId, c.version.SSOVersion, c.PasswordMd5, true, c.device.Guid, c.device.TgtgtKey, 0),
tlv.T116(c.version.MiscBitmap, c.version.SubSigmap), tlv.T116(c.version().MiscBitmap, c.version().SubSigmap),
tlv.T100(c.version.SSOVersion, c.version.SubAppId, c.version.MainSigMap), tlv.T100(c.version().SSOVersion, c.version().SubAppId, c.version().MainSigMap),
tlv.T107(0), tlv.T107(0),
tlv.T142(c.version.ApkId), tlv.T142(c.version().ApkId),
tlv.T144( tlv.T144(
[]byte(c.device.IMEI), []byte(c.Device().IMEI),
c.device.GenDeviceInfoData(), c.Device().GenDeviceInfoData(),
c.device.OSType, c.Device().OSType,
c.device.Version.Release, c.Device().Version.Release,
c.device.SimInfo, c.Device().SimInfo,
c.device.APN, c.Device().APN,
false, true, false, tlv.GuidFlag(), false, true, false, tlv.GuidFlag(),
c.device.Model, c.Device().Model,
c.device.Guid, c.Device().Guid,
c.device.Brand, c.Device().Brand,
c.device.TgtgtKey, c.Device().TgtgtKey,
), ),
tlv.T145(c.device.Guid), tlv.T145(c.Device().Guid),
tlv.T147(16, []byte(c.version.SortVersionName), c.version.ApkSign), tlv.T147(16, []byte(c.version().SortVersionName), c.version().ApkSign),
tlv.T(0x16a, t16a), tlv.T(0x16a, t16a),
tlv.T154(seq), tlv.T154(seq),
tlv.T141(c.device.SimInfo, c.device.APN), tlv.T141(c.Device().SimInfo, c.Device().APN),
tlv.T8(2052), tlv.T8(2052),
tlv.T511([]string{ tlv.T511([]string{
"tenpay.com", "openmobile.qq.com", "docs.qq.com", "connect.qq.com", "tenpay.com", "openmobile.qq.com", "docs.qq.com", "connect.qq.com",
"qzone.qq.com", "vip.qq.com", "gamecenter.qq.com", "qun.qq.com", "game.qq.com", "qzone.qq.com", "vip.qq.com", "gamecenter.qq.com", "qun.qq.com", "game.qq.com",
"qqweb.qq.com", "office.qq.com", "ti.qq.com", "mail.qq.com", "mma.qq.com", "qqweb.qq.com", "office.qq.com", "ti.qq.com", "mail.qq.com", "mma.qq.com",
}), }),
tlv.T187(c.device.MacAddress), tlv.T187(c.Device().MacAddress),
tlv.T188(c.device.AndroidId), tlv.T188(c.Device().AndroidId),
tlv.T194(c.device.IMSIMd5), tlv.T194(c.Device().IMSIMd5),
tlv.T191(0x00), tlv.T191(0x00),
tlv.T202(c.device.WifiBSSID, c.device.WifiSSID), tlv.T202(c.Device().WifiBSSID, c.Device().WifiSSID),
tlv.T177(c.version.BuildTime, c.version.SdkVersion), tlv.T177(c.version().BuildTime, c.version().SdkVersion),
tlv.T516(), tlv.T516(),
tlv.T521(8), tlv.T521(8),
// tlv.T525(tlv.T536([]byte{0x01, 0x00})), // tlv.T525(tlv.T536([]byte{0x01, 0x00})),
@ -281,7 +282,7 @@ func (c *QQClient) buildCaptchaPacket(result string, sign []byte) (uint16, []byt
tlv.T2(result, sign), tlv.T2(result, sign),
tlv.T8(2052), tlv.T8(2052),
tlv.T104(c.sig.T104), tlv.T104(c.sig.T104),
tlv.T116(c.version.MiscBitmap, c.version.SubSigmap), tlv.T116(c.version().MiscBitmap, c.version().SubSigmap),
}, },
} }
if c.sig.T547 != nil { if c.sig.T547 != nil {
@ -306,7 +307,7 @@ func (c *QQClient) buildSMSRequestPacket() (uint16, []byte) {
List: [][]byte{ List: [][]byte{
tlv.T8(2052), tlv.T8(2052),
tlv.T104(c.sig.T104), tlv.T104(c.sig.T104),
tlv.T116(c.version.MiscBitmap, c.version.SubSigmap), tlv.T116(c.version().MiscBitmap, c.version().SubSigmap),
tlv.T174(c.sig.T174), tlv.T174(c.sig.T174),
tlv.T17A(9), tlv.T17A(9),
tlv.T197(), tlv.T197(),
@ -330,7 +331,7 @@ func (c *QQClient) buildSMSCodeSubmitPacket(code string) (uint16, []byte) {
List: [][]byte{ List: [][]byte{
tlv.T8(2052), tlv.T8(2052),
tlv.T104(c.sig.T104), tlv.T104(c.sig.T104),
tlv.T116(c.version.MiscBitmap, c.version.SubSigmap), tlv.T116(c.version().MiscBitmap, c.version().SubSigmap),
tlv.T174(c.sig.T174), tlv.T174(c.sig.T174),
tlv.T17C(code), tlv.T17C(code),
tlv.T401(c.sig.G), tlv.T401(c.sig.G),
@ -356,7 +357,7 @@ func (c *QQClient) buildTicketSubmitPacket(ticket string) (uint16, []byte) {
tlv.T193(ticket), tlv.T193(ticket),
tlv.T8(2052), tlv.T8(2052),
tlv.T104(c.sig.T104), tlv.T104(c.sig.T104),
tlv.T116(c.version.MiscBitmap, c.version.SubSigmap), tlv.T116(c.version().MiscBitmap, c.version().SubSigmap),
}, },
} }
if c.sig.T547 != nil { if c.sig.T547 != nil {
@ -380,47 +381,47 @@ func (c *QQClient) buildRequestTgtgtNopicsigPacket() (uint16, []byte) {
Command: 15, Command: 15,
List: [][]byte{ List: [][]byte{
tlv.T18(16, uint32(c.Uin)), tlv.T18(16, uint32(c.Uin)),
tlv.T1(uint32(c.Uin), c.device.IpAddress), tlv.T1(uint32(c.Uin), c.Device().IpAddress),
tlv.T(0x106, c.sig.EncryptedA1), tlv.T(0x106, c.sig.EncryptedA1),
tlv.T116(c.version.MiscBitmap, c.version.SubSigmap), tlv.T116(c.version().MiscBitmap, c.version().SubSigmap),
tlv.T100(c.version.SSOVersion, 2, c.version.MainSigMap), tlv.T100(c.version().SSOVersion, 2, c.version().MainSigMap),
tlv.T107(0), tlv.T107(0),
tlv.T108(c.sig.Ksid), tlv.T108(c.sig.Ksid),
tlv.T144( tlv.T144(
c.device.AndroidId, c.Device().AndroidId,
c.device.GenDeviceInfoData(), c.Device().GenDeviceInfoData(),
c.device.OSType, c.Device().OSType,
c.device.Version.Release, c.Device().Version.Release,
c.device.SimInfo, c.Device().SimInfo,
c.device.APN, c.Device().APN,
false, true, false, tlv.GuidFlag(), false, true, false, tlv.GuidFlag(),
c.device.Model, c.Device().Model,
c.device.Guid, c.Device().Guid,
c.device.Brand, c.Device().Brand,
c.device.TgtgtKey, c.Device().TgtgtKey,
), ),
tlv.T142(c.version.ApkId), tlv.T142(c.version().ApkId),
tlv.T145(c.device.Guid), tlv.T145(c.Device().Guid),
tlv.T16A(c.sig.SrmToken), tlv.T16A(c.sig.SrmToken),
tlv.T154(seq), tlv.T154(seq),
tlv.T141(c.device.SimInfo, c.device.APN), tlv.T141(c.Device().SimInfo, c.Device().APN),
tlv.T8(2052), tlv.T8(2052),
tlv.T511([]string{ tlv.T511([]string{
"tenpay.com", "openmobile.qq.com", "docs.qq.com", "connect.qq.com", "tenpay.com", "openmobile.qq.com", "docs.qq.com", "connect.qq.com",
"qzone.qq.com", "vip.qq.com", "qun.qq.com", "game.qq.com", "qqweb.qq.com", "qzone.qq.com", "vip.qq.com", "qun.qq.com", "game.qq.com", "qqweb.qq.com",
"office.qq.com", "ti.qq.com", "mail.qq.com", "qzone.com", "mma.qq.com", "office.qq.com", "ti.qq.com", "mail.qq.com", "qzone.com", "mma.qq.com",
}), }),
tlv.T147(16, []byte(c.version.SortVersionName), c.version.ApkSign), tlv.T147(16, []byte(c.version().SortVersionName), c.version().ApkSign),
tlv.T177(c.version.BuildTime, c.version.SdkVersion), tlv.T177(c.version().BuildTime, c.version().SdkVersion),
tlv.T400(c.sig.G, c.Uin, c.device.Guid, c.sig.Dpwd, 1, 16, c.sig.RandSeed), tlv.T400(c.sig.G, c.Uin, c.Device().Guid, c.sig.Dpwd, 1, 16, c.sig.RandSeed),
tlv.T187(c.device.MacAddress), tlv.T187(c.Device().MacAddress),
tlv.T188(c.device.AndroidId), tlv.T188(c.Device().AndroidId),
tlv.T194(c.device.IMSIMd5), tlv.T194(c.Device().IMSIMd5),
tlv.T202(c.device.WifiBSSID, c.device.WifiSSID), tlv.T202(c.Device().WifiBSSID, c.Device().WifiSSID),
tlv.T516(), tlv.T516(),
tlv.T521(0), tlv.T521(0),
tlv.T525(tlv.T536([]byte{0x01, 0x00})), tlv.T525(tlv.T536([]byte{0x01, 0x00})),
tlv.T545([]byte(c.device.IMEI)), tlv.T545([]byte(c.Device().IMEI)),
}, },
} }
m := oicq.Message{ m := oicq.Message{
@ -445,9 +446,9 @@ func (c *QQClient) buildRequestChangeSigPacket(changeD2 bool) (uint16, []byte) {
t := &oicq.TLV{ t := &oicq.TLV{
Command: 11, Command: 11,
List: [][]byte{ List: [][]byte{
tlv.T100(c.version.SSOVersion, 100, c.version.MainSigMap), tlv.T100(c.version().SSOVersion, 100, c.version().MainSigMap),
tlv.T10A(c.sig.TGT), tlv.T10A(c.sig.TGT),
tlv.T116(c.version.MiscBitmap, c.version.SubSigmap), tlv.T116(c.version().MiscBitmap, c.version().SubSigmap),
tlv.T108(c.sig.Ksid), tlv.T108(c.sig.Ksid),
}, },
} }
@ -463,16 +464,16 @@ func (c *QQClient) buildRequestChangeSigPacket(changeD2 bool) (uint16, []byte) {
} }
t.Append( t.Append(
tlv.T144( tlv.T144(
c.device.AndroidId, c.Device().AndroidId,
c.device.GenDeviceInfoData(), c.Device().GenDeviceInfoData(),
c.device.OSType, c.Device().OSType,
c.device.Version.Release, c.Device().Version.Release,
c.device.SimInfo, c.Device().SimInfo,
c.device.APN, c.Device().APN,
false, true, false, tlv.GuidFlag(), false, true, false, tlv.GuidFlag(),
c.device.Model, c.Device().Model,
c.device.Guid, c.Device().Guid,
c.device.Brand, c.Device().Brand,
key, key,
), ),
tlv.T112(c.Uin), tlv.T112(c.Uin),
@ -480,25 +481,25 @@ func (c *QQClient) buildRequestChangeSigPacket(changeD2 bool) (uint16, []byte) {
if changeD2 { if changeD2 {
t.Append(tlv.T143(c.sig.D2)) t.Append(tlv.T143(c.sig.D2))
} else { } else {
t.Append(tlv.T145(c.device.Guid)) t.Append(tlv.T145(c.Device().Guid))
} }
t.Append( t.Append(
tlv.T142(c.version.ApkId), tlv.T142(c.version().ApkId),
tlv.T154(seq), tlv.T154(seq),
tlv.T18(16, uint32(c.Uin)), tlv.T18(16, uint32(c.Uin)),
tlv.T141(c.device.SimInfo, c.device.APN), tlv.T141(c.Device().SimInfo, c.Device().APN),
tlv.T8(2052), tlv.T8(2052),
tlv.T147(16, []byte(c.version.SortVersionName), c.version.ApkSign), tlv.T147(16, []byte(c.version().SortVersionName), c.version().ApkSign),
tlv.T177(c.version.BuildTime, c.version.SdkVersion), tlv.T177(c.version().BuildTime, c.version().SdkVersion),
tlv.T187(c.device.MacAddress), tlv.T187(c.Device().MacAddress),
tlv.T188(c.device.AndroidId), tlv.T188(c.Device().AndroidId),
tlv.T194(c.device.IMSIMd5), tlv.T194(c.Device().IMSIMd5),
tlv.T511([]string{ tlv.T511([]string{
"tenpay.com", "openmobile.qq.com", "docs.qq.com", "connect.qq.com", "tenpay.com", "openmobile.qq.com", "docs.qq.com", "connect.qq.com",
"qzone.qq.com", "vip.qq.com", "qun.qq.com", "game.qq.com", "qqweb.qq.com", "qzone.qq.com", "vip.qq.com", "qun.qq.com", "game.qq.com", "qqweb.qq.com",
"office.qq.com", "ti.qq.com", "mail.qq.com", "qzone.com", "mma.qq.com", "office.qq.com", "ti.qq.com", "mail.qq.com", "qzone.com", "mma.qq.com",
}), }),
tlv.T202(c.device.WifiBSSID, c.device.WifiSSID), tlv.T202(c.Device().WifiBSSID, c.Device().WifiSSID),
) )
req := c.buildOicqRequestPacket(c.Uin, 0x0810, t) req := c.buildOicqRequestPacket(c.Uin, 0x0810, t)
req2 := network.Request{ req2 := network.Request{
@ -522,23 +523,23 @@ func (c *QQClient) buildClientRegisterPacket() (uint16, []byte) {
Status: 11, Status: 11,
KickPC: 0, KickPC: 0,
KickWeak: 0, KickWeak: 0,
IOSVersion: int64(c.device.Version.SDK), IOSVersion: int64(c.Device().Version.SDK),
NetType: 1, NetType: 1,
RegType: 0, RegType: 0,
Guid: c.device.Guid, Guid: c.Device().Guid,
IsSetStatus: 0, IsSetStatus: 0,
LocaleId: 2052, LocaleId: 2052,
DevName: string(c.device.Model), DevName: string(c.Device().Model),
DevType: string(c.device.Model), DevType: string(c.Device().Model),
OSVer: string(c.device.Version.Release), OSVer: string(c.Device().Version.Release),
OpenPush: 1, OpenPush: 1,
LargeSeq: 1551, LargeSeq: 1551,
OldSSOIp: 0, OldSSOIp: 0,
NewSSOIp: 31806887127679168, NewSSOIp: 31806887127679168,
ChannelNo: "", ChannelNo: "",
CPID: 0, CPID: 0,
VendorName: string(c.device.VendorName), VendorName: string(c.Device().VendorName),
VendorOSName: string(c.device.VendorOSName), VendorOSName: string(c.Device().VendorOSName),
B769: []byte{0x0A, 0x04, 0x08, 0x2E, 0x10, 0x00, 0x0A, 0x05, 0x08, 0x9B, 0x02, 0x10, 0x00}, B769: []byte{0x0A, 0x04, 0x08, 0x2E, 0x10, 0x00, 0x0A, 0x05, 0x08, 0x9B, 0x02, 0x10, 0x00},
SetMute: 0, SetMute: 0,
} }
@ -576,15 +577,15 @@ func (c *QQClient) buildStatusSetPacket(status, extStatus int32) (uint16, []byte
KickPC: 0, KickPC: 0,
KickWeak: 0, KickWeak: 0,
Timestamp: time.Now().Unix(), Timestamp: time.Now().Unix(),
IOSVersion: int64(c.device.Version.SDK), IOSVersion: int64(c.Device().Version.SDK),
NetType: 1, NetType: 1,
RegType: 0, RegType: 0,
Guid: c.device.Guid, Guid: c.Device().Guid,
IsSetStatus: 1, IsSetStatus: 1,
LocaleId: 2052, LocaleId: 2052,
DevName: string(c.device.Model), DevName: string(c.Device().Model),
DevType: string(c.device.Model), DevType: string(c.Device().Model),
OSVer: string(c.device.Version.Release), OSVer: string(c.Device().Version.Release),
OpenPush: 1, OpenPush: 1,
LargeSeq: 1551, LargeSeq: 1551,
ExtOnlineStatus: int64(extStatus), ExtOnlineStatus: int64(extStatus),

View File

@ -65,8 +65,6 @@ type QQClient struct {
servers []netip.AddrPort servers []netip.AddrPort
currServerIndex int currServerIndex int
retryTimes int retryTimes int
version *auth.AppVersion
device *auth.Device
alive bool alive bool
// session info // session info
@ -199,11 +197,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
highwaySession: new(highway.Session), highwaySession: new(highway.Session),
} }
cli.transport = &network.Transport{ cli.transport = &network.Transport{Sig: cli.sig}
Sig: cli.sig,
Version: &cli.version,
Device: &cli.device,
}
cli.oicq = oicq.NewCodec(cli.Uin) cli.oicq = oicq.NewCodec(cli.Uin)
{ // init atomic values { // init atomic values
cli.SequenceId.Store(0x3635) cli.SequenceId.Store(0x3635)
@ -219,14 +213,18 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient {
return cli return cli
} }
func (c *QQClient) version() *auth.AppVersion {
return c.transport.Version
}
func (c *QQClient) Device() *DeviceInfo { func (c *QQClient) Device() *DeviceInfo {
return c.device return c.transport.Device
} }
func (c *QQClient) UseDevice(info *auth.Device) { func (c *QQClient) UseDevice(info *auth.Device) {
c.version = info.Protocol.Version() c.transport.Version = info.Protocol.Version()
c.device = info c.transport.Device = info
c.highwaySession.AppID = int32(c.version.AppId) c.highwaySession.AppID = int32(c.version().AppId)
c.sig.Ksid = []byte(fmt.Sprintf("|%s|A8.2.7.27f6ea96", info.IMEI)) c.sig.Ksid = []byte(fmt.Sprintf("|%s|A8.2.7.27f6ea96", info.IMEI))
} }
@ -278,7 +276,7 @@ func (c *QQClient) TokenLogin(token []byte) error {
c.oicq.WtSessionTicketKey = r.ReadBytesShort() c.oicq.WtSessionTicketKey = r.ReadBytesShort()
c.sig.OutPacketSessionID = r.ReadBytesShort() c.sig.OutPacketSessionID = r.ReadBytesShort()
// SystemDeviceInfo.TgtgtKey = r.ReadBytesShort() // SystemDeviceInfo.TgtgtKey = r.ReadBytesShort()
c.device.TgtgtKey = r.ReadBytesShort() c.Device().TgtgtKey = r.ReadBytesShort()
} }
_, err = c.sendAndWait(c.buildRequestChangeSigPacket(true)) _, err = c.sendAndWait(c.buildRequestChangeSigPacket(true))
if err != nil { if err != nil {
@ -408,7 +406,7 @@ func (c *QQClient) init(tokenLogin bool) error {
go c.doHeartbeat() go c.doHeartbeat()
} }
_ = c.RefreshStatus() _ = c.RefreshStatus()
if c.version.Protocol == auth.QiDian { if c.version().Protocol == auth.QiDian {
_, _ = c.sendAndWait(c.buildLoginExtraPacket()) // 小登录 _, _ = c.sendAndWait(c.buildLoginExtraPacket()) // 小登录
_, _ = c.sendAndWait(c.buildConnKeyRequestPacket()) // big data key 如果等待 config push 的话时间来不及 _, _ = c.sendAndWait(c.buildConnKeyRequestPacket()) // big data key 如果等待 config push 的话时间来不及
} }
@ -429,7 +427,7 @@ func (c *QQClient) GenToken() []byte {
w.WriteBytesShort(c.sig.EncryptedA1) w.WriteBytesShort(c.sig.EncryptedA1)
w.WriteBytesShort(c.oicq.WtSessionTicketKey) w.WriteBytesShort(c.oicq.WtSessionTicketKey)
w.WriteBytesShort(c.sig.OutPacketSessionID) w.WriteBytesShort(c.sig.OutPacketSessionID)
w.WriteBytesShort(c.device.TgtgtKey) w.WriteBytesShort(c.Device().TgtgtKey)
}) })
} }
@ -478,7 +476,7 @@ func (c *QQClient) ReloadFriendList() error {
// 当使用普通QQ时: 请求好友列表 // 当使用普通QQ时: 请求好友列表
// 当使用企点QQ时: 请求外部联系人列表 // 当使用企点QQ时: 请求外部联系人列表
func (c *QQClient) GetFriendList() (*FriendListResponse, error) { func (c *QQClient) GetFriendList() (*FriendListResponse, error) {
if c.version.Protocol == auth.QiDian { if c.version().Protocol == auth.QiDian {
rsp, err := c.getQiDianAddressDetailList() rsp, err := c.getQiDianAddressDetailList()
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -45,7 +45,7 @@ func decodeLoginResponse(c *QQClient, pkt *network.Packet) (any, error) {
if m.Exists(0x402) { if m.Exists(0x402) {
c.sig.Dpwd = []byte(utils.RandomString(16)) c.sig.Dpwd = []byte(utils.RandomString(16))
c.sig.T402 = m[0x402] c.sig.T402 = m[0x402]
h := md5.Sum(append(append(c.device.Guid, c.sig.Dpwd...), c.sig.T402...)) h := md5.Sum(append(append(c.Device().Guid, c.sig.Dpwd...), c.sig.T402...))
c.sig.G = h[:] c.sig.G = h[:]
} }
if m.Exists(0x546) { if m.Exists(0x546) {
@ -61,7 +61,7 @@ func decodeLoginResponse(c *QQClient, pkt *network.Packet) (any, error) {
if m.Exists(0x403) { if m.Exists(0x403) {
c.sig.RandSeed = m[0x403] c.sig.RandSeed = m[0x403]
} }
c.decodeT119(m[0x119], c.device.TgtgtKey) c.decodeT119(m[0x119], c.Device().TgtgtKey)
return LoginResponse{ return LoginResponse{
Success: true, Success: true,
}, nil }, nil
@ -306,7 +306,7 @@ func decodeTransEmpResponse(c *QQClient, pkt *network.Packet) (any, error) {
if !m.Exists(0x18) || !m.Exists(0x1e) || !m.Exists(0x19) { if !m.Exists(0x18) || !m.Exists(0x1e) || !m.Exists(0x19) {
return nil, errors.New("wtlogin.trans_emp sub cmd 0x12 error: tlv error") return nil, errors.New("wtlogin.trans_emp sub cmd 0x12 error: tlv error")
} }
c.device.TgtgtKey = m[0x1e] c.Device().TgtgtKey = m[0x1e]
return &QRCodeLoginResponse{State: QRCodeConfirmed, LoginInfo: &QRCodeLoginInfo{ return &QRCodeLoginResponse{State: QRCodeConfirmed, LoginInfo: &QRCodeLoginInfo{
tmpPwd: m[0x18], tmpPwd: m[0x18],
tmpNoPicSig: m[0x19], tmpNoPicSig: m[0x19],

View File

@ -31,8 +31,8 @@ func (c *QQClient) buildFaceroamRequestPacket() (uint16, []byte) {
payload, _ := proto.Marshal(&faceroam.FaceroamReqBody{ payload, _ := proto.Marshal(&faceroam.FaceroamReqBody{
Comm: &faceroam.PlatInfo{ Comm: &faceroam.PlatInfo{
Implat: proto.Int64(109), Implat: proto.Int64(109),
Osver: proto.String(string(c.device.Version.Release)), Osver: proto.String(string(c.Device().Version.Release)),
Mqqver: proto.Some(c.version.SortVersionName), Mqqver: proto.Some(c.version().SortVersionName),
}, },
Uin: proto.Uint64(uint64(c.Uin)), Uin: proto.Uint64(uint64(c.Uin)),
SubCmd: proto.Uint32(1), SubCmd: proto.Uint32(1),

View File

@ -297,9 +297,9 @@ func genForwardTemplate(resID, preview, summary string, ts int64, items []*msg.P
func (c *QQClient) getWebDeviceInfo() (i string) { func (c *QQClient) getWebDeviceInfo() (i string) {
qimei := strings.ToLower(utils.RandomString(36)) qimei := strings.ToLower(utils.RandomString(36))
i += fmt.Sprintf("i=%v&imsi=&mac=%v&m=%v&o=%v&", c.device.IMEI, utils.B2S(c.device.MacAddress), utils.B2S(c.device.Device), utils.B2S(c.device.Version.Release)) i += fmt.Sprintf("i=%v&imsi=&mac=%v&m=%v&o=%v&", c.Device().IMEI, utils.B2S(c.Device().MacAddress), utils.B2S(c.Device().Device), utils.B2S(c.Device().Version.Release))
i += fmt.Sprintf("a=%v&sd=0&c64=0&sc=1&p=1080*2210&aid=%v&", c.device.Version.SDK, c.device.IMEI) i += fmt.Sprintf("a=%v&sd=0&c64=0&sc=1&p=1080*2210&aid=%v&", c.Device().Version.SDK, c.Device().IMEI)
i += fmt.Sprintf("f=%v&mm=%v&cf=%v&cc=%v&", c.device.Brand, 5629 /* Total Memory*/, 1725 /* CPU Frequency */, 8 /* CPU Core Count */) i += fmt.Sprintf("f=%v&mm=%v&cf=%v&cc=%v&", c.Device().Brand, 5629 /* Total Memory*/, 1725 /* CPU Frequency */, 8 /* CPU Core Count */)
i += fmt.Sprintf("qimei=%v&qimei36=%v&", qimei, qimei) i += fmt.Sprintf("qimei=%v&qimei36=%v&", qimei, qimei)
i += "sharpP=1&n=wifi&support_xsj_live=true&client_mod=default&timezone=Asia/Shanghai&material_sdk_version=2.9.0&vh265=null&refreshrate=60" i += "sharpP=1&n=wifi&support_xsj_live=true&client_mod=default&timezone=Asia/Shanghai&material_sdk_version=2.9.0&vh265=null&refreshrate=60"
return return
@ -322,7 +322,7 @@ func (c *QQClient) packOIDBPackage(cmd, serviceType int32, body []byte) []byte {
Command: cmd, Command: cmd,
ServiceType: serviceType, ServiceType: serviceType,
Bodybuffer: body, Bodybuffer: body,
ClientVersion: "Android " + c.version.SortVersionName, ClientVersion: "Android " + c.version().SortVersionName,
} }
r, _ := proto.Marshal(pkg) r, _ := proto.Marshal(pkg)
return r return r

View File

@ -79,7 +79,7 @@ func (c *QQClient) GetGroupInfo(groupCode int64) (*GroupInfo, error) {
// OidbSvc.0x88d_0 // OidbSvc.0x88d_0
func (c *QQClient) buildGroupInfoRequestPacket(groupCode int64) (uint16, []byte) { func (c *QQClient) buildGroupInfoRequestPacket(groupCode int64) (uint16, []byte) {
body := &oidb.D88DReqBody{ body := &oidb.D88DReqBody{
AppId: proto.Uint32(c.version.AppId), AppId: proto.Uint32(c.version().AppId),
ReqGroupInfo: []*oidb.ReqGroupInfo{ ReqGroupInfo: []*oidb.ReqGroupInfo{
{ {
GroupCode: proto.Uint64(uint64(groupCode)), GroupCode: proto.Uint64(uint64(groupCode)),

View File

@ -10,8 +10,8 @@ import (
// Transport is a network transport. // Transport is a network transport.
type Transport struct { type Transport struct {
Sig *auth.SigInfo Sig *auth.SigInfo
Version **auth.AppVersion Version *auth.AppVersion
Device **auth.Device Device *auth.Device
// connection // connection
// conn *TCPClient // conn *TCPClient

View File

@ -59,7 +59,7 @@ func (c *QQClient) GetModelShow(modelName string) ([]*ModelVariant, error) {
Uin: c.Uin, Uin: c.Uin,
Model: strings.ReplaceAll(url.QueryEscape(modelName), "+", "%20"), Model: strings.ReplaceAll(url.QueryEscape(modelName), "+", "%20"),
AppType: 0, AppType: 0,
IMei: c.device.IMEI, IMei: c.Device().IMEI,
ShowInfo: true, ShowInfo: true,
ModelShow: "", ModelShow: "",
RecoverDefault: false, RecoverDefault: false,
@ -96,7 +96,7 @@ func (c *QQClient) SetModelShow(modelName string, modelShow string) error {
Uin: c.Uin, Uin: c.Uin,
Model: strings.ReplaceAll(url.QueryEscape(modelName), "+", "%20"), Model: strings.ReplaceAll(url.QueryEscape(modelName), "+", "%20"),
AppType: 0, AppType: 0,
IMei: c.device.IMEI, IMei: c.Device().IMEI,
ShowInfo: true, ShowInfo: true,
ModelShow: strings.ReplaceAll(url.QueryEscape(modelShow), "+", "%20"), ModelShow: strings.ReplaceAll(url.QueryEscape(modelShow), "+", "%20"),
RecoverDefault: modelShow == "", RecoverDefault: modelShow == "",

View File

@ -89,12 +89,12 @@ func (c *QQClient) ConnectionQualityTest() *ConnectionQualityInfo {
} }
func (c *QQClient) initServers() { func (c *QQClient) initServers() {
if c.device == nil { if c.Device() == nil {
// must have device. Use c.UseDevice to set it! // must have device. Use c.UseDevice to set it!
panic("client device is nil") panic("client device is nil")
} }
sso, err := getSSOAddress(c.device) sso, err := getSSOAddress(c.Device())
if err == nil && len(sso) > 0 { if err == nil && len(sso) > 0 {
c.servers = append(sso, c.servers...) c.servers = append(sso, c.servers...)
} }

View File

@ -30,7 +30,7 @@ func (c *QQClient) getQiDianAddressDetailList() ([]*FriendInfo, error) {
SubCmd: proto.Uint32(33), SubCmd: proto.Uint32(33),
CrmCommonHead: &cmd0x6ff.C519CRMMsgHead{ CrmCommonHead: &cmd0x6ff.C519CRMMsgHead{
KfUin: proto.Uint64(uint64(c.QiDian.MasterUin)), KfUin: proto.Uint64(uint64(c.QiDian.MasterUin)),
VerNo: proto.Uint32(uint32(utils.ConvertSubVersionToInt(c.version.SortVersionName))), VerNo: proto.Uint32(uint32(utils.ConvertSubVersionToInt(c.version().SortVersionName))),
CrmSubCmd: proto.Uint32(33), CrmSubCmd: proto.Uint32(33),
LaborUin: proto.Uint64(uint64(c.Uin)), LaborUin: proto.Uint64(uint64(c.Uin)),
}, },
@ -68,21 +68,21 @@ func (c *QQClient) buildLoginExtraPacket() (uint16, []byte) {
SubCmd: proto.Uint32(69), SubCmd: proto.Uint32(69),
CrmCommonHead: &cmd0x3f6.C3F6CRMMsgHead{ CrmCommonHead: &cmd0x3f6.C3F6CRMMsgHead{
CrmSubCmd: proto.Uint32(69), CrmSubCmd: proto.Uint32(69),
VerNo: proto.Uint32(uint32(utils.ConvertSubVersionToInt(c.version.SortVersionName))), VerNo: proto.Uint32(uint32(utils.ConvertSubVersionToInt(c.version().SortVersionName))),
Clienttype: proto.Uint32(2), Clienttype: proto.Uint32(2),
}, },
SubcmdLoginProcessCompleteReqBody: &cmd0x3f6.QDUserLoginProcessCompleteReqBody{ SubcmdLoginProcessCompleteReqBody: &cmd0x3f6.QDUserLoginProcessCompleteReqBody{
Kfext: proto.Uint64(uint64(c.Uin)), Kfext: proto.Uint64(uint64(c.Uin)),
Pubno: proto.Some(c.version.AppId), Pubno: proto.Some(c.version().AppId),
Buildno: proto.Uint32(uint32(utils.ConvertSubVersionToInt(c.version.SortVersionName))), Buildno: proto.Uint32(uint32(utils.ConvertSubVersionToInt(c.version().SortVersionName))),
TerminalType: proto.Uint32(2), TerminalType: proto.Uint32(2),
Status: proto.Uint32(10), Status: proto.Uint32(10),
LoginTime: proto.Uint32(5), LoginTime: proto.Uint32(5),
HardwareInfo: proto.String(string(c.device.Model)), HardwareInfo: proto.String(string(c.Device().Model)),
SoftwareInfo: proto.String(string(c.device.Version.Release)), SoftwareInfo: proto.String(string(c.Device().Version.Release)),
Guid: c.device.Guid, Guid: c.Device().Guid,
AppName: proto.Some(c.version.ApkId), AppName: proto.Some(c.version().ApkId),
SubAppId: proto.Some(c.version.AppId), SubAppId: proto.Some(c.version().AppId),
}, },
} }
payload, _ := proto.Marshal(req) payload, _ := proto.Marshal(req)

View File

@ -121,7 +121,7 @@ func (c *QQClient) MarkPrivateMessageReaded(uin, time int64) {
// StatSvc.GetDevLoginInfo // StatSvc.GetDevLoginInfo
func (c *QQClient) buildDeviceListRequestPacket() (uint16, []byte) { func (c *QQClient) buildDeviceListRequestPacket() (uint16, []byte) {
req := &jce.SvcReqGetDevLoginInfo{ req := &jce.SvcReqGetDevLoginInfo{
Guid: c.device.Guid, Guid: c.Device().Guid,
LoginType: 1, LoginType: 1,
AppName: "com.tencent.mobileqq", AppName: "com.tencent.mobileqq",
RequireMax: 20, RequireMax: 20,

View File

@ -121,7 +121,7 @@ func (c *QQClient) decodeT119(data, ek []byte) {
if len(decrypted) > 51+16 { if len(decrypted) > 51+16 {
dr := binary.NewReader(decrypted) dr := binary.NewReader(decrypted)
dr.ReadBytes(51) dr.ReadBytes(51)
c.device.TgtgtKey = dr.ReadBytes(16) c.Device().TgtgtKey = dr.ReadBytes(16)
} }
} }
c.Nickname = nick c.Nickname = nick
@ -131,7 +131,7 @@ func (c *QQClient) decodeT119(data, ek []byte) {
// wtlogin.exchange_emp // wtlogin.exchange_emp
func (c *QQClient) decodeT119R(data []byte) { func (c *QQClient) decodeT119R(data []byte) {
tea := binary.NewTeaCipher(c.device.TgtgtKey) tea := binary.NewTeaCipher(c.Device().TgtgtKey)
m, _ := tlv.NewDecoder(2, 2).DecodeRecordMap(tea.Decrypt(data)[2:]) m, _ := tlv.NewDecoder(2, 2).DecodeRecordMap(tea.Decrypt(data)[2:])
if t120, ok := m[0x120]; ok { if t120, ok := m[0x120]; ok {
c.sig.SKey = t120 c.sig.SKey = t120

View File

@ -105,7 +105,7 @@ func (c *QQClient) UploadFile(target message.Source, file *LocalFile) error {
}, },
ClientInfo: &exciting.ExcitingClientInfo{ ClientInfo: &exciting.ExcitingClientInfo{
ClientType: proto.Int32(2), ClientType: proto.Int32(2),
AppId: proto.String(fmt.Sprint(c.version.AppId)), AppId: proto.String(fmt.Sprint(c.version().AppId)),
TerminalType: proto.Int32(2), TerminalType: proto.Int32(2),
ClientVer: proto.String("d92615c5"), ClientVer: proto.String("d92615c5"),
Unknown: proto.Int32(4), Unknown: proto.Int32(4),