fix(smartproxy): Improve port binding intelligence and ACME challenge route management; update route configuration tests and dependency versions.

This commit is contained in:
2025-05-28 19:58:28 +00:00
parent 4ebaf6c061
commit 742adc2bd9
17 changed files with 948 additions and 1258 deletions

View File

@ -8,9 +8,23 @@ tap.test('should detect and forward non-TLS connections on HttpProxy ports', asy
let forwardedToHttpProxy = false;
let connectionPath = '';
// Mock the HttpProxy forwarding
const originalForward = SmartProxy.prototype['httpProxyBridge'].prototype.forwardToHttpProxy;
SmartProxy.prototype['httpProxyBridge'].prototype.forwardToHttpProxy = function(...args: any[]) {
// Create a SmartProxy instance first
const proxy = new SmartProxy({
useHttpProxy: [8080],
httpProxyPort: 8844,
routes: [{
name: 'test-http-forward',
match: { ports: 8080 },
action: {
type: 'forward',
target: { host: 'localhost', port: 8181 }
}
}]
});
// Mock the HttpProxy forwarding on the instance
const originalForward = (proxy as any).httpProxyBridge.forwardToHttpProxy;
(proxy as any).httpProxyBridge.forwardToHttpProxy = async function(...args: any[]) {
forwardedToHttpProxy = true;
connectionPath = 'httpproxy';
console.log('Mock: Connection forwarded to HttpProxy');
@ -18,22 +32,8 @@ tap.test('should detect and forward non-TLS connections on HttpProxy ports', asy
args[1].end(); // socket.end()
};
// Create a SmartProxy with useHttpProxy configured
const proxy = new SmartProxy({
useHttpProxy: [8080],
httpProxyPort: 8844,
enableDetailedLogging: true,
routes: [{
name: 'test-route',
match: {
ports: 8080
},
action: {
type: 'forward',
target: { host: 'localhost', port: 8181 }
}
}]
});
// Add detailed logging to the existing proxy instance
proxy.settings.enableDetailedLogging = true;
// Override the HttpProxy initialization to avoid actual HttpProxy setup
proxy['httpProxyBridge'].getHttpProxy = () => ({} as any);
@ -65,7 +65,8 @@ tap.test('should detect and forward non-TLS connections on HttpProxy ports', asy
await proxy.stop();
// Restore original method
SmartProxy.prototype['httpProxyBridge'].prototype.forwardToHttpProxy = originalForward;
// Restore original method
(proxy as any).httpProxyBridge.forwardToHttpProxy = originalForward;
});
// Test that verifies the fix detects non-TLS connections