From 577784ad6f3b908ffbdc1a954b747b3d6ac0d0b4 Mon Sep 17 00:00:00 2001 From: Maurice ONeal Date: Mon, 30 Mar 2020 19:12:11 -0400 Subject: [PATCH] Fixed the type_ids.md document The byte format positions and lens for the PEER_INFO and MY_INFO type ids were fixed to properly reflect format(s). Few format changes to the code using the 'auto' keyword. This will be an ongoing thing on every commit until all parts of the code use the 'auto' keyword were appropriate. --- docs/type_ids.md | 10 +++++----- src/session.cpp | 11 ++++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/docs/type_ids.md b/docs/type_ids.md index c4ff2d7..4413eb0 100644 --- a/docs/type_ids.md +++ b/docs/type_ids.md @@ -176,8 +176,8 @@ This carry some user account and session information about a peer client connect 1. bytes[0-27] 28bytes - session id (224bit hash) 2. bytes[28-59] 32bytes - user id (256bit hash) 3. bytes[60-107] 48bytes - user name (TEXT - padded with 0x00) - 4. bytes[108-235] 128bytes - app name (TEXT - padded with 0x00) - 5. bytes[236-299] 64bytes - disp name (TEXT - padded with 0x00) + 4. bytes[108-241] 134bytes - app name (TEXT - padded with 0x00) + 5. bytes[242-305] 64bytes - disp name (TEXT - padded with 0x00) notes: 1. the session id is unique to the peer's session connection only. it @@ -201,9 +201,9 @@ This contains all of the information found in ```PEER_INFO``` for the local sess ``` format: - 1. bytes[300-427] 128bytes - email (TEXT - padded with 0x00) - 2. bytes[428-431] 4bytes - host rank (32bit unsigned int) - 3. bytes[432] 1byte - is email confirmed? (0x00 false, 0x01 true) + 1. bytes[306-433] 128bytes - email (TEXT - padded with 0x00) + 2. bytes[434-437] 4bytes - host rank (32bit unsigned int) + 3. bytes[438] 1byte - is email confirmed? (0x00 false, 0x01 true) ``` ```NEW_CMD``` diff --git a/src/session.cpp b/src/session.cpp index e91a7c8..3787117 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -310,7 +310,7 @@ void Session::dataFromClient() } else if (tcpSocket->bytesAvailable() >= FRAME_HEADER_SIZE) { - QByteArray header = tcpSocket->read(FRAME_HEADER_SIZE); + auto header = tcpSocket->read(FRAME_HEADER_SIZE); tcpFrameType = static_cast(header[0]); tcpFrameCmdId = static_cast(rdInt(header.mid(1, 4))); @@ -328,9 +328,10 @@ void Session::dataFromClient() { wrStringToBlock(fromTEXT(tcpSocket->read(BLKSIZE_APP_NAME)).trimmed(), appName, BLKSIZE_APP_NAME); - QString coName = fromTEXT(tcpSocket->read(272)).trimmed(); - QStringList ver = QCoreApplication::applicationVersion().split('.'); - QByteArray servHeader; + auto coName = fromTEXT(tcpSocket->read(272)).trimmed(); + auto ver = QCoreApplication::applicationVersion().split('.'); + + QByteArray servHeader; servHeader.append(wrInt(0, 8)); servHeader.append(wrInt(ver[0].toULongLong(), 16)); @@ -495,7 +496,7 @@ void Session::login(const QByteArray &uId) void Session::sendLocalInfo() { - QByteArray frame = createPeerInfoFrame(); + auto frame = createPeerInfoFrame(); Query db;