feat(PortProxy): Add feature to preserve original client IP through chained proxies
This commit is contained in:
@ -175,6 +175,37 @@ tap.test('should stop port proxy', async () => {
|
||||
});
|
||||
|
||||
// Cleanup
|
||||
tap.test('should preserve client IP through chained proxies', async () => {
|
||||
// Create two proxies in chain
|
||||
const firstProxy = new PortProxy({
|
||||
fromPort: PROXY_PORT + 4,
|
||||
toPort: PROXY_PORT + 5, // Point to second proxy
|
||||
toHost: 'localhost',
|
||||
domains: [],
|
||||
sniEnabled: false,
|
||||
defaultAllowedIPs: ['127.0.0.1']
|
||||
});
|
||||
|
||||
const secondProxy = new PortProxy({
|
||||
fromPort: PROXY_PORT + 5,
|
||||
toPort: TEST_SERVER_PORT,
|
||||
toHost: 'localhost',
|
||||
domains: [],
|
||||
sniEnabled: false,
|
||||
defaultAllowedIPs: ['127.0.0.1']
|
||||
});
|
||||
|
||||
await secondProxy.start();
|
||||
await firstProxy.start();
|
||||
|
||||
// Connect through the chain
|
||||
const response = await createTestClient(PROXY_PORT + 4, TEST_DATA);
|
||||
expect(response).toEqual(`Echo: ${TEST_DATA}`);
|
||||
|
||||
await firstProxy.stop();
|
||||
await secondProxy.stop();
|
||||
});
|
||||
|
||||
tap.test('cleanup port proxy test environment', async () => {
|
||||
await new Promise<void>((resolve) => testServer.close(() => resolve()));
|
||||
});
|
||||
|
Reference in New Issue
Block a user