aboutsummaryrefslogtreecommitdiff
path: root/packages/bun-types/bun.d.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/bun-types/bun.d.ts')
-rw-r--r--packages/bun-types/bun.d.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts
index bd8b75023..a2ccebd8a 100644
--- a/packages/bun-types/bun.d.ts
+++ b/packages/bun-types/bun.d.ts
@@ -2196,6 +2196,21 @@ declare module "bun" {
tls?: TLSOptions;
}
+ export interface SocketAddress {
+ /**
+ * The IP address of the client.
+ */
+ address: string;
+ /**
+ * The port of the client.
+ */
+ port: number;
+ /**
+ * The IP family ("IPv4" or "IPv6").
+ */
+ family: "IPv4" | "IPv6";
+ }
+
/**
* HTTP & HTTPS Server
*
@@ -2344,6 +2359,24 @@ declare module "bun" {
): ServerWebSocketSendStatus;
/**
+ * Returns the client IP address of the given Request.
+ *
+ * @param request The incoming request
+ *
+ * @returns An ipv4/ipv6 address string, or null if it couldn't find one.
+ *
+ * @example
+ * ```js
+ * export default {
+ * async fetch(request, server) {
+ * return new Response(server.requestIP(request));
+ * }
+ * }
+ * ```
+ */
+ requestIP(request: Request): SocketAddress | null;
+
+ /**
* How many requests are in-flight right now?
*/
readonly pendingRequests: number;