Skip to content

Commit 7723149

Browse files
committed
Split ip
1 parent b5f682d commit 7723149

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ws/ws.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,10 @@ app.ws('/wg', {
316316
idleTimeout: 60,
317317
/* Handlers */
318318
upgrade: (res, req, context) => {
319-
const ip = req.getHeader('x-forwarded-for') || req.getHeader('cf-connecting-ip') || 'unknown';
319+
let ip = req.getHeader('x-forwarded-for') || req.getHeader('cf-connecting-ip') || 'unknown';
320+
if(ip.includes(',')) {
321+
ip = ip.split(',')[0];
322+
}
320323
if([...bannedIps].some((bannedIp) => ip.includes(bannedIp))
321324
|| ipConnectionCount.get(ip) && ipConnectionCount.get(ip) > 100) {
322325
console.log('Banned ip tried to connect', ip);

0 commit comments

Comments
 (0)