1
0
mirror of https://github.com/CPunch/Laika.git synced 2025-10-02 06:20:05 +00:00

Deprecated panel, added shell, lrsa.h -> lsodium.h

- Refactoring
This commit is contained in:
2022-02-24 22:13:05 -06:00
parent 5c31fb861b
commit c092d5a9a0
25 changed files with 808 additions and 40 deletions

33
shell/include/sclient.h Normal file
View File

@@ -0,0 +1,33 @@
#ifndef SHELLCLIENT_H
#define SHELLCLIENT_H
#include "hashmap.h"
#include "lpeer.h"
#include "lsodium.h"
#include "speer.h"
typedef struct sShell_client {
uint8_t priv[crypto_kx_SECRETKEYBYTES], pub[crypto_kx_PUBLICKEYBYTES];
struct sLaika_pollList pList;
struct sLaika_peer *peer;
struct hashmap *peers;
tShell_peer **peerTbl;
int peerTblCount;
int peerTblCap;
} tShell_client;
void shellC_init(tShell_client *client);
void shellC_cleanup(tShell_client *client);
void shellC_connectToCNC(tShell_client *client, char *ip, char *port);
bool shellC_poll(tShell_client *client, int timeout);
tShell_peer *shellC_getPeerByPub(tShell_client *client, uint8_t *pub, int *id);
int shellC_addPeer(tShell_client *client, tShell_peer *peer); /* returns new peer id */
void shellC_rmvPeer(tShell_client *client, tShell_peer *peer, int id);
void shellC_printInfo(tShell_peer *peer);
#endif

23
shell/include/scmd.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef SHELLCMD_H
#define SHELLCMD_H
#include <string.h>
#include "sclient.h"
typedef void (*shellCmdCallback)(tShell_client *client, int args, char *argc[]);
typedef struct sShell_cmdDef {
const char *cmd;
const char *help;
shellCmdCallback callback;
} tShell_cmdDef;
extern tShell_cmdDef shellS_cmds[];
void shellS_initCmds(void);
void shellS_cleanupCmds(void);
void shellS_runCmd(tShell_client *client, char *cmd);
#endif

18
shell/include/speer.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef SHELLPEER_H
#define SHELLPEER_H
#include "lsodium.h"
#include "lpeer.h"
typedef struct sShell_peer {
uint8_t pub[crypto_kx_PUBLICKEYBYTES];
char hostname[LAIKA_HOSTNAME_LEN], ipv4[LAIKA_IPV4_LEN];
PEERTYPE type;
} tShell_peer;
tShell_peer *shellP_newPeer(PEERTYPE type, uint8_t *pub, char *hostname, char *ipv4);
void shellP_freePeer(tShell_peer *peer);
char *shellP_typeStr(tShell_peer *peer);
#endif

26
shell/include/sterm.h Normal file
View File

@@ -0,0 +1,26 @@
#ifndef SHELLTERM_H
#define SHELLTERM_H
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <sys/select.h>
#include <termios.h>
#include <stdbool.h>
#include "sclient.h"
void shellT_conioTerm(void);
void shellT_resetTerm(void);
void shellT_printf(const char *format, ...);
/* waits for input for timeout (in ms). returns true if input is ready to be read, false if no events */
bool shellT_waitForInput(int timeout);
char shellT_getch(void);
int shellT_kbget(void);
void shellT_printPrompt(void);
void shellT_setPrompt(char *prompt);
void shellT_addChar(tShell_client *client, int c); /* processes input, moving cursor, adding char to cmd, etc. */
#endif