Skip to content

Commit a06bf5c

Browse files
authored
New sign (#170)
* fix: 更新签名 * fix: 修复一些bug * lint
1 parent 587d226 commit a06bf5c

11 files changed

Lines changed: 81 additions & 210 deletions

File tree

client/auth/app.go

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ var AppList = map[string]map[string]*AppInfo{
2121
PackageSign: "V1_LNX_NQ_3.1.2-13107_RDM_B",
2222
AppID: 1600001615,
2323
SubAppID: 537146866,
24-
AppIDQrcode: 13697054,
2524
AppClientVersion: 13172,
2625

2726
MainSigmap: 169742560,
@@ -44,7 +43,6 @@ var AppList = map[string]map[string]*AppInfo{
4443
PackageSign: "V1_LNX_NQ_3.2.10_25765_GW_B",
4544
AppID: 1600001615,
4645
SubAppID: 537234773,
47-
AppIDQrcode: 13697054,
4846
AppClientVersion: 13172,
4947

5048
MainSigmap: 169742560,
@@ -67,7 +65,6 @@ var AppList = map[string]map[string]*AppInfo{
6765
PackageSign: "V1_LNX_NQ_3.2.12_27597_GW_B",
6866
AppID: 1600001615,
6967
SubAppID: 537243600,
70-
AppIDQrcode: 13697054,
7168
AppClientVersion: 13172,
7269

7370
MainSigmap: 169742560,
@@ -90,7 +87,6 @@ var AppList = map[string]map[string]*AppInfo{
9087
PackageSign: "V1_LNX_NQ_3.2.15_30366_GW_B",
9188
AppID: 1600001615,
9289
SubAppID: 537258424,
93-
AppIDQrcode: 13697054,
9490
AppClientVersion: 30366,
9591

9692
MainSigmap: 169742560,
@@ -110,14 +106,35 @@ var AppList = map[string]map[string]*AppInfo{
110106
PTOSVersion: 19,
111107
PackageName: "com.tencent.qq",
112108
WTLoginSDK: "nt.wtlogin.0.0.1",
109+
PackageSign: "V1_LNX_NQ_3.2.19-39038_GW_B",
113110
AppID: 1600001615,
114111
SubAppID: 537313942,
115-
AppIDQrcode: 537313942,
116112
AppClientVersion: 39038,
117113
MainSigmap: 169742560,
118114
SubSigmap: 0,
119115
NTLoginType: 1,
120116
},
117+
118+
"3.2.26-46494": {
119+
OS: "Linux",
120+
Kernel: "Linux",
121+
VendorOS: "linux",
122+
123+
CurrentVersion: "3.2.26-46494",
124+
BuildVersion: 46494,
125+
MiscBitmap: 32764,
126+
PTVersion: "2.0.0",
127+
PTOSVersion: 19,
128+
PackageName: "com.tencent.qq",
129+
WTLoginSDK: "nt.wtlogin.0.0.1",
130+
PackageSign: "V1_LNX_NQ_3.2.26-46494_GW_B",
131+
AppID: 1600001615,
132+
SubAppID: 537345891,
133+
AppClientVersion: 46494,
134+
MainSigmap: 169742560,
135+
SubSigmap: 0,
136+
NTLoginType: 1,
137+
},
121138
},
122139

123140
"macos": {
@@ -136,7 +153,6 @@ var AppList = map[string]map[string]*AppInfo{
136153
PackageSign: "V1_MAC_NQ_6.9.20-17153_RDM_B",
137154
AppID: 1600001602,
138155
SubAppID: 537162356,
139-
AppIDQrcode: 537162356,
140156
AppClientVersion: 13172,
141157

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

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

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

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

235247
MainSigmap: 169742560,
@@ -254,7 +266,6 @@ type AppInfo struct {
254266
PackageSign string `json:"package_sign"`
255267
AppID int `json:"app_id"`
256268
SubAppID int `json:"sub_app_id"`
257-
AppIDQrcode int `json:"app_id_qrcode"`
258269
AppClientVersion int `json:"app_client_version"`
259270
MainSigmap int `json:"main_sigmap"`
260271
SubSigmap int `json:"sub_sigmap"`

client/base.go

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -129,36 +129,21 @@ type QQClient struct {
129129
DisconnectedEvent EventHandle[*DisconnectedEvent]
130130
}
131131

132-
// AddSignServer 设置签名服务器url
133-
func (c *QQClient) AddSignServer(signServers ...string) {
134-
if c.signProvider == nil {
135-
c.UseSignProvider(sign.NewSigner(c.debug))
136-
}
137-
c.signProvider.AddSignServer(signServers...)
138-
}
139-
140-
// GetSignServer 获得所有签名服务器
141-
func (c *QQClient) GetSignServer() []string {
142-
return c.signProvider.GetSignServer()
143-
}
144-
145132
// AddSignHeader 设置签名服务器签名时的额外http header
146133
func (c *QQClient) AddSignHeader(header map[string]string) {
147-
if c.signProvider == nil {
148-
c.UseSignProvider(sign.NewSigner(c.debug))
134+
if c.signProvider != nil {
135+
c.signProvider.AddRequestHeader(header)
149136
}
150-
c.signProvider.AddRequestHeader(header)
151137
}
152138

153139
func (c *QQClient) UseVersion(app *auth.AppInfo) {
154140
c.transport.Version = app
155141
c.highwaySession.AppID = uint32(app.AppID)
156142
c.highwaySession.SubAppID = uint32(app.SubAppID)
157143
c.UA = "LagrangeGo qq/" + app.PackageSign
158-
if c.signProvider == nil {
159-
c.signProvider = sign.NewSigner(c.debug)
144+
if c.signProvider != nil {
145+
c.signProvider.SetAppInfo(app)
160146
}
161-
c.signProvider.SetAppInfo(app)
162147
}
163148

164149
func (c *QQClient) UseSignProvider(p sign.Provider) {

client/cache.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
package client
22

33
import (
4-
"strconv"
54
"time"
65

76
"github.com/LagrangeDev/LagrangeGo/client/entity"
87
)
98

10-
var selfUin string
11-
129
// GetUID 获取缓存中对应uin的uid
1310
func (c *QQClient) GetUID(uin uint32, groupUin ...uint32) string {
1411
if uin == 0 {
1512
return ""
1613
}
17-
if uin == c.Uin {
18-
if selfUin == "" {
19-
selfUin = strconv.FormatUint(uint64(uin), 10)
20-
}
21-
return selfUin
22-
}
2314
if len(groupUin) == 0 && c.cache.FriendCacheIsEmpty() {
2415
if err := c.RefreshFriendCache(); err != nil {
2516
return ""

client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (c *QQClient) FetchQRCode(size, margin, ecLevel uint32) ([]byte, string, er
7979
WriteU64(0).
8080
WriteU8(0).
8181
WriteTLV(
82-
tlv.T16(c.Version().AppID, c.Version().AppIDQrcode,
82+
tlv.T16(c.Version().AppID, c.Version().SubAppID,
8383
lgrio.MustParseHexStr(c.Device().GUID), c.Version().PTVersion, c.Version().PackageName),
8484
tlv.T1b(0, 0, size, margin, 72, ecLevel, 2),
8585
tlv.T1d(c.Version().MiscBitmap),

client/internal/network/transport.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ func (t *Transport) PackPacket(req *Request) []byte {
3030
if req.Sign != nil {
3131
sign := req.Sign.Value
3232
head[24] = proto.DynamicMessage{
33-
1: []byte(sign.Sign),
34-
2: []byte(sign.Token),
35-
3: []byte(sign.Extra),
33+
1: []byte(sign.SecSign),
34+
2: []byte(sign.SecToken),
35+
3: []byte(sign.SecExtra),
3636
}
3737
}
3838

client/packet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
func (c *QQClient) uniPacket(command string, body []byte) (uint32, []byte, error) {
1010
seq := c.getAndIncreaseSequence()
11-
sign, err := c.signProvider.Sign(command, seq, body)
11+
sign, err := c.signProvider.Sign(command, seq, body, c.Uin, c.Device().GUID, c.Version().PackageSign)
1212
if err != nil {
1313
return 0, nil, err
1414
}

client/packets/tlv/qrcode.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ func T11(unusualSign []byte) []byte {
1111
Pack(0x11)
1212
}
1313

14-
func T16(appid, appidQrcode int, guid []byte, ptVersion, packageName string) []byte {
14+
func T16(appid, subappid int, guid []byte, ptVersion, packageName string) []byte {
1515
return binary.NewBuilder().
1616
WriteU32(0).
1717
WriteU32(uint32(appid)).
18-
WriteU32(uint32(appidQrcode)).
18+
WriteU32(uint32(subappid)).
1919
WriteBytes(guid).
2020
WritePacketString(packageName, "u16", false).
2121
WritePacketString(ptVersion, "u16", false).

client/sign/http.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -71,33 +71,6 @@ func ContainSignPKG(cmd string) bool {
7171
return ok
7272
}
7373

74-
func httpGet[T any](rawURL string, queryParams map[string]string, timeout time.Duration, header http.Header) (target T, err error) {
75-
u, err := url.Parse(rawURL)
76-
if err != nil {
77-
return
78-
}
79-
80-
q := u.Query()
81-
for k, v := range queryParams {
82-
q.Set(k, v)
83-
}
84-
u.RawQuery = q.Encode()
85-
86-
ctx, cancel := context.WithTimeout(context.Background(), timeout)
87-
defer cancel()
88-
89-
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
90-
if err != nil {
91-
return
92-
}
93-
for k, vs := range header {
94-
for _, v := range vs {
95-
req.Header.Add(k, v)
96-
}
97-
}
98-
return doHTTP[T](ctx, req)
99-
}
100-
10174
func httpPost[T any](rawURL string, body io.Reader, timeout time.Duration, header http.Header) (target T, err error) {
10275
u, err := url.Parse(rawURL)
10376
if err != nil {

client/sign/provider.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,21 @@ type (
1111
HexData []byte
1212

1313
Request struct {
14-
Cmd string `json:"cmd"`
15-
Seq int `json:"seq"`
16-
Src HexData `json:"src"`
14+
Command string `json:"command"`
15+
Seq int `json:"seq"`
16+
Body HexData `json:"body"`
17+
Uin uint32 `json:"uin"`
18+
GUID string `json:"guid"`
19+
Qua string `json:"qua"`
1720
}
1821

1922
Response struct {
20-
Platform string `json:"platform"`
21-
Version string `json:"version"`
22-
Value struct {
23-
Sign HexData `json:"sign"`
24-
Extra HexData `json:"extra"`
25-
Token HexData `json:"token"`
23+
Code uint32 `json:"code"`
24+
Message string `json:"message"`
25+
Value struct {
26+
SecSign HexData `json:"sec_sign"`
27+
SecToken HexData `json:"sec_token"`
28+
SecExtra HexData `json:"sec_extra"`
2629
} `json:"value"`
2730
}
2831
)
@@ -45,10 +48,8 @@ func (h *HexData) UnmarshalJSON(data []byte) error {
4548
}
4649

4750
type Provider interface {
48-
Sign(cmd string, seq uint32, data []byte) (*Response, error)
51+
Sign(cmd string, seq uint32, data []byte, uin uint32, guid, qua string) (*Response, error)
4952
AddRequestHeader(header map[string]string)
50-
AddSignServer(signServers ...string)
51-
GetSignServer() []string
5253
SetAppInfo(app *auth.AppInfo)
5354
Release()
5455
}

0 commit comments

Comments
 (0)