- if (request.path === '/tracker/socket') {
- wss.handleUpgrade(request, socket, head, ws => wss.emit('connection', ws, request))
+ if (request.url === '/tracker/socket') {
+ const ip = proxyAddr(request, CONFIG.TRUST_PROXY)
+
+ if (blockedIPs.has(ip)) {
+ logger.debug('Blocking IP %s from tracker.', ip)
+
+ socket.write('HTTP/1.1 403 Forbidden\r\n\r\n')
+ socket.destroy()
+ return
+ }
+
+ // FIXME: typings
+ return wss.handleUpgrade(request, socket as any, head, ws => wss.emit('connection', ws, request))