Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions client/auth/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ var AppList = map[string]map[string]*AppInfo{
PackageSign: "V1_LNX_NQ_3.1.2-13107_RDM_B",
AppID: 1600001615,
SubAppID: 537146866,
AppIDQrcode: 13697054,
AppClientVersion: 13172,

MainSigmap: 169742560,
Expand All @@ -44,7 +43,6 @@ var AppList = map[string]map[string]*AppInfo{
PackageSign: "V1_LNX_NQ_3.2.10_25765_GW_B",
AppID: 1600001615,
SubAppID: 537234773,
AppIDQrcode: 13697054,
AppClientVersion: 13172,

MainSigmap: 169742560,
Expand All @@ -67,7 +65,6 @@ var AppList = map[string]map[string]*AppInfo{
PackageSign: "V1_LNX_NQ_3.2.12_27597_GW_B",
AppID: 1600001615,
SubAppID: 537243600,
AppIDQrcode: 13697054,
AppClientVersion: 13172,

MainSigmap: 169742560,
Expand All @@ -90,7 +87,6 @@ var AppList = map[string]map[string]*AppInfo{
PackageSign: "V1_LNX_NQ_3.2.15_30366_GW_B",
AppID: 1600001615,
SubAppID: 537258424,
AppIDQrcode: 13697054,
AppClientVersion: 30366,

MainSigmap: 169742560,
Expand All @@ -110,14 +106,35 @@ var AppList = map[string]map[string]*AppInfo{
PTOSVersion: 19,
PackageName: "com.tencent.qq",
WTLoginSDK: "nt.wtlogin.0.0.1",
PackageSign: "V1_LNX_NQ_3.2.19-39038_GW_B",
AppID: 1600001615,
SubAppID: 537313942,
AppIDQrcode: 537313942,
AppClientVersion: 39038,
MainSigmap: 169742560,
SubSigmap: 0,
NTLoginType: 1,
},

"3.2.26-46494": {
OS: "Linux",
Kernel: "Linux",
VendorOS: "linux",

CurrentVersion: "3.2.26-46494",
BuildVersion: 46494,
MiscBitmap: 32764,
PTVersion: "2.0.0",
PTOSVersion: 19,
PackageName: "com.tencent.qq",
WTLoginSDK: "nt.wtlogin.0.0.1",
PackageSign: "V1_LNX_NQ_3.2.26-46494_GW_B",
AppID: 1600001615,
SubAppID: 537345891,
AppClientVersion: 46494,
MainSigmap: 169742560,
SubSigmap: 0,
NTLoginType: 1,
},
},

"macos": {
Expand All @@ -136,7 +153,6 @@ var AppList = map[string]map[string]*AppInfo{
PackageSign: "V1_MAC_NQ_6.9.20-17153_RDM_B",
AppID: 1600001602,
SubAppID: 537162356,
AppIDQrcode: 537162356,
AppClientVersion: 13172,

MainSigmap: 169742560,
Expand All @@ -160,7 +176,6 @@ var AppList = map[string]map[string]*AppInfo{
PackageSign: "V1_WIN_NQ_9.9.12-25493_GW_B",
AppID: 1600001604,
SubAppID: 537231759,
AppIDQrcode: 537138217,
AppClientVersion: 13172,

MainSigmap: 169742560,
Expand All @@ -183,7 +198,6 @@ var AppList = map[string]map[string]*AppInfo{
PackageSign: "V1_WIN_NQ_9.9.12-25765_GW_B",
AppID: 1600001604,
SubAppID: 537234702,
AppIDQrcode: 537138217,
AppClientVersion: 13172,

MainSigmap: 169742560,
Expand All @@ -206,7 +220,6 @@ var AppList = map[string]map[string]*AppInfo{
PackageSign: "V1_WIN_NQ_9.9.15-27597_GW_B",
AppID: 1600001604,
SubAppID: 537243441,
AppIDQrcode: 537138217,
AppClientVersion: 13172,

MainSigmap: 169742560,
Expand All @@ -229,7 +242,6 @@ var AppList = map[string]map[string]*AppInfo{
PackageSign: "V1_WIN_NQ_9.9.15-28060_GW_B",
AppID: 1600001604,
SubAppID: 537246092,
AppIDQrcode: 537138217,
AppClientVersion: 13172,

MainSigmap: 169742560,
Expand All @@ -254,7 +266,6 @@ type AppInfo struct {
PackageSign string `json:"package_sign"`
AppID int `json:"app_id"`
SubAppID int `json:"sub_app_id"`
AppIDQrcode int `json:"app_id_qrcode"`
AppClientVersion int `json:"app_client_version"`
MainSigmap int `json:"main_sigmap"`
SubSigmap int `json:"sub_sigmap"`
Expand Down
23 changes: 4 additions & 19 deletions client/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,36 +129,21 @@ type QQClient struct {
DisconnectedEvent EventHandle[*DisconnectedEvent]
}

// AddSignServer 设置签名服务器url
func (c *QQClient) AddSignServer(signServers ...string) {
if c.signProvider == nil {
c.UseSignProvider(sign.NewSigner(c.debug))
}
c.signProvider.AddSignServer(signServers...)
}

// GetSignServer 获得所有签名服务器
func (c *QQClient) GetSignServer() []string {
return c.signProvider.GetSignServer()
}

// AddSignHeader 设置签名服务器签名时的额外http header
func (c *QQClient) AddSignHeader(header map[string]string) {
if c.signProvider == nil {
c.UseSignProvider(sign.NewSigner(c.debug))
if c.signProvider != nil {
c.signProvider.AddRequestHeader(header)
}
c.signProvider.AddRequestHeader(header)
}

func (c *QQClient) UseVersion(app *auth.AppInfo) {
c.transport.Version = app
c.highwaySession.AppID = uint32(app.AppID)
c.highwaySession.SubAppID = uint32(app.SubAppID)
c.UA = "LagrangeGo qq/" + app.PackageSign
if c.signProvider == nil {
c.signProvider = sign.NewSigner(c.debug)
if c.signProvider != nil {
c.signProvider.SetAppInfo(app)
}
c.signProvider.SetAppInfo(app)
}

func (c *QQClient) UseSignProvider(p sign.Provider) {
Expand Down
9 changes: 0 additions & 9 deletions client/cache.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
package client

import (
"strconv"
"time"

"github.com/LagrangeDev/LagrangeGo/client/entity"
)

var selfUin string

// GetUID 获取缓存中对应uin的uid
func (c *QQClient) GetUID(uin uint32, groupUin ...uint32) string {
if uin == 0 {
return ""
}
if uin == c.Uin {
if selfUin == "" {
selfUin = strconv.FormatUint(uint64(uin), 10)
}
return selfUin
}
if len(groupUin) == 0 && c.cache.FriendCacheIsEmpty() {
if err := c.RefreshFriendCache(); err != nil {
return ""
Expand Down
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (c *QQClient) FetchQRCode(size, margin, ecLevel uint32) ([]byte, string, er
WriteU64(0).
WriteU8(0).
WriteTLV(
tlv.T16(c.Version().AppID, c.Version().AppIDQrcode,
tlv.T16(c.Version().AppID, c.Version().SubAppID,
lgrio.MustParseHexStr(c.Device().GUID), c.Version().PTVersion, c.Version().PackageName),
tlv.T1b(0, 0, size, margin, 72, ecLevel, 2),
tlv.T1d(c.Version().MiscBitmap),
Expand Down
6 changes: 3 additions & 3 deletions client/internal/network/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ func (t *Transport) PackPacket(req *Request) []byte {
if req.Sign != nil {
sign := req.Sign.Value
head[24] = proto.DynamicMessage{
1: []byte(sign.Sign),
2: []byte(sign.Token),
3: []byte(sign.Extra),
1: []byte(sign.SecSign),
2: []byte(sign.SecToken),
3: []byte(sign.SecExtra),
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func (c *QQClient) uniPacket(command string, body []byte) (uint32, []byte, error) {
seq := c.getAndIncreaseSequence()
sign, err := c.signProvider.Sign(command, seq, body)
sign, err := c.signProvider.Sign(command, seq, body, c.Uin, c.Device().GUID, c.Version().PackageSign)
if err != nil {
return 0, nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions client/packets/tlv/qrcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ func T11(unusualSign []byte) []byte {
Pack(0x11)
}

func T16(appid, appidQrcode int, guid []byte, ptVersion, packageName string) []byte {
func T16(appid, subappid int, guid []byte, ptVersion, packageName string) []byte {
return binary.NewBuilder().
WriteU32(0).
WriteU32(uint32(appid)).
WriteU32(uint32(appidQrcode)).
WriteU32(uint32(subappid)).
WriteBytes(guid).
WritePacketString(packageName, "u16", false).
WritePacketString(ptVersion, "u16", false).
Expand Down
27 changes: 0 additions & 27 deletions client/sign/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,33 +71,6 @@ func ContainSignPKG(cmd string) bool {
return ok
}

func httpGet[T any](rawURL string, queryParams map[string]string, timeout time.Duration, header http.Header) (target T, err error) {
u, err := url.Parse(rawURL)
if err != nil {
return
}

q := u.Query()
for k, v := range queryParams {
q.Set(k, v)
}
u.RawQuery = q.Encode()

ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()

req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
if err != nil {
return
}
for k, vs := range header {
for _, v := range vs {
req.Header.Add(k, v)
}
}
return doHTTP[T](ctx, req)
}

func httpPost[T any](rawURL string, body io.Reader, timeout time.Duration, header http.Header) (target T, err error) {
u, err := url.Parse(rawURL)
if err != nil {
Expand Down
25 changes: 13 additions & 12 deletions client/sign/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ type (
HexData []byte

Request struct {
Cmd string `json:"cmd"`
Seq int `json:"seq"`
Src HexData `json:"src"`
Command string `json:"command"`
Seq int `json:"seq"`
Body HexData `json:"body"`
Uin uint32 `json:"uin"`
GUID string `json:"guid"`
Qua string `json:"qua"`
}

Response struct {
Platform string `json:"platform"`
Version string `json:"version"`
Value struct {
Sign HexData `json:"sign"`
Extra HexData `json:"extra"`
Token HexData `json:"token"`
Code uint32 `json:"code"`
Message string `json:"message"`
Value struct {
SecSign HexData `json:"sec_sign"`
SecToken HexData `json:"sec_token"`
SecExtra HexData `json:"sec_extra"`
} `json:"value"`
}
)
Expand All @@ -45,10 +48,8 @@ func (h *HexData) UnmarshalJSON(data []byte) error {
}

type Provider interface {
Sign(cmd string, seq uint32, data []byte) (*Response, error)
Sign(cmd string, seq uint32, data []byte, uin uint32, guid, qua string) (*Response, error)
AddRequestHeader(header map[string]string)
AddSignServer(signServers ...string)
GetSignServer() []string
SetAppInfo(app *auth.AppInfo)
Release()
}
Loading
Loading