fix(plugins): Simplified plugin import structure across codebase
This commit is contained in:
@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-02-21 - 3.8.1 - fix(plugins)
|
||||||
|
Simplified plugin import structure across codebase
|
||||||
|
|
||||||
|
- Consolidated plugin imports under a single 'plugins.ts' file.
|
||||||
|
- Replaced individual plugin imports in smartproxy files with the consolidated plugin imports.
|
||||||
|
- Fixed error handling for early socket errors in PortProxy setup.
|
||||||
|
|
||||||
## 2025-02-21 - 3.8.0 - feat(PortProxy)
|
## 2025-02-21 - 3.8.0 - feat(PortProxy)
|
||||||
Add active connection tracking and logging in PortProxy
|
Add active connection tracking and logging in PortProxy
|
||||||
|
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartproxy',
|
name: '@push.rocks/smartproxy',
|
||||||
version: '3.8.0',
|
version: '3.8.1',
|
||||||
description: 'a proxy for handling high workloads of proxying'
|
description: 'a proxy for handling high workloads of proxying'
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './smartproxy.plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
import { ProxyRouter } from './smartproxy.classes.router.js';
|
import { ProxyRouter } from './smartproxy.classes.router.js';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './smartproxy.plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
export class ProxyRouter {
|
export class ProxyRouter {
|
||||||
public reverseProxyConfigs: plugins.tsclass.network.IReverseProxyConfig[] = [];
|
public reverseProxyConfigs: plugins.tsclass.network.IReverseProxyConfig[] = [];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './smartproxy.plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
export class SslRedirect {
|
export class SslRedirect {
|
||||||
httpServer: plugins.http.Server;
|
httpServer: plugins.http.Server;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './smartproxy.plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
export interface IDomainConfig {
|
export interface IDomainConfig {
|
||||||
domain: string; // glob pattern for domain
|
domain: string; // glob pattern for domain
|
||||||
@ -167,7 +167,19 @@ export class PortProxy {
|
|||||||
// Create a plain net server for TLS passthrough.
|
// Create a plain net server for TLS passthrough.
|
||||||
this.netServer = plugins.net.createServer((socket: plugins.net.Socket) => {
|
this.netServer = plugins.net.createServer((socket: plugins.net.Socket) => {
|
||||||
const remoteIP = socket.remoteAddress || '';
|
const remoteIP = socket.remoteAddress || '';
|
||||||
|
|
||||||
|
// Flag to detect if we've received the first data chunk.
|
||||||
|
let initialDataReceived = false;
|
||||||
|
|
||||||
|
// Immediately attach an error handler to catch early errors.
|
||||||
|
socket.on('error', (err: Error) => {
|
||||||
|
if (!initialDataReceived) {
|
||||||
|
console.log(`(Premature) Incoming socket error from ${remoteIP} before data received: ${err.message}`);
|
||||||
|
} else {
|
||||||
|
console.log(`(Immediate) Incoming socket error from ${remoteIP}: ${err.message}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Track the new incoming connection.
|
// Track the new incoming connection.
|
||||||
this.activeConnections.add(socket);
|
this.activeConnections.add(socket);
|
||||||
console.log(`New connection from ${remoteIP}. Active connections: ${this.activeConnections.size}`);
|
console.log(`New connection from ${remoteIP}. Active connections: ${this.activeConnections.size}`);
|
||||||
@ -265,6 +277,7 @@ export class PortProxy {
|
|||||||
// For SNI-enabled connections, peek at the first chunk.
|
// For SNI-enabled connections, peek at the first chunk.
|
||||||
if (this.settings.sniEnabled) {
|
if (this.settings.sniEnabled) {
|
||||||
socket.once('data', (chunk: Buffer) => {
|
socket.once('data', (chunk: Buffer) => {
|
||||||
|
initialDataReceived = true;
|
||||||
// Try to extract the server name from the ClientHello.
|
// Try to extract the server name from the ClientHello.
|
||||||
const serverName = extractSNI(chunk) || '';
|
const serverName = extractSNI(chunk) || '';
|
||||||
console.log(`Received connection from ${remoteIP} with SNI: ${serverName}`);
|
console.log(`Received connection from ${remoteIP} with SNI: ${serverName}`);
|
||||||
@ -272,6 +285,7 @@ export class PortProxy {
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// For non-SNI connections, simply check defaultAllowedIPs.
|
// For non-SNI connections, simply check defaultAllowedIPs.
|
||||||
|
initialDataReceived = true;
|
||||||
if (!this.settings.defaultAllowedIPs || !isAllowed(remoteIP, this.settings.defaultAllowedIPs)) {
|
if (!this.settings.defaultAllowedIPs || !isAllowed(remoteIP, this.settings.defaultAllowedIPs)) {
|
||||||
console.log(`Connection rejected: IP ${remoteIP} not allowed for non-SNI connection`);
|
console.log(`Connection rejected: IP ${remoteIP} not allowed for non-SNI connection`);
|
||||||
socket.end();
|
socket.end();
|
||||||
|
Reference in New Issue
Block a user