-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathrequest-ip.node.txt
27 lines (23 loc) · 1.76 KB
/
request-ip.node.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
┏━━━━━━━━━━━━━━━━┓
┃ REQUEST-IP ┃
┗━━━━━━━━━━━━━━━━┛
VERSION ==> #3.3.0
REQUESTIP.getClientIp(REQ)->'IP' #Returns client IP, beyond proxies, or null if cannot find.
#Tries, in order (see HTTP doc for more info):
# - X-Client-IP [C]
# - X-Forwarded-For [C]
# - CF-Connecting-IP [C] (Cloudflare)
# - Fastly-Client-Ip [C] (Fastly and Firebase)
# - True-Client-Ip [C] (Akamai and Cloudflare)
# - X-Real-IP [C] (Nginx/FastCGI)
# - X-Cluster-Client-IP [C] (Rackspace, Riverbed Stringray)
# - X-Forwarded [C], Forwarded-For [C]
# - X-Appengine-User-Ip [C] (Google App Engine)
# - REQ.connection.remoteAddress, REQ.connection.socket.remoteAddress,
# REQ.socket.remoteAddress, REQ.info.remoteAddress
# - REQ.requestContext.identity.sourceIp (AWS Lambda)
# - Cf-Pseudo-IPv4 (Cloudflare fallback)
# - recurse on REQ.raw REQ2 (Fastify)
#Does not return if not a valid IPv4|IPv6
REQUESTIP.mw([OPTS])->MDW #Same but as Connect MDW, settings REQ.ATTR = IP
#ATTR is OPTS.attributeName (def: 'clientIp')