Skip to content

Commit

Permalink
revert: partial revert to try a new fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzah committed Sep 30, 2022
1 parent 23606c8 commit f547f93
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions server/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,9 @@ export default async function handleLink(req: IncomingMessage, res: ServerRespon
// Get the IP
let ip = req.socket.remoteAddress ?? '127.0.0.1';
if (process.env.TRUST_PROXY === 'true') {
if (process.env.TRUST_PROXY_HEADER) {
if (req.headers[process.env.TRUST_PROXY_HEADER])
ip = Array.isArray(req.headers[process.env.TRUST_PROXY_HEADER])
? req.headers[process.env.TRUST_PROXY_HEADER][0]
: (req.headers[process.env.TRUST_PROXY_HEADER] as string);
} else if (req.headers['cf-connecting-ip'])
ip = Array.isArray(req.headers['cf-connecting-ip']) ? req.headers['cf-connecting-ip'][0] : req.headers['cf-connecting-ip'];
const proxyHeader = process.env.TRUST_PROXY_HEADER || 'cf-connecting-ip';
if (proxyHeader && req.headers[proxyHeader])
ip = Array.isArray(req.headers[proxyHeader]) ? req.headers[proxyHeader][0] : (req.headers[proxyHeader] as string);
}

const cooldown = await processCooldown(`stub_${ip}`, RATELIMIT_EXPIRY, RATELIMIT_USES);
Expand Down

0 comments on commit f547f93

Please sign in to comment.