MCPcopy Index your code
hub / github.com/CodeGraphContext/CodeGraphContext / getClientIp

Function getClientIp

website/api/lib/security.js:29–41  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

27}
28
29function getClientIp(req) {
30 const forwardedFor = req?.headers?.["x-forwarded-for"];
31 if (typeof forwardedFor === "string" && forwardedFor.length > 0) {
32 return forwardedFor.split(",")[0].trim();
33 }
34
35 const realIp = req?.headers?.["x-real-ip"];
36 if (typeof realIp === "string" && realIp.length > 0) {
37 return realIp.trim();
38 }
39
40 return req?.socket?.remoteAddress || "unknown";
41}
42
43function cleanupExpiredEntries(now = Date.now()) {
44 const { windowMs } = getRateLimitConfig();

Callers 1

handlerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected