mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: handle reverse_proxy chains
This commit is contained in:
1 parent
c58c0d8465
commit
3f337e41c3
5 files changed
+8
-7
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.16.10",
|
||||
"version": "3.16.11",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -18,7 +18,9 @@ export default async (ctx, next) => {
|
||||
const { domainId, domainInfo } = ctx;
|
||||
const isWebsocket = ctx.request.headers.upgrade === 'websocket';
|
||||
const [xff, xhost] = system.getMany(['server.xff', 'server.xhost']);
|
||||
const ip = ctx.request.headers[xff?.toLowerCase() || ''] as string || ctx.request.ip;
|
||||
// ignore reverse_proxy chains
|
||||
const ipHeader = ctx.request.headers[xff?.toLowerCase() || ''];
|
||||
const ip = (typeof ipHeader === 'string' ? ipHeader : ipHeader[0] || ctx.request.ip).split(',')[0].trim();
|
||||
const host = ctx.request.headers[xhost?.toLowerCase() || ''] as string || ctx.request.host;
|
||||
const request: HydroRequest = {
|
||||
method: ctx.request.method.toLowerCase(),
|
||||
|
||||
Reference in new issue
Block a user