Remove IP Forwarding debug code
This commit is contained in:
@@ -11,7 +11,6 @@ services:
|
||||
DATA_DIR: /data
|
||||
SEED_DEMO_MEMES: "false"
|
||||
TRUST_PROXY: ${TRUST_PROXY:-false}
|
||||
DEBUG_CLIENT_IP: ${DEBUG_CLIENT_IP:-false}
|
||||
ADMIN_TOKEN: ${ADMIN_TOKEN}
|
||||
OPENAI_API_KEY: ${OPENAI_API_KEY}
|
||||
OPENAI_MODERATION_MODEL: ${OPENAI_MODERATION_MODEL:-gpt-4o-mini}
|
||||
|
||||
@@ -19,7 +19,6 @@ const PAGE_SIZE_MAX = 48;
|
||||
const UPLOAD_MAX_BYTES = 5 * 1024 * 1024;
|
||||
const REQUEST_MAX_BYTES = 6 * 1024 * 1024;
|
||||
const SSE_HEARTBEAT_MS = 25_000;
|
||||
const DEBUG_CLIENT_IP = process.env.DEBUG_CLIENT_IP === 'true';
|
||||
const events = new Set();
|
||||
const DISCOVERY_ROUTES = new Set([
|
||||
'/robots.txt',
|
||||
@@ -110,12 +109,6 @@ const server = http.createServer(async (req, res) => {
|
||||
});
|
||||
}
|
||||
|
||||
if (req.method === 'GET' && url.pathname === '/api/debug/ip') {
|
||||
noIndex(res);
|
||||
if (!DEBUG_CLIENT_IP) return sendJson(res, 404, { error: 'Not found' });
|
||||
return sendJson(res, 200, clientIpDebug(req));
|
||||
}
|
||||
|
||||
if (req.method === 'GET' && url.pathname === '/api/admin/pending') {
|
||||
noIndex(res);
|
||||
if (!isAdminRequest(req)) return sendJson(res, 404, { error: 'Not found' });
|
||||
@@ -327,26 +320,8 @@ function safeIds(ids) {
|
||||
|
||||
function clientIp(req) {
|
||||
if (process.env.TRUST_PROXY === 'true') {
|
||||
const edgeClientIp = String(req.headers['x-bitsforfree-client-ip'] || '').trim();
|
||||
if (edgeClientIp) return edgeClientIp;
|
||||
|
||||
const forwarded = String(req.headers['x-forwarded-for'] || '').split(',')[0].trim();
|
||||
if (forwarded) return forwarded;
|
||||
}
|
||||
return req.socket.remoteAddress || 'unknown';
|
||||
}
|
||||
|
||||
function clientIpDebug(req) {
|
||||
return {
|
||||
trustProxy: process.env.TRUST_PROXY === 'true',
|
||||
resolvedClientIp: clientIp(req),
|
||||
remoteAddress: req.socket.remoteAddress || '',
|
||||
headers: {
|
||||
xBitsForFreeClientIp: req.headers['x-bitsforfree-client-ip'] || '',
|
||||
xForwardedFor: req.headers['x-forwarded-for'] || '',
|
||||
xRealIp: req.headers['x-real-ip'] || '',
|
||||
forwarded: req.headers.forwarded || '',
|
||||
cfConnectingIp: req.headers['cf-connecting-ip'] || ''
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user