MCPcopy Index your code
hub / github.com/nodejs/node / onconnection

Function onconnection

lib/net.js:2477–2550  ·  view source on GitHub ↗
(err, clientHandle)

Source from the content-addressed store, hash-verified

2475};
2476
2477function onconnection(err, clientHandle) {
2478 const handle = this;
2479 const self = handle[owner_symbol];
2480
2481 debug('onconnection');
2482
2483 if (err) {
2484 self.emit('error', new ErrnoException(err, 'accept'));
2485 return;
2486 }
2487
2488 if (self.maxConnections != null && self._connections >= self.maxConnections) {
2489 if (clientHandle.getsockname || clientHandle.getpeername) {
2490 const data = { __proto__: null };
2491 if (clientHandle.getsockname) {
2492 const localInfo = { __proto__: null };
2493 clientHandle.getsockname(localInfo);
2494 data.localAddress = localInfo.address;
2495 data.localPort = localInfo.port;
2496 data.localFamily = localInfo.family;
2497 }
2498 if (clientHandle.getpeername) {
2499 const remoteInfo = { __proto__: null };
2500 clientHandle.getpeername(remoteInfo);
2501 data.remoteAddress = remoteInfo.address;
2502 data.remotePort = remoteInfo.port;
2503 data.remoteFamily = remoteInfo.family;
2504 }
2505 self.emit('drop', data);
2506 } else {
2507 self.emit('drop');
2508 }
2509 clientHandle.close();
2510 return;
2511 }
2512 if (self.blockList && typeof clientHandle.getpeername === 'function') {
2513 const remoteInfo = { __proto__: null };
2514 clientHandle.getpeername(remoteInfo);
2515 const addressType = isIP(remoteInfo.address);
2516 if (addressType && self.blockList.check(remoteInfo.address, `ipv${addressType}`)) {
2517 clientHandle.close();
2518 return;
2519 }
2520 }
2521 const socket = new Socket({
2522 handle: clientHandle,
2523 allowHalfOpen: self.allowHalfOpen,
2524 pauseOnCreate: self.pauseOnConnect,
2525 readable: true,
2526 writable: true,
2527 readableHighWaterMark: self.highWaterMark,
2528 writableHighWaterMark: self.highWaterMark,
2529 });
2530
2531 if (self.noDelay && clientHandle.setNoDelay) {
2532 socket[kSetNoDelay] = true;
2533 clientHandle.setNoDelay(true);
2534 }

Callers

nothing calls this directly

Calls 6

isIPFunction · 0.85
closeMethod · 0.65
debugFunction · 0.50
emitMethod · 0.45
checkMethod · 0.45
publishMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…