From 8291f1f33a88601f3eb6eafcbafb717853f207e6 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sat, 3 May 2025 19:02:26 +0000 Subject: [PATCH] fix(tlsalert): Centralize plugin imports in TlsAlert and update plan checklist --- changelog.md | 7 +++++++ readme.plan.md | 2 +- ts/00_commitinfo_data.ts | 2 +- ts/smartproxy/classes.pp.tlsalert.ts | 14 +++++++------- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/changelog.md b/changelog.md index 0f563bd..8ec1cc0 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2025-05-03 - 10.0.2 - fix(tlsalert) +Centralize plugin imports in TlsAlert and update plan checklist + +- Mark the 'Centralize plugin imports in ts/plugins.ts' item as complete in readme.plan.md +- Replace direct 'net' imports with a centralized 'plugins' import in ts/smartproxy/classes.pp.tlsalert.ts +- Update all socket type references from net.Socket to plugins.net.Socket for consistency + ## 2025-05-03 - 10.0.1 - fix(docs) Improve mermaid diagram formatting in readme.md using HTML
tags for line breaks diff --git a/readme.plan.md b/readme.plan.md index 44a0f43..cef94a1 100644 --- a/readme.plan.md +++ b/readme.plan.md @@ -18,7 +18,7 @@ This document outlines a roadmap to simplify and refactor the SmartProxy & Netwo - [x] Unify configuration options: - [x] Merge `INetworkProxyOptions.acme`, `IPort80HandlerOptions`, and `port80HandlerConfig` into one schema - [x] Deprecate old option names and provide clear upgrade path -- [ ] Centralize plugin imports in `ts/plugins.ts` and update all modules to use it +- [x] Centralize plugin imports in `ts/plugins.ts` and update all modules to use it - [x] Remove legacy or unused code paths (e.g., old HTTP/2 fallback logic if obsolete) - [ ] Enhance and expand test coverage: - Add unit tests for certificate issuance, renewal, and error handling diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 9ccf083..c3d7151 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartproxy', - version: '10.0.1', + version: '10.0.2', description: 'A powerful proxy package that effectively handles high traffic, with features such as SSL/TLS support, port proxying, WebSocket handling, dynamic routing with authentication options, and automatic ACME certificate management.' } diff --git a/ts/smartproxy/classes.pp.tlsalert.ts b/ts/smartproxy/classes.pp.tlsalert.ts index 34ef2ed..fa448a3 100644 --- a/ts/smartproxy/classes.pp.tlsalert.ts +++ b/ts/smartproxy/classes.pp.tlsalert.ts @@ -1,4 +1,4 @@ -import * as net from 'net'; +import * as plugins from '../plugins.js'; /** * TlsAlert class for managing TLS alert messages @@ -99,7 +99,7 @@ export class TlsAlert { * @returns Promise that resolves when the alert has been sent */ static async send( - socket: net.Socket, + socket: plugins.net.Socket, level: number, description: number, closeAfterSend: boolean = false, @@ -183,7 +183,7 @@ export class TlsAlert { * @param socket The socket to send the alert to * @returns Promise that resolves when the alert has been sent */ - static async sendSniRequired(socket: net.Socket): Promise { + static async sendSniRequired(socket: plugins.net.Socket): Promise { return this.send(socket, this.LEVEL_WARNING, this.UNRECOGNIZED_NAME); } @@ -194,7 +194,7 @@ export class TlsAlert { * @param closeDelay Milliseconds to wait before closing the connection (default: 200ms) * @returns Promise that resolves when the alert has been sent and the connection closed */ - static async sendCloseNotify(socket: net.Socket, closeDelay: number = 200): Promise { + static async sendCloseNotify(socket: plugins.net.Socket, closeDelay: number = 200): Promise { return this.send(socket, this.LEVEL_WARNING, this.CLOSE_NOTIFY, true, closeDelay); } @@ -208,7 +208,7 @@ export class TlsAlert { * @returns Promise that resolves when the alert has been sent */ static async sendCertificateExpired( - socket: net.Socket, + socket: plugins.net.Socket, fatal: boolean = false, closeAfterSend: boolean = true, closeDelay: number = 200 @@ -224,7 +224,7 @@ export class TlsAlert { * @param socket The socket to send the alerts to * @returns Promise that resolves when all alerts have been sent */ - static async sendForceSniSequence(socket: net.Socket): Promise { + static async sendForceSniSequence(socket: plugins.net.Socket): Promise { try { // Send unrecognized_name (warning) socket.cork(); @@ -249,7 +249,7 @@ export class TlsAlert { * @returns Promise that resolves when the alert has been sent and the connection closed */ static async sendFatalAndClose( - socket: net.Socket, + socket: plugins.net.Socket, description: number, closeDelay: number = 100 ): Promise {