fix(protocol): decode numeric doubt request account fields
Linux doubt-request lists were returning the request time as the applicant account, so later uid lookup queried the wrong value. Decode the account, request time, and source group from the live list layout. Refs #460
This commit is contained in:
1 parent
6efadce2eb
commit
41b92263a7
5 files changed
+126
-26
No files matched your search
@@ -0,0 +1 @@
|
||||
08e91a22a60c080112a10c0a7e0880c2d72f12066e69636b3030180020fe012a056d73673030320851512067726f75703a1766696c746572656420667269656e6420726571756573744080c3bbc2064880cee4cd02500062006a30abc8a360ea075bcf8bbfa1e1e0e010beb1ac5228138eb82586704b41691e9efea640392a2a65e9dd50de82f154e0201b0a7d08c7aa9b3012066e69636b3031180020012a056d73673031320851512067726f75703a1766696c746572656420667269656e6420726571756573744080e6c0c206488dcee4cd02500162006a30ee591d017a9bb6807f7db7c8d3665e34923c7db6f6252d672a8f1f8986c7c9e3d21415ea86987a1b689c8d675d2a26800a7d088e93df3012066e69636b3032180020012a056d73673032320851512067726f75703a1766696c746572656420667269656e642072657175657374408089c6c206489acee4cd02500062006a305fe9e2cce8e6bc04c4f76fe8872347907e73a73b9184c3a7cbbd9c85a1d319c252129d950d06920d50732964df4afcf20a810108d5fba23112066e69636b3033180020ffffffff0f2a056d73673033320851512067726f75703a1766696c746572656420667269656e6420726571756573744080accbc20648a7cee4cd02500062006a3006b881debd01f92c98ef3c1726406ebeb88cae9d12d89e9fa36c20a77495dd0a3eb9fbbe7b14f65d657e979adfda5c600a7d089ce4e63112066e69636b3034180020012a056d73673034320851512067726f75703a1766696c746572656420667269656e6420726571756573744080cfd0c20648b4cee4cd02500062006a30316f76c654c33c8f6f3689a9475d8b871f74654789edb72d3f1a87bb1ba11cf07286b8d748f4d08d6fbe5afee8208e010a870108e3ccaa3212066e69636b3035185920ffffffff0f2a056d73673035320851512067726f75703a1766696c746572656420667269656e6420726571756573744080f2d5c20648c1cee4cd0250006206e4b89ce4baac6a30a3038a382c30ee6a8686410089e1c618f0b11bf92fdf2726da2910d2082a147a5569d04815e7c42287b424ef45b00ff70a860108aab5ee3212066e69636b3036180120002a056d73673036320851512067726f75703a1766696c746572656420667269656e642072657175657374408095dbc20648cecee4cd0250006209e7a59ee5a588e5b79d6a3097d6cc1f21ca290ab424147c3181e68490c49de47eda96eb422ec861eefdc8f580578655ac4f874ab7e8467cfc0e9fd30a810108f19db23312066e69636b3037180020ffffffff0f2a056d73673037320851512067726f75703a1766696c746572656420667269656e6420726571756573744080b8e0c20648dbcee4cd02500062006a303c1421acb295e3a5a4c914625ef1dbee99b552716ed28046cfa3b9171518dab5c247e0ddd3a24cb5f318a1cb60d6c9b30a810108b886f63312066e69636b3038180020ffffffff0f2a056d73673038320851512067726f75703a1766696c746572656420667269656e6420726571756573744080dbe5c20648e8cee4cd02500162006a3020ac3ddb705e3246f8fe7d266becea5bf92ec584a2cc12d4a83197d782047ca61d0ed90c5c4419e0866940f22a3eb1420a7d08ffeeb93412066e69636b3039180020012a056d73673039320851512067726f75703a1766696c746572656420667269656e6420726571756573744080feeac20648f5cee4cd02500162006a3047da9cf4f576624c5edd21b6bcfda8898c91143711f0bd251e00dfb1c273738290fa190cf6dc231c41dc31ad2086c6050a7d08c6d7fd3412066e69636b3130181420002a056d73673130320851512067726f75703a1766696c746572656420667269656e6420726571756573744080a1f0c2064882cfe4cd02500062006a300ab4598cfe36f3f340ec5237766213a06ddd99d900c3b3ac4d18530d4308f17943a22ef6b85d4d3f08086dcaf36465550a8401088dc0c13512066e69636b3131181220fe012a056d73673131320851512067726f75703a1766696c746572656420667269656e6420726571756573744080c4f5c206488fcfe4cd0250016206e697a0e994a16a3006e504c8f85b64fa8d5cb196d4b8cebc8098c752d879880bd8ab0108a829a1b29f952ff4e4b3807af4d54f70fb0dbf50
|
||||
@@ -1,10 +1,12 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbDoubtGetResp } from '@snowluma/proto-defs/oidb-actions/doubt-buddy';
|
||||
import type { SendPacketResult } from '@snowluma/common/packet-sender';
|
||||
import { GetDoubtBuddyReq } from '../../../src/oidb-services/friend/get-doubt-buddy-req';
|
||||
import { env, v, m } from '../_pb-oracle';
|
||||
import { env, v, s, m } from '../_pb-oracle';
|
||||
|
||||
function makeSender(): { sendRawPacket: ReturnType<typeof vi.fn> } {
|
||||
const respEnv: OidbBase<OidbDoubtGetResp> = {
|
||||
@@ -12,7 +14,7 @@ function makeSender(): { sendRawPacket: ReturnType<typeof vi.fn> } {
|
||||
body: { status: 1, body: { list: [
|
||||
{
|
||||
uid: 'u_alice', nick: 'Alice', source: '可能认识', reason: '',
|
||||
msg: 'hi', uin: 12345n, groupCode: '', reqTime: 1700000000n,
|
||||
msg: 'hi', reqTime: 1700000000n,
|
||||
},
|
||||
], reason: '' } },
|
||||
};
|
||||
@@ -46,11 +48,11 @@ describe('GetDoubtBuddyReq namespace', () => {
|
||||
expect(Buffer.from(bytes).toString('hex')).toBe(env(0xD69, 0, body, true));
|
||||
});
|
||||
|
||||
it('deserializes the item list to the OneBot shape (uid + reqTime high-confidence)', async () => {
|
||||
it('deserializes the string uid item to the OneBot shape', async () => {
|
||||
const list = await GetDoubtBuddyReq.invoke(makeSender(), { count: 10 });
|
||||
expect(list).toEqual([
|
||||
{
|
||||
uid: 'u_alice', user_id: 12345, nick: 'Alice', source: '可能认识',
|
||||
uid: 'u_alice', user_id: 0, nick: 'Alice', source: '可能认识',
|
||||
reason: '', msg: 'hi', group_code: '', reqTime: 1700000000,
|
||||
},
|
||||
]);
|
||||
@@ -73,16 +75,20 @@ describe('GetDoubtBuddyReq namespace', () => {
|
||||
});
|
||||
|
||||
it('keeps the uid string and does not reread it as the account number', async () => {
|
||||
const respEnv: OidbBase<OidbDoubtGetResp> = {
|
||||
command: 0xD69, subCommand: 0,
|
||||
body: { status: 1, body: { list: [
|
||||
{ uid: 'u_alice', nick: 'Alice', msg: 'hi', source: 'QQ号查找', reason: 'caution' },
|
||||
] } },
|
||||
};
|
||||
const item = [
|
||||
...s(1, 'u_alice'),
|
||||
...s(2, 'Alice'),
|
||||
...s(5, 'hi'),
|
||||
...s(6, 'QQ号查找'),
|
||||
...s(7, 'caution'),
|
||||
];
|
||||
const sender = {
|
||||
sendRawPacket: vi.fn(async () => ({
|
||||
success: true, gotResponse: true, errorCode: 0, errorMessage: '',
|
||||
responseData: Buffer.from(protobuf_encode<OidbBase<OidbDoubtGetResp>>(respEnv)),
|
||||
responseData: Buffer.from(env(0xD69, 0, [
|
||||
...v(1, 1),
|
||||
...m(2, m(1, item)),
|
||||
], false), 'hex'),
|
||||
})),
|
||||
};
|
||||
const list = await GetDoubtBuddyReq.invoke(sender, { count: 10 });
|
||||
@@ -93,4 +99,44 @@ describe('GetDoubtBuddyReq namespace', () => {
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
// Live capture from QQ 3.2.32-52194 on Linux. Locks the real wire shape:
|
||||
// tag1 is the applicant's account number (not a string uid), tag8 is the
|
||||
// request unix time, and tag9 is the source group. Before this, a tag8-as-uin
|
||||
// read made the uin->uid fallback query the request time as an account.
|
||||
it('decodes a captured Linux reply: account at tag1, time at tag8, group at tag9', () => {
|
||||
const hex = readFileSync(
|
||||
fileURLToPath(new URL('./fixtures/d69-linux-3.2.32.hex', import.meta.url)),
|
||||
'utf8',
|
||||
).trim();
|
||||
const list = GetDoubtBuddyReq.deserialize(
|
||||
{} as any,
|
||||
GetDoubtBuddyReq.decode(Buffer.from(hex, 'hex')).body!,
|
||||
);
|
||||
|
||||
expect(list).toHaveLength(12);
|
||||
expect(list[0]).toMatchObject({
|
||||
uid: '',
|
||||
user_id: 100000000,
|
||||
nick: 'nick00',
|
||||
source: 'QQ group',
|
||||
reason: 'filtered friend request',
|
||||
msg: 'msg00',
|
||||
group_code: '700000000',
|
||||
reqTime: 1750000000,
|
||||
});
|
||||
expect(list[1]).toMatchObject({
|
||||
uid: '',
|
||||
user_id: 101111111,
|
||||
group_code: '700000013',
|
||||
reqTime: 1750086400,
|
||||
});
|
||||
// Account numbers stay in the QQ range; request times land in 2025-2026.
|
||||
for (const item of list) {
|
||||
expect(item.user_id).toBeGreaterThan(100000);
|
||||
expect(item.user_id).toBeLessThan(4294967296);
|
||||
expect(item.reqTime).toBeGreaterThan(1700000000);
|
||||
expect(item.reqTime).toBeLessThan(2000000000);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user