Skip to content

Commit 361e5d0

Browse files
committed
I'm an idiot
1 parent 5cff18f commit 361e5d0

File tree

3 files changed

+1
-35
lines changed

3 files changed

+1
-35
lines changed

apps/server/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"execa": "^9.6.0",
2323
"fastify": "^5.6.1",
2424
"gel": "^2.1.1",
25-
"ipaddr.js": "^2.2.0",
2625
"nanoid": "^3.3.11",
2726
"zod": "^4.1.12"
2827
},

apps/server/src/main.ts

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
} from "@trpc/server/adapters/fastify";
77
import type { TRPCReconnectNotification } from "@trpc/server/rpc";
88
import fastify from "fastify";
9-
import ipaddr from "ipaddr.js";
109
import { env } from "./env";
1110
import { roomRouter } from "./routers/room";
1211
import { roomAdminRouter } from "./routers/room-admin";
@@ -29,38 +28,7 @@ const server = fastify({
2928
routerOptions: {
3029
maxParamLength: 5000,
3130
},
32-
trustProxy: env.TRUSTED_PROXIES
33-
? (address) => {
34-
const ip = ipaddr.parse(address);
35-
const trustedCidrs =
36-
env.TRUSTED_PROXIES?.filter((c) => ipaddr.isValidCIDR(c)).map((c) =>
37-
ipaddr.parseCIDR(c),
38-
) || [];
39-
const trustedIps =
40-
env.TRUSTED_PROXIES?.filter((c) => ipaddr.isValid(c)).map((c) =>
41-
ipaddr.parse(c),
42-
) || [];
43-
44-
// Check if the IP matches any trusted CIDR
45-
for (const [range, prefix] of trustedCidrs) {
46-
if (ip.match(range, prefix)) {
47-
return true;
48-
}
49-
}
50-
51-
// Check if the IP matches any trusted IP directly
52-
for (const trustedIp of trustedIps) {
53-
if (
54-
ip.kind() === trustedIp.kind() &&
55-
ip.toNormalizedString() === trustedIp.toNormalizedString()
56-
) {
57-
return true;
58-
}
59-
}
60-
61-
return false;
62-
}
63-
: false,
31+
trustProxy: env.TRUSTED_PROXIES,
6432
});
6533

6634
await server.register(ws, {

bun.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"execa": "^9.6.0",
6060
"fastify": "^5.6.1",
6161
"gel": "^2.1.1",
62-
"ipaddr.js": "^2.2.0",
6362
"nanoid": "^3.3.11",
6463
"zod": "^4.1.12",
6564
},

0 commit comments

Comments
 (0)