From 44679bebd44e279629de243abc79d8a60218a643 Mon Sep 17 00:00:00 2001 From: DrSmoothl <1787882683@qq.com> Date: Tue, 6 Oct 2026 15:20:24 +0800 Subject: [PATCH] fix(protocol): keep the highway upload address The session response address was discarded, so uploads used the default host. Fixes #513 --- .../core/tests/highway/highway-client.test.ts | 21 +++++++++++++++++++ packages/proto-defs/src/highway.ts | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/core/tests/highway/highway-client.test.ts b/packages/core/tests/highway/highway-client.test.ts index d187658f..aa1cf601 100644 --- a/packages/core/tests/highway/highway-client.test.ts +++ b/packages/core/tests/highway/highway-client.test.ts @@ -302,6 +302,27 @@ describe('fetchHighwaySession trace lifecycle', () => { } }); + it('keeps a server address encoded as a fixed 32-bit field', async () => { + // Address field 2 is four raw bytes. The fixture is not produced by the + // schema encoder, so a varint declaration cannot hide itself. + const responseData = Buffer.from('8a50150a02aabb1201cc1a0c08011208150102030418903f', 'hex'); + const bridge = { + identity: { uin: '10001' }, + sendRawPacket: vi.fn(async () => ({ + success: true, + gotResponse: true, + errorCode: 0, + errorMessage: '', + responseData, + })), + } as unknown as BridgeContext; + + const session = await fetchHighwaySession(bridge); + + expect(session.host).toBe('1.2.3.4'); + expect(session.port).toBe(8080); + }); + it('records a thrown control request as one failed terminal', async () => { const bridge = { identity: { uin: '10001' }, diff --git a/packages/proto-defs/src/highway.ts b/packages/proto-defs/src/highway.ts index ada14b96..795c7b31 100644 --- a/packages/proto-defs/src/highway.ts +++ b/packages/proto-defs/src/highway.ts @@ -1,4 +1,4 @@ -import type { pb, pb_repeated, int_32, uint_32, uint_64, bool, bytes } from '@snowluma/proton'; +import type { pb, pb_repeated, int_32, uint_32, uint_64, fixed_32, bool, bytes } from '@snowluma/proton'; import type { IndexNode, PictureInfo, @@ -185,7 +185,7 @@ export interface HttpConn0x6FF501Request { export interface ServerAddr { type?: pb<1, uint_32>; - ip?: pb<2, uint_32>; + ip?: pb<2, fixed_32>; port?: pb<3, uint_32>; area?: pb<4, uint_32>; }