fix: bandwidth limiters didn't work with proxy on localhost
Massimo Melina committed
Jun 21, 2025 at 00:00 UTC
06a4eefc525e2f59feecee5e5463d10b9f9a7710
1 file changed
+1
-2
src/misc.ts
+1
-2
@@ -3,7 +3,6 @@
3
import { basename } from 'path'
4
import Koa from 'koa'
5
import { Connection } from './connections'
6
-import assert from 'assert'
6
export * from './util-http'
7
export * from './util-files'
8
export * from './fileAttr'
@@ -25,7 +24,7 @@ export function pattern2filter(pattern: string){
24
}
25
26
export function isLocalHost(c: Connection | Koa.Context | string) {
28
- const ip = typeof c === 'string' ? c : c.socket.remoteAddress // don't use Context.ip as it is subject to proxied ips, and that's no use for localhost detection
27
+ const ip = typeof c === 'string' ? c : c.ip
28
return ip && isIpLocalHost(ip)
29
}
30