@webdecoy/node 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +3 -0
- package/dist/index.mjs +3 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -67,11 +67,16 @@ declare function isTestTriggerUserAgent(userAgent: string | undefined): boolean;
|
|
|
67
67
|
* - `'cloudflare'` — use `CF-Connecting-IP`. Only meaningful if the origin is
|
|
68
68
|
* unreachable except through Cloudflare, since the header is otherwise just
|
|
69
69
|
* another thing a client can send.
|
|
70
|
+
* - `'railway'` — the app runs on Railway with nothing else in front. Railway's
|
|
71
|
+
* edge replaces any `X-Forwarded-For` the client sent with exactly
|
|
72
|
+
* `<client>, <edge>`, so the client is two entries from the right. The
|
|
73
|
+
* common guess of `1` names Railway's edge for every visitor. With a CDN in
|
|
74
|
+
* front of Railway, configure for the CDN instead (`'cloudflare'`).
|
|
70
75
|
* - `string[]` — CIDRs (or bare addresses) of the proxies you run. The chain is
|
|
71
76
|
* walked right to left and the first address that isn't one of yours is the
|
|
72
77
|
* client. Use this when the depth varies.
|
|
73
78
|
*/
|
|
74
|
-
type TrustedProxies = false | number | 'cloudflare' | string[];
|
|
79
|
+
type TrustedProxies = false | number | 'cloudflare' | 'railway' | string[];
|
|
75
80
|
/** Headers as either a Node-style bag or a WHATWG `Headers`. */
|
|
76
81
|
type HeaderSource = Record<string, string | string[] | undefined> | {
|
|
77
82
|
get(name: string): string | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -67,11 +67,16 @@ declare function isTestTriggerUserAgent(userAgent: string | undefined): boolean;
|
|
|
67
67
|
* - `'cloudflare'` — use `CF-Connecting-IP`. Only meaningful if the origin is
|
|
68
68
|
* unreachable except through Cloudflare, since the header is otherwise just
|
|
69
69
|
* another thing a client can send.
|
|
70
|
+
* - `'railway'` — the app runs on Railway with nothing else in front. Railway's
|
|
71
|
+
* edge replaces any `X-Forwarded-For` the client sent with exactly
|
|
72
|
+
* `<client>, <edge>`, so the client is two entries from the right. The
|
|
73
|
+
* common guess of `1` names Railway's edge for every visitor. With a CDN in
|
|
74
|
+
* front of Railway, configure for the CDN instead (`'cloudflare'`).
|
|
70
75
|
* - `string[]` — CIDRs (or bare addresses) of the proxies you run. The chain is
|
|
71
76
|
* walked right to left and the first address that isn't one of yours is the
|
|
72
77
|
* client. Use this when the depth varies.
|
|
73
78
|
*/
|
|
74
|
-
type TrustedProxies = false | number | 'cloudflare' | string[];
|
|
79
|
+
type TrustedProxies = false | number | 'cloudflare' | 'railway' | string[];
|
|
75
80
|
/** Headers as either a Node-style bag or a WHATWG `Headers`. */
|
|
76
81
|
type HeaderSource = Record<string, string | string[] | undefined> | {
|
|
77
82
|
get(name: string): string | null;
|
package/dist/index.js
CHANGED
|
@@ -3766,6 +3766,9 @@ function resolveClientIp(options) {
|
|
|
3766
3766
|
if (trustProxy === "cloudflare") {
|
|
3767
3767
|
return normalizeIp(readHeader(headers, "cf-connecting-ip")) ?? peer;
|
|
3768
3768
|
}
|
|
3769
|
+
if (trustProxy === "railway") {
|
|
3770
|
+
return resolveClientIp({ headers, peer: options.peer, trustProxy: 2 });
|
|
3771
|
+
}
|
|
3769
3772
|
const chain = forwardedChain(headers);
|
|
3770
3773
|
const singleHeaderFallback = () => normalizeIp(readHeader(headers, "x-real-ip")) ?? normalizeIp(readHeader(headers, "x-vercel-forwarded-for")?.split(",").pop()) ?? void 0;
|
|
3771
3774
|
if (typeof trustProxy === "number") {
|
package/dist/index.mjs
CHANGED
|
@@ -183,6 +183,9 @@ function resolveClientIp(options) {
|
|
|
183
183
|
if (trustProxy === "cloudflare") {
|
|
184
184
|
return normalizeIp(readHeader(headers, "cf-connecting-ip")) ?? peer;
|
|
185
185
|
}
|
|
186
|
+
if (trustProxy === "railway") {
|
|
187
|
+
return resolveClientIp({ headers, peer: options.peer, trustProxy: 2 });
|
|
188
|
+
}
|
|
186
189
|
const chain = forwardedChain(headers);
|
|
187
190
|
const singleHeaderFallback = () => normalizeIp(readHeader(headers, "x-real-ip")) ?? normalizeIp(readHeader(headers, "x-vercel-forwarded-for")?.split(",").pop()) ?? void 0;
|
|
188
191
|
if (typeof trustProxy === "number") {
|