fix(protocol): keep the highway upload address

The session response address was discarded, so uploads used the default host.

Fixes #513
This commit is contained in:
DrSmoothl
2026-10-06 15:20:24 +08:00
parent f95d247e73
commit 44679bebd4
2 changed files with 23 additions and 2 deletions
@@ -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' },
+2 -2
View File
@@ -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>;
}