BREAKING CHANGE(forwarding): Refactor unified forwarding API and remove redundant documentation. Removed docs/forwarding-system.md (its content is migrated into readme.md) and updated helper functions (e.g. replacing sniPassthrough with httpsPassthrough) to accept configuration objects. Legacy fields in domain configurations (allowedIPs, blockedIPs, useNetworkProxy, networkProxyPort, connectionTimeout) have been removed in favor of forwarding.security and advanced options. Tests and examples have been updated accordingly.
This commit is contained in:
@ -279,14 +279,21 @@ tap.test('should support optional source IP preservation in chained proxies', as
|
||||
if (index4 !== -1) allProxies.splice(index4, 1);
|
||||
});
|
||||
|
||||
// Test round-robin behavior for multiple target IPs in a domain config.
|
||||
tap.test('should use round robin for multiple target IPs in domain config', async () => {
|
||||
// Test round-robin behavior for multiple target hosts in a domain config.
|
||||
tap.test('should use round robin for multiple target hosts in domain config', async () => {
|
||||
// Create a domain config with multiple hosts in the target
|
||||
const domainConfig = {
|
||||
domains: ['rr.test'],
|
||||
allowedIPs: ['127.0.0.1'],
|
||||
targetIPs: ['hostA', 'hostB']
|
||||
} as any;
|
||||
|
||||
forwarding: {
|
||||
type: 'http-only',
|
||||
target: {
|
||||
host: ['hostA', 'hostB'], // Array of hosts for round-robin
|
||||
port: 80
|
||||
},
|
||||
http: { enabled: true }
|
||||
}
|
||||
};
|
||||
|
||||
const proxyInstance = new SmartProxy({
|
||||
fromPort: 0,
|
||||
toPort: 0,
|
||||
@ -296,11 +303,14 @@ tap.test('should use round robin for multiple target IPs in domain config', asyn
|
||||
defaultAllowedIPs: [],
|
||||
globalPortRanges: []
|
||||
});
|
||||
|
||||
|
||||
// Don't track this proxy as it doesn't actually start or listen
|
||||
|
||||
const firstTarget = proxyInstance.domainConfigManager.getTargetIP(domainConfig);
|
||||
const secondTarget = proxyInstance.domainConfigManager.getTargetIP(domainConfig);
|
||||
|
||||
// Get the first target host from the forwarding config
|
||||
const firstTarget = proxyInstance.domainConfigManager.getTargetHost(domainConfig);
|
||||
// Get the second target host - should be different due to round-robin
|
||||
const secondTarget = proxyInstance.domainConfigManager.getTargetHost(domainConfig);
|
||||
|
||||
expect(firstTarget).toEqual('hostA');
|
||||
expect(secondTarget).toEqual('hostB');
|
||||
});
|
||||
|
Reference in New Issue
Block a user