show total bytes read/written when cleaning up socket

This commit is contained in:
zefie
2025-06-23 22:33:50 -04:00
parent 023b7af723
commit c6a3a0f949
2 changed files with 4 additions and 2 deletions

View File

@@ -15,7 +15,6 @@ const httpx = require(classPath + "/HTTPX.js");
const net = require('net');
const crypto = require('crypto')
const CryptoJS = require('crypto-js');
const { crc16 } = require('easy-crc');
const process = require('process');
const WTVSec = require(classPath + "/WTVSec.js");
const WTVLzpf = require(classPath + "/WTVLzpf.js");
@@ -2198,7 +2197,7 @@ async function processRequest(socket, data_hex, skipSecure = false, encryptedReq
async function cleanupSocket(socket) {
try {
if (socket_sessions[socket.id]) {
if (!minisrv_config.config.debug_flags.quiet) console.debug(" * Cleaning up disconnected socket", socket.id);
if (!minisrv_config.config.debug_flags.quiet) console.debug('* Cleaning up disconnected socket', socket.id, `(${socket_sessions[socket.id].socket_total_read} bytes read, ${socket_sessions[socket.id].socket_total_written} bytes written)`);
delete socket_sessions[socket.id];
}
if (socket.ssid) {
@@ -2245,11 +2244,13 @@ async function handleSocket(socket) {
socket.id = getSocketRandomID(socket);
socket.ssid = null;
socket_sessions[socket.id] = [];
socket_sessions[socket.id].socket_total_read = 0;
socket.minisrv_pc_mode = false;
socket.setEncoding('hex'); //set data encoding (Text: 'ascii', 'utf8' ~ Binary: 'hex', 'base64' (do not trust 'binary' encoding))
socket.setTimeout(minisrv_config.config.socket_timeout * 1000);
socket.on('data', function (data_hex) {
if (socket_sessions[socket.id]) {
socket_sessions[socket.id].socket_total_read += data_hex.length / 2; // hex encoding, so divide by 2
if (!socket_sessions[socket.id].secure && !socket_sessions[socket.id].expecting_post_data) {
// buffer unencrypted data until we see the classic double-newline, or get blank
if (!socket_sessions[socket.id].header_buffer) socket_sessions[socket.id].header_buffer = "";

View File

@@ -3234,6 +3234,7 @@ class WTVIRC {
exemptions: new Set(),
invites: new Set(),
modes: [...this.default_channel_modes],
mlock: [],
limit: null,
key: null,
timestamp: this.getDate()