@@ -1791,6 +1791,13 @@ function Server(options, connectionListener) {
|
1791 | 1791 | this.keepAlive = Boolean(options.keepAlive); |
1792 | 1792 | this.keepAliveInitialDelay = ~~(options.keepAliveInitialDelay / 1000); |
1793 | 1793 | this.highWaterMark = options.highWaterMark ?? getDefaultHighWaterMark(); |
| 1794 | +if (options.blockList) { |
| 1795 | +// TODO: use BlockList.isBlockList (https://github.com/nodejs/node/pull/56078) |
| 1796 | +if (!(options.blockList instanceof module.exports.BlockList)) { |
| 1797 | +throw new ERR_INVALID_ARG_TYPE('options.blockList', 'net.BlockList', options.blockList); |
| 1798 | +} |
| 1799 | +this.blockList = options.blockList; |
| 1800 | +} |
1794 | 1801 | } |
1795 | 1802 | ObjectSetPrototypeOf(Server.prototype, EventEmitter.prototype); |
1796 | 1803 | ObjectSetPrototypeOf(Server, EventEmitter); |
@@ -2239,7 +2246,15 @@ function onconnection(err, clientHandle) {
|
2239 | 2246 | clientHandle.close(); |
2240 | 2247 | return; |
2241 | 2248 | } |
2242 | | - |
| 2249 | +if (self.blockList && typeof clientHandle.getpeername === 'function') { |
| 2250 | +const remoteInfo = { __proto__: null }; |
| 2251 | +clientHandle.getpeername(remoteInfo); |
| 2252 | +const addressType = isIP(remoteInfo.address); |
| 2253 | +if (addressType && self.blockList.check(remoteInfo.address, `ipv${addressType}`)) { |
| 2254 | +clientHandle.close(); |
| 2255 | +return; |
| 2256 | +} |
| 2257 | +} |
2243 | 2258 | const socket = new Socket({ |
2244 | 2259 | handle: clientHandle, |
2245 | 2260 | allowHalfOpen: self.allowHalfOpen, |
|