update
This commit is contained in:
@ -5,7 +5,7 @@ import type { TForwardingType } from '../../../forwarding/config/forwarding-type
|
||||
/**
|
||||
* Supported action types for route configurations
|
||||
*/
|
||||
export type TRouteActionType = 'forward' | 'redirect' | 'block';
|
||||
export type TRouteActionType = 'forward' | 'redirect' | 'block' | 'static';
|
||||
|
||||
/**
|
||||
* TLS handling modes for route configurations
|
||||
@ -31,6 +31,7 @@ export interface IRouteMatch {
|
||||
path?: string; // Match specific paths
|
||||
clientIp?: string[]; // Match specific client IPs
|
||||
tlsVersion?: string[]; // Match specific TLS versions
|
||||
headers?: Record<string, string | RegExp>; // Match specific HTTP headers
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,7 +95,10 @@ export interface IRouteSecurity {
|
||||
* Static file server configuration
|
||||
*/
|
||||
export interface IRouteStaticFiles {
|
||||
directory: string;
|
||||
root: string;
|
||||
index?: string[];
|
||||
headers?: Record<string, string>;
|
||||
directory?: string;
|
||||
indexFiles?: string[];
|
||||
cacheControl?: string;
|
||||
expires?: number;
|
||||
@ -123,6 +127,30 @@ export interface IRouteAdvanced {
|
||||
// Additional advanced options would go here
|
||||
}
|
||||
|
||||
/**
|
||||
* WebSocket configuration
|
||||
*/
|
||||
export interface IRouteWebSocket {
|
||||
enabled: boolean;
|
||||
pingInterval?: number;
|
||||
pingTimeout?: number;
|
||||
maxPayloadSize?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load balancing configuration
|
||||
*/
|
||||
export interface IRouteLoadBalancing {
|
||||
algorithm: 'round-robin' | 'least-connections' | 'ip-hash';
|
||||
healthCheck?: {
|
||||
path: string;
|
||||
interval: number;
|
||||
timeout: number;
|
||||
unhealthyThreshold: number;
|
||||
healthyThreshold: number;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Action configuration for route handling
|
||||
*/
|
||||
@ -139,6 +167,15 @@ export interface IRouteAction {
|
||||
// For redirects
|
||||
redirect?: IRouteRedirect;
|
||||
|
||||
// For static files
|
||||
static?: IRouteStaticFiles;
|
||||
|
||||
// WebSocket support
|
||||
websocket?: IRouteWebSocket;
|
||||
|
||||
// Load balancing options
|
||||
loadBalancing?: IRouteLoadBalancing;
|
||||
|
||||
// Security options
|
||||
security?: IRouteSecurity;
|
||||
|
||||
@ -146,21 +183,75 @@ export interface IRouteAction {
|
||||
advanced?: IRouteAdvanced;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rate limiting configuration
|
||||
*/
|
||||
export interface IRouteRateLimit {
|
||||
enabled: boolean;
|
||||
maxRequests: number;
|
||||
window: number; // Time window in seconds
|
||||
keyBy?: 'ip' | 'path' | 'header';
|
||||
headerName?: string;
|
||||
errorMessage?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Security features for routes
|
||||
*/
|
||||
export interface IRouteSecurity {
|
||||
rateLimit?: IRouteRateLimit;
|
||||
basicAuth?: {
|
||||
enabled: boolean;
|
||||
users: Array<{ username: string; password: string }>;
|
||||
realm?: string;
|
||||
excludePaths?: string[];
|
||||
};
|
||||
jwtAuth?: {
|
||||
enabled: boolean;
|
||||
secret: string;
|
||||
algorithm?: string;
|
||||
issuer?: string;
|
||||
audience?: string;
|
||||
expiresIn?: number;
|
||||
excludePaths?: string[];
|
||||
};
|
||||
ipAllowList?: string[];
|
||||
ipBlockList?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Headers configuration
|
||||
*/
|
||||
export interface IRouteHeaders {
|
||||
request?: Record<string, string>;
|
||||
response?: Record<string, string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The core unified configuration interface
|
||||
*/
|
||||
export interface IRouteConfig {
|
||||
// Unique identifier
|
||||
id?: string;
|
||||
|
||||
// What to match
|
||||
match: IRouteMatch;
|
||||
|
||||
// What to do with matched traffic
|
||||
action: IRouteAction;
|
||||
|
||||
// Custom headers
|
||||
headers?: IRouteHeaders;
|
||||
|
||||
// Security features
|
||||
security?: IRouteSecurity;
|
||||
|
||||
// Optional metadata
|
||||
name?: string; // Human-readable name for this route
|
||||
description?: string; // Description of the route's purpose
|
||||
priority?: number; // Controls matching order (higher = matched first)
|
||||
tags?: string[]; // Arbitrary tags for categorization
|
||||
enabled?: boolean; // Whether the route is active (default: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user