Skip to content

Commit e3aa8d7

Browse files
committed
Update remove getWebSocketClientIp function
1 parent 3e47845 commit e3aa8d7

File tree

1 file changed

+1
-28
lines changed

1 file changed

+1
-28
lines changed

packages/core/src/index.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type {
1414
Server,
1515
WebSocketData,
1616
} from "./types";
17-
import type { ServerWebSocket } from "bun";
17+
1818
/**
1919
* Runtime detection utilities for identifying the current JavaScript runtime environment.
2020
* @internal
@@ -2202,33 +2202,6 @@ export class Web<T extends Record<string, unknown> = Record<string, unknown>, B
22022202
}
22032203
}
22042204

2205-
/**
2206-
* Helper function to get the real client IP from a WebSocket connection.
2207-
* Use this instead of ws.remoteAddress to get the real client IP when behind proxies.
2208-
*
2209-
* @param ws - The WebSocket connection
2210-
* @returns The client IP address or undefined
2211-
*
2212-
* @example
2213-
* ```typescript
2214-
* import { getWebSocketClientIp } from "@rabbit-company/web";
2215-
*
2216-
* app.websocket({
2217-
* open(ws) {
2218-
* const ip = getWebSocketClientIp(ws);
2219-
* console.log(`Client connected from: ${ip}`);
2220-
* },
2221-
* message(ws, message) {
2222-
* const ip = getWebSocketClientIp(ws);
2223-
* console.log(`Message from ${ip}: ${message}`);
2224-
* }
2225-
* });
2226-
* ```
2227-
*/
2228-
export function getWebSocketClientIp<D extends Record<string, unknown> = Record<string, unknown>>(ws: ServerWebSocket<WebSocketData<D>>): string | undefined {
2229-
return ws.data?.clientIp;
2230-
}
2231-
22322205
/**
22332206
* Extracts the static prefix from a path pattern by finding the longest initial segment
22342207
* that doesn't contain parameters (:) or wildcards (*). Used for quick middleware filtering.

0 commit comments

Comments
 (0)