update
This commit is contained in:
@@ -18,29 +18,29 @@ Implement enhanced routing structure with multiple targets per route, sub-matchi
|
||||
### 3. Implementation Steps
|
||||
|
||||
#### Phase 1: Type Updates
|
||||
- [ ] Update `IRouteTarget` interface in `route-types.ts`
|
||||
- [x] Update `IRouteTarget` interface in `route-types.ts`
|
||||
- Add `match?: ITargetMatch` property
|
||||
- Add override properties (tls, websocket, etc.)
|
||||
- Add `priority?: number` field
|
||||
- [ ] Create `ITargetMatch` interface for sub-matching criteria
|
||||
- [ ] Update `IRouteAction` to use only `targets: IRouteTarget[]`
|
||||
- [x] Create `ITargetMatch` interface for sub-matching criteria
|
||||
- [x] Update `IRouteAction` to use only `targets: IRouteTarget[]`
|
||||
|
||||
#### Phase 2: Route Resolution Logic
|
||||
- [ ] Update route matching logic to handle multiple targets
|
||||
- [ ] Implement target sub-matching algorithm:
|
||||
- [x] Update route matching logic to handle multiple targets
|
||||
- [x] Implement target sub-matching algorithm:
|
||||
1. Sort targets by priority (highest first)
|
||||
2. For each target with a match property, check if request matches
|
||||
3. Use first matching target, or fallback to target without match
|
||||
- [ ] Ensure target-specific settings override route-level settings
|
||||
- [x] Ensure target-specific settings override route-level settings
|
||||
|
||||
#### Phase 3: Code Migration
|
||||
- [ ] Find all occurrences of `action.target` and update to `action.targets[0]`
|
||||
- [ ] Update route helpers and utilities
|
||||
- [ ] Update certificate manager to handle multiple targets
|
||||
- [ ] Update connection handlers
|
||||
- [x] Find all occurrences of `action.target` and update to use `action.targets`
|
||||
- [x] Update route helpers and utilities
|
||||
- [x] Update certificate manager to handle multiple targets
|
||||
- [x] Update connection handlers
|
||||
|
||||
#### Phase 4: Testing
|
||||
- [ ] Update existing tests to use new format
|
||||
- [x] Update existing tests to use new format
|
||||
- [ ] Add tests for multi-target scenarios
|
||||
- [ ] Add tests for sub-matching logic
|
||||
- [ ] Add tests for setting overrides
|
||||
|
@@ -82,7 +82,7 @@ tap.test('Route-level connection limits', async () => {
|
||||
const route: IRouteConfig = {
|
||||
name: 'test-route',
|
||||
match: { ports: 443 },
|
||||
action: { type: 'forward', target: { host: 'localhost', port: 8080 } },
|
||||
action: { type: 'forward', targets: [{ host: 'localhost', port: 8080 }] },
|
||||
security: {
|
||||
maxConnections: 3
|
||||
}
|
||||
|
@@ -400,9 +400,9 @@ tap.test('should use round robin for multiple target hosts in domain config', as
|
||||
|
||||
// For route-based approach, the actual round-robin logic happens in connection handling
|
||||
// Just make sure our config has the expected hosts
|
||||
expect(Array.isArray(routeConfig.action.target.host)).toBeTrue();
|
||||
expect(routeConfig.action.target.host).toContain('hostA');
|
||||
expect(routeConfig.action.target.host).toContain('hostB');
|
||||
expect(Array.isArray(routeConfig.action.targets[0].host)).toBeTrue();
|
||||
expect(routeConfig.action.targets[0].host).toContain('hostA');
|
||||
expect(routeConfig.action.targets[0].host).toContain('hostB');
|
||||
});
|
||||
|
||||
// CLEANUP: Tear down all servers and proxies
|
||||
|
@@ -247,7 +247,8 @@ export interface IRouteAction {
|
||||
type: TRouteActionType;
|
||||
|
||||
// Targets for forwarding (array supports multiple targets with sub-matching)
|
||||
targets: IRouteTarget[];
|
||||
// Required for 'forward' action type
|
||||
targets?: IRouteTarget[];
|
||||
|
||||
// TLS handling (default for all targets, can be overridden per target)
|
||||
tls?: IRouteTls;
|
||||
|
@@ -922,7 +922,7 @@ export class RouteConnectionHandler {
|
||||
routeContext.targetHost = selectedHost;
|
||||
|
||||
// Get effective settings (target overrides route-level settings)
|
||||
const effectiveTls = selectedTarget.tls || effectiveTls;
|
||||
const effectiveTls = selectedTarget.tls || action.tls;
|
||||
const effectiveWebsocket = selectedTarget.websocket || action.websocket;
|
||||
const effectiveSendProxyProtocol = selectedTarget.sendProxyProtocol !== undefined
|
||||
? selectedTarget.sendProxyProtocol
|
||||
|
@@ -42,7 +42,7 @@ export function createHttpRoute(
|
||||
// Create route action
|
||||
const action: IRouteAction = {
|
||||
type: 'forward',
|
||||
target
|
||||
targets: [target]
|
||||
};
|
||||
|
||||
// Create the route config
|
||||
@@ -82,7 +82,7 @@ export function createHttpsTerminateRoute(
|
||||
// Create route action
|
||||
const action: IRouteAction = {
|
||||
type: 'forward',
|
||||
target,
|
||||
targets: [target],
|
||||
tls: {
|
||||
mode: options.reencrypt ? 'terminate-and-reencrypt' : 'terminate',
|
||||
certificate: options.certificate || 'auto'
|
||||
@@ -152,7 +152,7 @@ export function createHttpsPassthroughRoute(
|
||||
// Create route action
|
||||
const action: IRouteAction = {
|
||||
type: 'forward',
|
||||
target,
|
||||
targets: [target],
|
||||
tls: {
|
||||
mode: 'passthrough'
|
||||
}
|
||||
@@ -243,7 +243,7 @@ export function createLoadBalancerRoute(
|
||||
// Create route action
|
||||
const action: IRouteAction = {
|
||||
type: 'forward',
|
||||
target
|
||||
targets: [target]
|
||||
};
|
||||
|
||||
// Add TLS configuration if provided
|
||||
@@ -303,7 +303,7 @@ export function createApiRoute(
|
||||
// Create route action
|
||||
const action: IRouteAction = {
|
||||
type: 'forward',
|
||||
target
|
||||
targets: [target]
|
||||
};
|
||||
|
||||
// Add TLS configuration if using HTTPS
|
||||
@@ -374,7 +374,7 @@ export function createWebSocketRoute(
|
||||
// Create route action
|
||||
const action: IRouteAction = {
|
||||
type: 'forward',
|
||||
target,
|
||||
targets: [target],
|
||||
websocket: {
|
||||
enabled: true,
|
||||
pingInterval: options.pingInterval || 30000, // 30 seconds
|
||||
@@ -432,10 +432,10 @@ export function createPortMappingRoute(options: {
|
||||
// Create route action
|
||||
const action: IRouteAction = {
|
||||
type: 'forward',
|
||||
target: {
|
||||
targets: [{
|
||||
host: options.targetHost,
|
||||
port: options.portMapper
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
// Create the route config
|
||||
@@ -500,10 +500,10 @@ export function createDynamicRoute(options: {
|
||||
// Create route action
|
||||
const action: IRouteAction = {
|
||||
type: 'forward',
|
||||
target: {
|
||||
targets: [{
|
||||
host: options.targetHost,
|
||||
port: options.portMapper
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
// Create the route config
|
||||
@@ -548,10 +548,10 @@ export function createSmartLoadBalancer(options: {
|
||||
// Create route action
|
||||
const action: IRouteAction = {
|
||||
type: 'forward',
|
||||
target: {
|
||||
targets: [{
|
||||
host: hostSelector,
|
||||
port: options.portMapper
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
// Create the route config
|
||||
@@ -609,10 +609,10 @@ export function createNfTablesRoute(
|
||||
// Create route action
|
||||
const action: IRouteAction = {
|
||||
type: 'forward',
|
||||
target: {
|
||||
targets: [{
|
||||
host: target.host,
|
||||
port: target.port
|
||||
},
|
||||
}],
|
||||
forwardingEngine: 'nftables',
|
||||
nftables: {
|
||||
protocol: options.protocol || 'tcp',
|
||||
|
@@ -24,10 +24,10 @@ export function createHttpRoute(
|
||||
},
|
||||
action: {
|
||||
type: 'forward',
|
||||
target: {
|
||||
targets: [{
|
||||
host: target.host,
|
||||
port: target.port
|
||||
}
|
||||
}]
|
||||
},
|
||||
name: options.name || `HTTP: ${Array.isArray(domains) ? domains.join(', ') : domains}`
|
||||
};
|
||||
@@ -53,10 +53,10 @@ export function createHttpsTerminateRoute(
|
||||
},
|
||||
action: {
|
||||
type: 'forward',
|
||||
target: {
|
||||
targets: [{
|
||||
host: target.host,
|
||||
port: target.port
|
||||
},
|
||||
}],
|
||||
tls: {
|
||||
mode: options.reencrypt ? 'terminate-and-reencrypt' : 'terminate',
|
||||
certificate: options.certificate || 'auto'
|
||||
@@ -83,10 +83,10 @@ export function createHttpsPassthroughRoute(
|
||||
},
|
||||
action: {
|
||||
type: 'forward',
|
||||
target: {
|
||||
targets: [{
|
||||
host: target.host,
|
||||
port: target.port
|
||||
},
|
||||
}],
|
||||
tls: {
|
||||
mode: 'passthrough'
|
||||
}
|
||||
|
Reference in New Issue
Block a user