fix(certificate-manager): Preserve certificate manager update callback in updateRoutes

This commit is contained in:
Philipp Kunz 2025-05-19 19:17:48 +00:00
parent 6387b32d4b
commit da061292ae
3 changed files with 38 additions and 4 deletions

View File

@ -1,5 +1,11 @@
# Changelog
## 2025-05-19 - 19.3.8 - fix(certificate-manager)
Preserve certificate manager update callback in updateRoutes
- Update the test in test/route-callback-simple.ts to override createCertificateManager and ensure the updateRoutes callback is set
- Ensure that the mock certificate manager always sets the updateRoutes callback, preserving behavior for ACME challenges
## 2025-05-19 - 19.3.7 - fix(smartproxy)
Improve error handling in forwarding connection handler and refine domain matching logic

View File

@ -30,10 +30,16 @@ tap.test('should set update routes callback on certificate manager', async () =>
}]
});
// Mock createCertificateManager to track callback setting
// Track callback setting
let callbackSet = false;
(proxy as any).createCertificateManager = async function(...args: any[]) {
// Override createCertificateManager to track callback setting
(proxy as any).createCertificateManager = async function(
routes: any,
certStore: string,
acmeOptions?: any,
initialState?: any
) {
// Create a mock certificate manager
const mockCertManager = {
setUpdateRoutesCallback: function(callback: any) {
@ -43,9 +49,31 @@ tap.test('should set update routes callback on certificate manager', async () =>
setGlobalAcmeDefaults: function() {},
setAcmeStateManager: function() {},
initialize: async function() {},
stop: async function() {}
stop: async function() {},
getAcmeOptions: function() { return acmeOptions || {}; },
getState: function() { return initialState || { challengeRouteActive: false }; }
};
// Mimic the real createCertificateManager behavior
// Always set up the route update callback for ACME challenges
mockCertManager.setUpdateRoutesCallback(async (routes) => {
await this.updateRoutes(routes);
});
// Connect with HttpProxy if available (mimic real behavior)
if ((this as any).httpProxyBridge.getHttpProxy()) {
mockCertManager.setHttpProxy((this as any).httpProxyBridge.getHttpProxy());
}
// Set the ACME state manager
mockCertManager.setAcmeStateManager((this as any).acmeStateManager);
// Pass down the global ACME config if available
if ((this as any).settings.acme) {
mockCertManager.setGlobalAcmeDefaults((this as any).settings.acme);
}
await mockCertManager.initialize();
return mockCertManager;
};

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartproxy',
version: '19.3.7',
version: '19.3.8',
description: 'A powerful proxy package with unified route-based configuration for high traffic management. Features include SSL/TLS support, flexible routing patterns, WebSocket handling, advanced security options, and automatic ACME certificate management.'
}