MCPcopy Index your code
hub / github.com/tinyhttp/tinyhttp / getIP

Function getIP

packages/app/src/request.ts:58–59  ·  view source on GitHub ↗
(req: Pick<IncomingMessage, 'headers' | 'connection'>)

Source from the content-addressed store, hash-verified

56}
57
58export const getIP = (req: Pick<IncomingMessage, 'headers' | 'connection'>): string | undefined =>
59 proxyAddr(req, trustRemoteAddress(req)).replace(/^.*:/, '') // striping the redundant prefix addeded by OS to IPv4 address
60
61export const getIPs = (req: Pick<IncomingMessage, 'headers' | 'connection'>): string[] | undefined =>
62 all(req, trustRemoteAddress(req))

Callers 1

extendMiddlewareFunction · 0.90

Calls 1

trustRemoteAddressFunction · 0.85

Tested by

no test coverage detected