update
This commit is contained in:
@@ -478,16 +478,16 @@ const domainRouter = (socket: net.Socket, context: IRouteContext) => {
|
||||
## Detailed Implementation Tasks
|
||||
|
||||
### Step 1: Update TSocketHandler Type (15 minutes)
|
||||
- [ ] Open `ts/proxies/smart-proxy/models/route-types.ts`
|
||||
- [ ] Find line 14: `export type TSocketHandler = (socket: plugins.net.Socket) => void | Promise<void>;`
|
||||
- [ ] Import IRouteContext at top of file: `import type { IRouteContext } from '../../../core/models/route-context.js';`
|
||||
- [ ] Update TSocketHandler to: `export type TSocketHandler = (socket: plugins.net.Socket, context: IRouteContext) => void | Promise<void>;`
|
||||
- [ ] Save file
|
||||
- [x] Open `ts/proxies/smart-proxy/models/route-types.ts`
|
||||
- [x] Find line 14: `export type TSocketHandler = (socket: plugins.net.Socket) => void | Promise<void>;`
|
||||
- [x] Import IRouteContext at top of file: `import type { IRouteContext } from '../../../core/models/route-context.js';`
|
||||
- [x] Update TSocketHandler to: `export type TSocketHandler = (socket: plugins.net.Socket, context: IRouteContext) => void | Promise<void>;`
|
||||
- [x] Save file
|
||||
|
||||
### Step 2: Update Socket Handler Implementation (30 minutes)
|
||||
- [ ] Open `ts/proxies/smart-proxy/route-connection-handler.ts`
|
||||
- [ ] Find `handleSocketHandlerAction` method (around line 790)
|
||||
- [ ] Add route context creation after line 809:
|
||||
- [x] Open `ts/proxies/smart-proxy/route-connection-handler.ts`
|
||||
- [x] Find `handleSocketHandlerAction` method (around line 790)
|
||||
- [x] Add route context creation after line 809:
|
||||
```typescript
|
||||
// Create route context for the handler
|
||||
const routeContext = this.createRouteContext({
|
||||
@@ -502,19 +502,19 @@ const domainRouter = (socket: net.Socket, context: IRouteContext) => {
|
||||
routeId: route.id,
|
||||
});
|
||||
```
|
||||
- [ ] Update line 812 from `const result = route.action.socketHandler(socket);`
|
||||
- [ ] To: `const result = route.action.socketHandler(socket, routeContext);`
|
||||
- [ ] Save file
|
||||
- [x] Update line 812 from `const result = route.action.socketHandler(socket);`
|
||||
- [x] To: `const result = route.action.socketHandler(socket, routeContext);`
|
||||
- [x] Save file
|
||||
|
||||
### Step 3: Update Existing Socket Handlers in route-helpers.ts (20 minutes)
|
||||
- [ ] Open `ts/proxies/smart-proxy/utils/route-helpers.ts`
|
||||
- [ ] Update `echo` handler (line 856):
|
||||
- [x] Open `ts/proxies/smart-proxy/utils/route-helpers.ts`
|
||||
- [x] Update `echo` handler (line 856):
|
||||
- From: `echo: (socket: plugins.net.Socket) => {`
|
||||
- To: `echo: (socket: plugins.net.Socket, context: IRouteContext) => {`
|
||||
- [ ] Update `proxy` handler (line 864):
|
||||
- [x] Update `proxy` handler (line 864):
|
||||
- From: `proxy: (targetHost: string, targetPort: number) => (socket: plugins.net.Socket) => {`
|
||||
- To: `proxy: (targetHost: string, targetPort: number) => (socket: plugins.net.Socket, context: IRouteContext) => {`
|
||||
- [ ] Update `lineProtocol` handler (line 879):
|
||||
- [x] Update `lineProtocol` handler (line 879):
|
||||
- From: `lineProtocol: (handler: (line: string, socket: plugins.net.Socket) => void) => (socket: plugins.net.Socket) => {`
|
||||
- To: `lineProtocol: (handler: (line: string, socket: plugins.net.Socket) => void) => (socket: plugins.net.Socket, context: IRouteContext) => {`
|
||||
- [ ] Update `httpResponse` handler (line 896):
|
||||
@@ -635,11 +635,11 @@ const domainRouter = (socket: net.Socket, context: IRouteContext) => {
|
||||
});
|
||||
}
|
||||
```
|
||||
- [ ] Save file
|
||||
- [x] Save file
|
||||
|
||||
### Step 9: Update Helper Functions (20 minutes)
|
||||
- [ ] Still in `route-helpers.ts`
|
||||
- [ ] Update `createHttpToHttpsRedirect` function (around line 109):
|
||||
- [x] Still in `route-helpers.ts`
|
||||
- [x] Update `createHttpToHttpsRedirect` function (around line 109):
|
||||
- Change the action to use socket handler:
|
||||
```typescript
|
||||
action: {
|
||||
@@ -647,8 +647,8 @@ const domainRouter = (socket: net.Socket, context: IRouteContext) => {
|
||||
socketHandler: SocketHandlers.httpRedirect(`https://{domain}:${httpsPort}{path}`, 301)
|
||||
}
|
||||
```
|
||||
- [ ] Delete entire `createStaticFileRoute` function (lines 277-322)
|
||||
- [ ] Save file
|
||||
- [x] Delete entire `createStaticFileRoute` function (lines 277-322)
|
||||
- [x] Save file
|
||||
|
||||
### Step 10: Update Test Files (1.5 hours)
|
||||
#### 10.1 Update Socket Handler Tests
|
||||
|
||||
Reference in New Issue
Block a user