(reason)
| 322 | // Global |
| 323 | // ------ |
| 324 | disconnect(reason) { |
| 325 | const pktLen = 1 + 4 + 4 + 4; |
| 326 | // We don't use _packetRW.write.* here because we need to make sure that |
| 327 | // we always get a full packet allocated because this message can be sent |
| 328 | // at any time -- even during a key exchange |
| 329 | let p = this._packetRW.write.allocStartKEX; |
| 330 | const packet = this._packetRW.write.alloc(pktLen, true); |
| 331 | const end = p + pktLen; |
| 332 | |
| 333 | if (!VALID_DISCONNECT_REASONS.has(reason)) |
| 334 | reason = DISCONNECT_REASON.PROTOCOL_ERROR; |
| 335 | |
| 336 | packet[p] = MESSAGE.DISCONNECT; |
| 337 | writeUInt32BE(packet, reason, ++p); |
| 338 | packet.fill(0, p += 4, end); |
| 339 | |
| 340 | this._debug && this._debug(`Outbound: Sending DISCONNECT (${reason})`); |
| 341 | sendPacket(this, this._packetRW.write.finalize(packet, true), true); |
| 342 | } |
| 343 | ping() { |
| 344 | const p = this._packetRW.write.allocStart; |
| 345 | const packet = this._packetRW.write.alloc(PING_PAYLOAD.length); |
no test coverage detected