fix(PortProxy): fixed import usage of net and tls libraries for PortProxy
This commit is contained in:
parent
23f61eb60b
commit
6c0c65bb1a
@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-02-21 - 3.3.1 - fix(PortProxy)
|
||||
fixed import usage of net and tls libraries for PortProxy
|
||||
|
||||
- Corrected the use of plugins for importing 'tls' and 'net' libraries in the PortProxy module.
|
||||
- Updated the constructor of PortProxy to accept combined tls options with ProxySettings.
|
||||
|
||||
## 2025-02-21 - 3.3.0 - feat(PortProxy)
|
||||
Enhanced PortProxy with domain and IP filtering, SNI support, and minimatch integration
|
||||
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartproxy',
|
||||
version: '3.3.0',
|
||||
version: '3.3.1',
|
||||
description: 'a proxy for handling high workloads of proxying'
|
||||
}
|
||||
|
@ -2,9 +2,10 @@
|
||||
import * as http from 'http';
|
||||
import * as https from 'https';
|
||||
import * as net from 'net';
|
||||
import * as tls from 'tls';
|
||||
import * as url from 'url';
|
||||
|
||||
export { http, https, net, url };
|
||||
export { http, https, net, tls, url };
|
||||
|
||||
// tsclass scope
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
@ -1,6 +1,4 @@
|
||||
import * as plugins from './smartproxy.plugins.js';
|
||||
import * as net from 'net';
|
||||
import * as tls from 'tls';
|
||||
|
||||
|
||||
export interface DomainConfig {
|
||||
@ -11,17 +9,17 @@ export interface DomainConfig {
|
||||
export interface ProxySettings {
|
||||
domains: DomainConfig[];
|
||||
sniEnabled?: boolean;
|
||||
tlsOptions?: tls.TlsOptions;
|
||||
tlsOptions?: plugins.tls.TlsOptions;
|
||||
defaultAllowedIPs?: string[]; // Optional default IP patterns if no matching domain found
|
||||
}
|
||||
|
||||
export class PortProxy {
|
||||
netServer: plugins.net.Server;
|
||||
netServer: plugins.net.Server | plugins.tls.Server;
|
||||
fromPort: number;
|
||||
toPort: number;
|
||||
settings: ProxySettings;
|
||||
|
||||
constructor(fromPortArg: number, toPortArg: number, settings: ProxySettings) {
|
||||
constructor(fromPortArg: number, toPortArg: number, settings: plugins.tls.TlsOptions & ProxySettings) {
|
||||
this.fromPort = fromPortArg;
|
||||
this.toPort = toPortArg;
|
||||
this.settings = settings;
|
||||
@ -46,11 +44,11 @@ export class PortProxy {
|
||||
return this.settings.domains.find(config => plugins.minimatch(serverName, config.domain));
|
||||
};
|
||||
|
||||
const server = this.settings.sniEnabled ? tls.createServer(this.settings.tlsOptions || {}) : net.createServer();
|
||||
const server = this.settings.sniEnabled ? plugins.tls.createServer(this.settings.tlsOptions || {}) : plugins.net.createServer();
|
||||
|
||||
this.netServer = server.on('connection', (from: net.Socket) => {
|
||||
this.netServer = server.on('connection', (from: plugins.net.Socket) => {
|
||||
const remoteIP = from.remoteAddress || '';
|
||||
if (this.settings.sniEnabled && from instanceof tls.TLSSocket) {
|
||||
if (this.settings.sniEnabled && from instanceof plugins.tls.TLSSocket) {
|
||||
const serverName = (from as any).servername || '';
|
||||
const domainConfig = findMatchingDomain(serverName);
|
||||
|
||||
@ -75,7 +73,7 @@ export class PortProxy {
|
||||
return;
|
||||
}
|
||||
|
||||
const to = net.createConnection({
|
||||
const to = plugins.net.createConnection({
|
||||
host: 'localhost',
|
||||
port: this.toPort,
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user