From ed15fbca26b83c65813140d8222082e24470d313 Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Thu, 16 Feb 2023 18:40:56 +0800 Subject: [PATCH] client: move device&version into c.transport --- client/builders.go | 233 ++++++++++++++------------- client/client.go | 28 ++-- client/decoders.go | 6 +- client/face.go | 4 +- client/global.go | 8 +- client/group_info.go | 2 +- client/internal/network/transport.go | 4 +- client/model_show.go | 4 +- client/network.go | 4 +- client/qidian.go | 18 +-- client/sync.go | 2 +- client/tlv_decoders.go | 4 +- client/upload_file.go | 2 +- 13 files changed, 159 insertions(+), 160 deletions(-) diff --git a/client/builders.go b/client/builders.go index 5558c2f0..4abe6b95 100644 --- a/client/builders.go +++ b/client/builders.go @@ -49,55 +49,55 @@ func (c *QQClient) buildLoginPacket() (uint16, []byte) { Command: 9, List: [][]byte{ tlv.T18(16, uint32(c.Uin)), - 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.T116(c.version.MiscBitmap, c.version.SubSigmap), - tlv.T100(c.version.SSOVersion, c.version.SubAppId, c.version.MainSigMap), + 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.T116(c.version().MiscBitmap, c.version().SubSigmap), + tlv.T100(c.version().SSOVersion, c.version().SubAppId, c.version().MainSigMap), tlv.T107(0), - tlv.T142(c.version.ApkId), + tlv.T142(c.version().ApkId), tlv.T144( - []byte(c.device.IMEI), - c.device.GenDeviceInfoData(), - c.device.OSType, - c.device.Version.Release, - c.device.SimInfo, - c.device.APN, + []byte(c.Device().IMEI), + c.Device().GenDeviceInfoData(), + c.Device().OSType, + c.Device().Version.Release, + c.Device().SimInfo, + c.Device().APN, false, true, false, tlv.GuidFlag(), - c.device.Model, - c.device.Guid, - c.device.Brand, - c.device.TgtgtKey, + c.Device().Model, + c.Device().Guid, + c.Device().Brand, + c.Device().TgtgtKey, ), - tlv.T145(c.device.Guid), - tlv.T147(16, []byte(c.version.SortVersionName), c.version.ApkSign), + tlv.T145(c.Device().Guid), + tlv.T147(16, []byte(c.version().SortVersionName), c.version().ApkSign), /* if (miscBitMap & 0x80) != 0{ w.Write(tlv.T166(1)) } */ tlv.T154(seq), - tlv.T141(c.device.SimInfo, c.device.APN), + tlv.T141(c.Device().SimInfo, c.Device().APN), tlv.T8(2052), tlv.T511([]string{ "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", "qqweb.qq.com", "office.qq.com", "ti.qq.com", "mail.qq.com", "mma.qq.com", }), - tlv.T187(c.device.MacAddress), - tlv.T188(c.device.AndroidId), + tlv.T187(c.Device().MacAddress), + tlv.T188(c.Device().AndroidId), }, } - if len(c.device.IMSIMd5) != 0 { - t.Append(tlv.T194(c.device.IMSIMd5)) + if len(c.Device().IMSIMd5) != 0 { + t.Append(tlv.T194(c.Device().IMSIMd5)) } if c.AllowSlider { t.Append(tlv.T191(0x82)) } - if len(c.device.WifiBSSID) != 0 && len(c.device.WifiSSID) != 0 { - t.Append(tlv.T202(c.device.WifiBSSID, c.device.WifiSSID)) + if len(c.Device().WifiBSSID) != 0 && len(c.Device().WifiSSID) != 0 { + t.Append(tlv.T202(c.Device().WifiBSSID, c.Device().WifiSSID)) } t.Append( - tlv.T177(c.version.BuildTime, c.version.SdkVersion), + tlv.T177(c.version().BuildTime, c.version().SdkVersion), tlv.T516(), tlv.T521(0), tlv.T525(tlv.T536([]byte{0x01, 0x00})), @@ -121,7 +121,7 @@ func (c *QQClient) buildDeviceLockLoginPacket() (uint16, []byte) { List: [][]byte{ tlv.T8(2052), 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), }, }) @@ -137,8 +137,9 @@ func (c *QQClient) buildDeviceLockLoginPacket() (uint16, []byte) { } func (c *QQClient) buildQRCodeFetchRequestPacket(size, margin, ecLevel uint32) (uint16, []byte) { + old := c.version() watch := auth.AndroidWatch.Version() - c.transport.Version = &watch + c.transport.Version = watch seq := c.nextSeq() req := oicq.Message{ Command: 0x0812, @@ -154,11 +155,11 @@ func (c *QQClient) buildQRCodeFetchRequestPacket(size, margin, ecLevel uint32) ( w.WriteBytesShort(EmptyBytes) 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.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.T33(c.device.Guid)) + 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.T35(8)) })) }), @@ -172,13 +173,13 @@ func (c *QQClient) buildQRCodeFetchRequestPacket(size, margin, ecLevel uint32) ( Body: c.oicq.Marshal(&req), } payload := c.transport.PackPacket(&r) - c.transport.Version = &c.version + c.transport.Version = old return seq, payload } func (c *QQClient) buildQRCodeResultQueryRequestPacket(sig []byte) (uint16, []byte) { - watch := auth.AndroidWatch.Version() - c.transport.Version = &watch + old := c.version() + c.transport.Version = auth.AndroidWatch.Version() seq := c.nextSeq() req := oicq.Message{ Command: 0x0812, @@ -208,7 +209,7 @@ func (c *QQClient) buildQRCodeResultQueryRequestPacket(sig []byte) (uint16, []by Body: c.oicq.Marshal(&req), } payload := c.transport.PackPacket(&r) - c.transport.Version = &c.version + c.transport.Version = old return seq, payload } @@ -218,43 +219,43 @@ func (c *QQClient) buildQRCodeLoginPacket(t106, t16a, t318 []byte) (uint16, []by Command: 9, List: [][]byte{ 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.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.T100(c.version.SSOVersion, c.version.SubAppId, c.version.MainSigMap), + tlv.T116(c.version().MiscBitmap, c.version().SubSigmap), + tlv.T100(c.version().SSOVersion, c.version().SubAppId, c.version().MainSigMap), tlv.T107(0), - tlv.T142(c.version.ApkId), + tlv.T142(c.version().ApkId), tlv.T144( - []byte(c.device.IMEI), - c.device.GenDeviceInfoData(), - c.device.OSType, - c.device.Version.Release, - c.device.SimInfo, - c.device.APN, + []byte(c.Device().IMEI), + c.Device().GenDeviceInfoData(), + c.Device().OSType, + c.Device().Version.Release, + c.Device().SimInfo, + c.Device().APN, false, true, false, tlv.GuidFlag(), - c.device.Model, - c.device.Guid, - c.device.Brand, - c.device.TgtgtKey, + c.Device().Model, + c.Device().Guid, + c.Device().Brand, + c.Device().TgtgtKey, ), - tlv.T145(c.device.Guid), - tlv.T147(16, []byte(c.version.SortVersionName), c.version.ApkSign), + tlv.T145(c.Device().Guid), + tlv.T147(16, []byte(c.version().SortVersionName), c.version().ApkSign), tlv.T(0x16a, t16a), tlv.T154(seq), - tlv.T141(c.device.SimInfo, c.device.APN), + tlv.T141(c.Device().SimInfo, c.Device().APN), tlv.T8(2052), tlv.T511([]string{ "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", "qqweb.qq.com", "office.qq.com", "ti.qq.com", "mail.qq.com", "mma.qq.com", }), - tlv.T187(c.device.MacAddress), - tlv.T188(c.device.AndroidId), - tlv.T194(c.device.IMSIMd5), + tlv.T187(c.Device().MacAddress), + tlv.T188(c.Device().AndroidId), + tlv.T194(c.Device().IMSIMd5), tlv.T191(0x00), - tlv.T202(c.device.WifiBSSID, c.device.WifiSSID), - tlv.T177(c.version.BuildTime, c.version.SdkVersion), + tlv.T202(c.Device().WifiBSSID, c.Device().WifiSSID), + tlv.T177(c.version().BuildTime, c.version().SdkVersion), tlv.T516(), tlv.T521(8), // 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.T8(2052), 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 { @@ -306,7 +307,7 @@ func (c *QQClient) buildSMSRequestPacket() (uint16, []byte) { List: [][]byte{ tlv.T8(2052), 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.T17A(9), tlv.T197(), @@ -330,7 +331,7 @@ func (c *QQClient) buildSMSCodeSubmitPacket(code string) (uint16, []byte) { List: [][]byte{ tlv.T8(2052), 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.T17C(code), tlv.T401(c.sig.G), @@ -356,7 +357,7 @@ func (c *QQClient) buildTicketSubmitPacket(ticket string) (uint16, []byte) { tlv.T193(ticket), tlv.T8(2052), 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 { @@ -380,47 +381,47 @@ func (c *QQClient) buildRequestTgtgtNopicsigPacket() (uint16, []byte) { Command: 15, List: [][]byte{ 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.T116(c.version.MiscBitmap, c.version.SubSigmap), - tlv.T100(c.version.SSOVersion, 2, c.version.MainSigMap), + tlv.T116(c.version().MiscBitmap, c.version().SubSigmap), + tlv.T100(c.version().SSOVersion, 2, c.version().MainSigMap), tlv.T107(0), tlv.T108(c.sig.Ksid), tlv.T144( - c.device.AndroidId, - c.device.GenDeviceInfoData(), - c.device.OSType, - c.device.Version.Release, - c.device.SimInfo, - c.device.APN, + c.Device().AndroidId, + c.Device().GenDeviceInfoData(), + c.Device().OSType, + c.Device().Version.Release, + c.Device().SimInfo, + c.Device().APN, false, true, false, tlv.GuidFlag(), - c.device.Model, - c.device.Guid, - c.device.Brand, - c.device.TgtgtKey, + c.Device().Model, + c.Device().Guid, + c.Device().Brand, + c.Device().TgtgtKey, ), - tlv.T142(c.version.ApkId), - tlv.T145(c.device.Guid), + tlv.T142(c.version().ApkId), + tlv.T145(c.Device().Guid), tlv.T16A(c.sig.SrmToken), tlv.T154(seq), - tlv.T141(c.device.SimInfo, c.device.APN), + tlv.T141(c.Device().SimInfo, c.Device().APN), tlv.T8(2052), tlv.T511([]string{ "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", "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.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.T187(c.device.MacAddress), - tlv.T188(c.device.AndroidId), - tlv.T194(c.device.IMSIMd5), - tlv.T202(c.device.WifiBSSID, c.device.WifiSSID), + tlv.T147(16, []byte(c.version().SortVersionName), c.version().ApkSign), + 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.T187(c.Device().MacAddress), + tlv.T188(c.Device().AndroidId), + tlv.T194(c.Device().IMSIMd5), + tlv.T202(c.Device().WifiBSSID, c.Device().WifiSSID), tlv.T516(), tlv.T521(0), tlv.T525(tlv.T536([]byte{0x01, 0x00})), - tlv.T545([]byte(c.device.IMEI)), + tlv.T545([]byte(c.Device().IMEI)), }, } m := oicq.Message{ @@ -445,9 +446,9 @@ func (c *QQClient) buildRequestChangeSigPacket(changeD2 bool) (uint16, []byte) { t := &oicq.TLV{ Command: 11, 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.T116(c.version.MiscBitmap, c.version.SubSigmap), + tlv.T116(c.version().MiscBitmap, c.version().SubSigmap), tlv.T108(c.sig.Ksid), }, } @@ -463,16 +464,16 @@ func (c *QQClient) buildRequestChangeSigPacket(changeD2 bool) (uint16, []byte) { } t.Append( tlv.T144( - c.device.AndroidId, - c.device.GenDeviceInfoData(), - c.device.OSType, - c.device.Version.Release, - c.device.SimInfo, - c.device.APN, + c.Device().AndroidId, + c.Device().GenDeviceInfoData(), + c.Device().OSType, + c.Device().Version.Release, + c.Device().SimInfo, + c.Device().APN, false, true, false, tlv.GuidFlag(), - c.device.Model, - c.device.Guid, - c.device.Brand, + c.Device().Model, + c.Device().Guid, + c.Device().Brand, key, ), tlv.T112(c.Uin), @@ -480,25 +481,25 @@ func (c *QQClient) buildRequestChangeSigPacket(changeD2 bool) (uint16, []byte) { if changeD2 { t.Append(tlv.T143(c.sig.D2)) } else { - t.Append(tlv.T145(c.device.Guid)) + t.Append(tlv.T145(c.Device().Guid)) } t.Append( - tlv.T142(c.version.ApkId), + tlv.T142(c.version().ApkId), tlv.T154(seq), 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.T147(16, []byte(c.version.SortVersionName), c.version.ApkSign), - tlv.T177(c.version.BuildTime, c.version.SdkVersion), - tlv.T187(c.device.MacAddress), - tlv.T188(c.device.AndroidId), - tlv.T194(c.device.IMSIMd5), + tlv.T147(16, []byte(c.version().SortVersionName), c.version().ApkSign), + tlv.T177(c.version().BuildTime, c.version().SdkVersion), + tlv.T187(c.Device().MacAddress), + tlv.T188(c.Device().AndroidId), + tlv.T194(c.Device().IMSIMd5), tlv.T511([]string{ "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", "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) req2 := network.Request{ @@ -522,23 +523,23 @@ func (c *QQClient) buildClientRegisterPacket() (uint16, []byte) { Status: 11, KickPC: 0, KickWeak: 0, - IOSVersion: int64(c.device.Version.SDK), + IOSVersion: int64(c.Device().Version.SDK), NetType: 1, RegType: 0, - Guid: c.device.Guid, + Guid: c.Device().Guid, IsSetStatus: 0, LocaleId: 2052, - DevName: string(c.device.Model), - DevType: string(c.device.Model), - OSVer: string(c.device.Version.Release), + DevName: string(c.Device().Model), + DevType: string(c.Device().Model), + OSVer: string(c.Device().Version.Release), OpenPush: 1, LargeSeq: 1551, OldSSOIp: 0, NewSSOIp: 31806887127679168, ChannelNo: "", CPID: 0, - VendorName: string(c.device.VendorName), - VendorOSName: string(c.device.VendorOSName), + VendorName: string(c.Device().VendorName), + VendorOSName: string(c.Device().VendorOSName), B769: []byte{0x0A, 0x04, 0x08, 0x2E, 0x10, 0x00, 0x0A, 0x05, 0x08, 0x9B, 0x02, 0x10, 0x00}, SetMute: 0, } @@ -576,15 +577,15 @@ func (c *QQClient) buildStatusSetPacket(status, extStatus int32) (uint16, []byte KickPC: 0, KickWeak: 0, Timestamp: time.Now().Unix(), - IOSVersion: int64(c.device.Version.SDK), + IOSVersion: int64(c.Device().Version.SDK), NetType: 1, RegType: 0, - Guid: c.device.Guid, + Guid: c.Device().Guid, IsSetStatus: 1, LocaleId: 2052, - DevName: string(c.device.Model), - DevType: string(c.device.Model), - OSVer: string(c.device.Version.Release), + DevName: string(c.Device().Model), + DevType: string(c.Device().Model), + OSVer: string(c.Device().Version.Release), OpenPush: 1, LargeSeq: 1551, ExtOnlineStatus: int64(extStatus), diff --git a/client/client.go b/client/client.go index bac2f7e5..69b8aa12 100644 --- a/client/client.go +++ b/client/client.go @@ -65,8 +65,6 @@ type QQClient struct { servers []netip.AddrPort currServerIndex int retryTimes int - version *auth.AppVersion - device *auth.Device alive bool // session info @@ -199,11 +197,7 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient { highwaySession: new(highway.Session), } - cli.transport = &network.Transport{ - Sig: cli.sig, - Version: &cli.version, - Device: &cli.device, - } + cli.transport = &network.Transport{Sig: cli.sig} cli.oicq = oicq.NewCodec(cli.Uin) { // init atomic values cli.SequenceId.Store(0x3635) @@ -219,14 +213,18 @@ func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient { return cli } +func (c *QQClient) version() *auth.AppVersion { + return c.transport.Version +} + func (c *QQClient) Device() *DeviceInfo { - return c.device + return c.transport.Device } func (c *QQClient) UseDevice(info *auth.Device) { - c.version = info.Protocol.Version() - c.device = info - c.highwaySession.AppID = int32(c.version.AppId) + c.transport.Version = info.Protocol.Version() + c.transport.Device = info + c.highwaySession.AppID = int32(c.version().AppId) 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.sig.OutPacketSessionID = r.ReadBytesShort() // SystemDeviceInfo.TgtgtKey = r.ReadBytesShort() - c.device.TgtgtKey = r.ReadBytesShort() + c.Device().TgtgtKey = r.ReadBytesShort() } _, err = c.sendAndWait(c.buildRequestChangeSigPacket(true)) if err != nil { @@ -408,7 +406,7 @@ func (c *QQClient) init(tokenLogin bool) error { go c.doHeartbeat() } _ = c.RefreshStatus() - if c.version.Protocol == auth.QiDian { + if c.version().Protocol == auth.QiDian { _, _ = c.sendAndWait(c.buildLoginExtraPacket()) // 小登录 _, _ = 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.oicq.WtSessionTicketKey) 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时: 请求外部联系人列表 func (c *QQClient) GetFriendList() (*FriendListResponse, error) { - if c.version.Protocol == auth.QiDian { + if c.version().Protocol == auth.QiDian { rsp, err := c.getQiDianAddressDetailList() if err != nil { return nil, err diff --git a/client/decoders.go b/client/decoders.go index 10dd24aa..7899622b 100644 --- a/client/decoders.go +++ b/client/decoders.go @@ -45,7 +45,7 @@ func decodeLoginResponse(c *QQClient, pkt *network.Packet) (any, error) { if m.Exists(0x402) { c.sig.Dpwd = []byte(utils.RandomString(16)) 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[:] } if m.Exists(0x546) { @@ -61,7 +61,7 @@ func decodeLoginResponse(c *QQClient, pkt *network.Packet) (any, error) { if m.Exists(0x403) { c.sig.RandSeed = m[0x403] } - c.decodeT119(m[0x119], c.device.TgtgtKey) + c.decodeT119(m[0x119], c.Device().TgtgtKey) return LoginResponse{ Success: true, }, nil @@ -306,7 +306,7 @@ func decodeTransEmpResponse(c *QQClient, pkt *network.Packet) (any, error) { if !m.Exists(0x18) || !m.Exists(0x1e) || !m.Exists(0x19) { 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{ tmpPwd: m[0x18], tmpNoPicSig: m[0x19], diff --git a/client/face.go b/client/face.go index bf1a0cf9..25eff0b3 100644 --- a/client/face.go +++ b/client/face.go @@ -31,8 +31,8 @@ func (c *QQClient) buildFaceroamRequestPacket() (uint16, []byte) { payload, _ := proto.Marshal(&faceroam.FaceroamReqBody{ Comm: &faceroam.PlatInfo{ Implat: proto.Int64(109), - Osver: proto.String(string(c.device.Version.Release)), - Mqqver: proto.Some(c.version.SortVersionName), + Osver: proto.String(string(c.Device().Version.Release)), + Mqqver: proto.Some(c.version().SortVersionName), }, Uin: proto.Uint64(uint64(c.Uin)), SubCmd: proto.Uint32(1), diff --git a/client/global.go b/client/global.go index c5c15e70..139011cf 100644 --- a/client/global.go +++ b/client/global.go @@ -297,9 +297,9 @@ func genForwardTemplate(resID, preview, summary string, ts int64, items []*msg.P func (c *QQClient) getWebDeviceInfo() (i string) { 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("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("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("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 += "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 @@ -322,7 +322,7 @@ func (c *QQClient) packOIDBPackage(cmd, serviceType int32, body []byte) []byte { Command: cmd, ServiceType: serviceType, Bodybuffer: body, - ClientVersion: "Android " + c.version.SortVersionName, + ClientVersion: "Android " + c.version().SortVersionName, } r, _ := proto.Marshal(pkg) return r diff --git a/client/group_info.go b/client/group_info.go index 0d46746e..f2e4610a 100644 --- a/client/group_info.go +++ b/client/group_info.go @@ -79,7 +79,7 @@ func (c *QQClient) GetGroupInfo(groupCode int64) (*GroupInfo, error) { // OidbSvc.0x88d_0 func (c *QQClient) buildGroupInfoRequestPacket(groupCode int64) (uint16, []byte) { body := &oidb.D88DReqBody{ - AppId: proto.Uint32(c.version.AppId), + AppId: proto.Uint32(c.version().AppId), ReqGroupInfo: []*oidb.ReqGroupInfo{ { GroupCode: proto.Uint64(uint64(groupCode)), diff --git a/client/internal/network/transport.go b/client/internal/network/transport.go index f258e4c0..3590d294 100644 --- a/client/internal/network/transport.go +++ b/client/internal/network/transport.go @@ -10,8 +10,8 @@ import ( // Transport is a network transport. type Transport struct { Sig *auth.SigInfo - Version **auth.AppVersion - Device **auth.Device + Version *auth.AppVersion + Device *auth.Device // connection // conn *TCPClient diff --git a/client/model_show.go b/client/model_show.go index dffae9e7..d8872df7 100644 --- a/client/model_show.go +++ b/client/model_show.go @@ -59,7 +59,7 @@ func (c *QQClient) GetModelShow(modelName string) ([]*ModelVariant, error) { Uin: c.Uin, Model: strings.ReplaceAll(url.QueryEscape(modelName), "+", "%20"), AppType: 0, - IMei: c.device.IMEI, + IMei: c.Device().IMEI, ShowInfo: true, ModelShow: "", RecoverDefault: false, @@ -96,7 +96,7 @@ func (c *QQClient) SetModelShow(modelName string, modelShow string) error { Uin: c.Uin, Model: strings.ReplaceAll(url.QueryEscape(modelName), "+", "%20"), AppType: 0, - IMei: c.device.IMEI, + IMei: c.Device().IMEI, ShowInfo: true, ModelShow: strings.ReplaceAll(url.QueryEscape(modelShow), "+", "%20"), RecoverDefault: modelShow == "", diff --git a/client/network.go b/client/network.go index 6b74d7e9..2b97050a 100644 --- a/client/network.go +++ b/client/network.go @@ -89,12 +89,12 @@ func (c *QQClient) ConnectionQualityTest() *ConnectionQualityInfo { } func (c *QQClient) initServers() { - if c.device == nil { + if c.Device() == nil { // must have device. Use c.UseDevice to set it! panic("client device is nil") } - sso, err := getSSOAddress(c.device) + sso, err := getSSOAddress(c.Device()) if err == nil && len(sso) > 0 { c.servers = append(sso, c.servers...) } diff --git a/client/qidian.go b/client/qidian.go index bc381fff..f4eb7139 100644 --- a/client/qidian.go +++ b/client/qidian.go @@ -30,7 +30,7 @@ func (c *QQClient) getQiDianAddressDetailList() ([]*FriendInfo, error) { SubCmd: proto.Uint32(33), CrmCommonHead: &cmd0x6ff.C519CRMMsgHead{ 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), LaborUin: proto.Uint64(uint64(c.Uin)), }, @@ -68,21 +68,21 @@ func (c *QQClient) buildLoginExtraPacket() (uint16, []byte) { SubCmd: proto.Uint32(69), CrmCommonHead: &cmd0x3f6.C3F6CRMMsgHead{ 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), }, SubcmdLoginProcessCompleteReqBody: &cmd0x3f6.QDUserLoginProcessCompleteReqBody{ Kfext: proto.Uint64(uint64(c.Uin)), - Pubno: proto.Some(c.version.AppId), - Buildno: proto.Uint32(uint32(utils.ConvertSubVersionToInt(c.version.SortVersionName))), + Pubno: proto.Some(c.version().AppId), + Buildno: proto.Uint32(uint32(utils.ConvertSubVersionToInt(c.version().SortVersionName))), TerminalType: proto.Uint32(2), Status: proto.Uint32(10), LoginTime: proto.Uint32(5), - HardwareInfo: proto.String(string(c.device.Model)), - SoftwareInfo: proto.String(string(c.device.Version.Release)), - Guid: c.device.Guid, - AppName: proto.Some(c.version.ApkId), - SubAppId: proto.Some(c.version.AppId), + HardwareInfo: proto.String(string(c.Device().Model)), + SoftwareInfo: proto.String(string(c.Device().Version.Release)), + Guid: c.Device().Guid, + AppName: proto.Some(c.version().ApkId), + SubAppId: proto.Some(c.version().AppId), }, } payload, _ := proto.Marshal(req) diff --git a/client/sync.go b/client/sync.go index 0b0d214a..7a5e46a6 100644 --- a/client/sync.go +++ b/client/sync.go @@ -121,7 +121,7 @@ func (c *QQClient) MarkPrivateMessageReaded(uin, time int64) { // StatSvc.GetDevLoginInfo func (c *QQClient) buildDeviceListRequestPacket() (uint16, []byte) { req := &jce.SvcReqGetDevLoginInfo{ - Guid: c.device.Guid, + Guid: c.Device().Guid, LoginType: 1, AppName: "com.tencent.mobileqq", RequireMax: 20, diff --git a/client/tlv_decoders.go b/client/tlv_decoders.go index fb01ef8c..200e5370 100644 --- a/client/tlv_decoders.go +++ b/client/tlv_decoders.go @@ -121,7 +121,7 @@ func (c *QQClient) decodeT119(data, ek []byte) { if len(decrypted) > 51+16 { dr := binary.NewReader(decrypted) dr.ReadBytes(51) - c.device.TgtgtKey = dr.ReadBytes(16) + c.Device().TgtgtKey = dr.ReadBytes(16) } } c.Nickname = nick @@ -131,7 +131,7 @@ func (c *QQClient) decodeT119(data, ek []byte) { // wtlogin.exchange_emp 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:]) if t120, ok := m[0x120]; ok { c.sig.SKey = t120 diff --git a/client/upload_file.go b/client/upload_file.go index 13291cac..cfd9d73a 100644 --- a/client/upload_file.go +++ b/client/upload_file.go @@ -105,7 +105,7 @@ func (c *QQClient) UploadFile(target message.Source, file *LocalFile) error { }, ClientInfo: &exciting.ExcitingClientInfo{ ClientType: proto.Int32(2), - AppId: proto.String(fmt.Sprint(c.version.AppId)), + AppId: proto.String(fmt.Sprint(c.version().AppId)), TerminalType: proto.Int32(2), ClientVer: proto.String("d92615c5"), Unknown: proto.Int32(4),