feat(PortProxy): Add feature to preserve original client IP through chained proxies

This commit is contained in:
2025-02-21 19:39:52 +00:00
parent 8cb8fa1a52
commit c77b31b72c
4 changed files with 40 additions and 1 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartproxy',
version: '3.5.0',
version: '3.6.0',
description: 'a proxy for handling high workloads of proxying'
}

View File

@ -123,9 +123,11 @@ export class PortProxy {
const domainConfig = serverName ? findMatchingDomain(serverName) : undefined;
const targetHost = domainConfig?.targetIP || this.settings.toHost!;
// Create connection with IP binding to preserve original client IP
const to = plugins.net.createConnection({
host: targetHost,
port: this.settings.toPort,
localAddress: remoteIP.replace('::ffff:', ''), // Remove IPv6 mapping if present
});
console.log(`Connection established: ${remoteIP} -> ${targetHost}:${this.settings.toPort}${serverName ? ` (SNI: ${serverName})` : ''}`);
from.setTimeout(120000);