This document outlines a plan to consolidate duplicate and inconsistent interfaces in the SmartProxy codebase, specifically the `IRouteSecurity` interface which is defined twice with different properties. This inconsistency caused issues with security checks for port forwarding. The goal is to unify these interfaces, use consistent property naming, and improve code maintainability.
## Problem Description
We currently have two separate `IRouteSecurity` interfaces defined in `ts/proxies/smart-proxy/models/route-types.ts`:
1.**First definition** (lines 116-122) - Used in IRouteAction:
```typescript
export interface IRouteSecurity {
allowedIps?: string[];
blockedIps?: string[];
maxConnections?: number;
authentication?: IRouteAuthentication;
}
```
2.**Second definition** (lines 253-272) - Used directly in IRouteConfig:
```typescript
export interface IRouteSecurity {
rateLimit?: IRouteRateLimit;
basicAuth?: {...};
jwtAuth?: {...};
ipAllowList?: string[];
ipBlockList?: string[];
}
```
This duplication with inconsistent naming (`allowedIps` vs `ipAllowList` and `blockedIps` vs `ipBlockList`) caused routing issues when IP security checks were used, as we had to implement a workaround to check both property names.
## Implementation Plan
### Phase 1: Interface Consolidation
1.**Create a unified interface definition:**
- Create one comprehensive `IRouteSecurity` interface that includes all properties
- Use consistent property naming (standardize on `ipAllowList` and `ipBlockList`)
- Add proper documentation for each property
- Remove the duplicate interface definition
2.**Update references to use the unified interface:**
- Update all code that references the old interface properties
- Update all configurations to use the new property names
- Ensure implementation in `route-manager.ts` uses the correct property names
### Phase 2: Code and Documentation Updates
1.**Update type usages and documentation:**
- Update all code that creates or uses security configurations
- Update documentation to reflect the new interface structure
- Add examples of the correct property usage
- Document the breaking change in changelog.md
2.**Add tests:**
- Update existing tests to use the new property names
- Add test cases for all security configuration scenarios
- Verify that port range configurations with security settings work correctly