File tree Expand file tree Collapse file tree 3 files changed +1
-35
lines changed
Expand file tree Collapse file tree 3 files changed +1
-35
lines changed Original file line number Diff line number Diff line change 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 },
Original file line number Diff line number Diff line change 66} from "@trpc/server/adapters/fastify" ;
77import type { TRPCReconnectNotification } from "@trpc/server/rpc" ;
88import fastify from "fastify" ;
9- import ipaddr from "ipaddr.js" ;
109import { env } from "./env" ;
1110import { roomRouter } from "./routers/room" ;
1211import { 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
6634await server . register ( ws , {
Original file line number Diff line number Diff line change 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 },
You can’t perform that action at this time.
0 commit comments