feat(PortProxy): Enhance PortProxy to support domain-specific target IPs
This commit is contained in:
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartproxy',
|
||||
version: '3.4.4',
|
||||
version: '3.5.0',
|
||||
description: 'a proxy for handling high workloads of proxying'
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import * as plugins from './smartproxy.plugins.js';
|
||||
export interface DomainConfig {
|
||||
domain: string; // glob pattern for domain
|
||||
allowedIPs: string[]; // glob patterns for IPs allowed to access this domain
|
||||
targetIP?: string; // Optional target IP for this domain
|
||||
}
|
||||
|
||||
export interface ProxySettings extends plugins.tls.TlsOptions {
|
||||
@ -118,11 +119,15 @@ export class PortProxy {
|
||||
return;
|
||||
}
|
||||
|
||||
// Determine target host - use domain-specific targetIP if available
|
||||
const domainConfig = serverName ? findMatchingDomain(serverName) : undefined;
|
||||
const targetHost = domainConfig?.targetIP || this.settings.toHost!;
|
||||
|
||||
const to = plugins.net.createConnection({
|
||||
host: this.settings.toHost!,
|
||||
host: targetHost,
|
||||
port: this.settings.toPort,
|
||||
});
|
||||
console.log(`Connection established: ${remoteIP} -> ${this.settings.toHost}:${this.settings.toPort}${serverName ? ` (SNI: ${serverName})` : ''}`);
|
||||
console.log(`Connection established: ${remoteIP} -> ${targetHost}:${this.settings.toPort}${serverName ? ` (SNI: ${serverName})` : ''}`);
|
||||
from.setTimeout(120000);
|
||||
from.pipe(to);
|
||||
to.pipe(from);
|
||||
|
Reference in New Issue
Block a user