mirror of
https://github.com/CPunch/Laika.git
synced 2025-10-23 15:00:12 +00:00
Added .clang-format, formatted codebase
This commit is contained in:
@@ -1,24 +1,25 @@
|
||||
#ifndef LAIKA_CNC_H
|
||||
#define LAIKA_CNC_H
|
||||
|
||||
#include "hashmap.h"
|
||||
#include "laika.h"
|
||||
#include "lpacket.h"
|
||||
#include "lsocket.h"
|
||||
#include "lpolllist.h"
|
||||
#include "lpeer.h"
|
||||
#include "lpolllist.h"
|
||||
#include "lsocket.h"
|
||||
#include "ltask.h"
|
||||
#include "hashmap.h"
|
||||
|
||||
/* kill peers if they haven't ping'd within a minute */
|
||||
#define LAIKA_PEER_TIMEOUT 60 * 1000
|
||||
|
||||
typedef bool (*tLaika_peerIter)(struct sLaika_peer *peer, void *uData);
|
||||
|
||||
struct sLaika_cnc {
|
||||
struct sLaika_cnc
|
||||
{
|
||||
uint8_t priv[crypto_kx_SECRETKEYBYTES], pub[crypto_kx_PUBLICKEYBYTES];
|
||||
struct sLaika_socket sock;
|
||||
struct sLaika_pollList pList;
|
||||
struct hashmap *peers; /* holds all peers, lookup using pubkey */
|
||||
struct hashmap *peers; /* holds all peers, lookup using pubkey */
|
||||
struct sLaika_peer **authPeers; /* holds connected panel peers */
|
||||
uint8_t **authKeys;
|
||||
int authKeysCount;
|
||||
@@ -50,7 +51,8 @@ void laikaC_iterPeers(struct sLaika_cnc *cnc, tLaika_peerIter iter, void *uData)
|
||||
struct sLaika_peer *laikaC_getPeerByPub(struct sLaika_cnc *cnc, uint8_t *pub);
|
||||
|
||||
/* kills peers who haven't ping'd in a while */
|
||||
void laikaC_sweepPeersTask(struct sLaika_taskService *service, struct sLaika_task *task, clock_t currTick, void *uData);
|
||||
void laikaC_sweepPeersTask(struct sLaika_taskService *service, struct sLaika_task *task,
|
||||
clock_t currTick, void *uData);
|
||||
|
||||
void laikaC_iterPeers(struct sLaika_cnc *cnc, tLaika_peerIter iter, void *uData);
|
||||
|
||||
|
@@ -7,9 +7,13 @@
|
||||
void laikaC_sendNewPeer(struct sLaika_peer *authPeer, struct sLaika_peer *bot);
|
||||
void laikaC_sendRmvPeer(struct sLaika_peer *authPeer, struct sLaika_peer *bot);
|
||||
|
||||
void laikaC_handleAuthenticatedHandshake(struct sLaika_peer *authPeer, LAIKAPKT_SIZE sz, void *uData);
|
||||
void laikaC_handleAuthenticatedShellOpen(struct sLaika_peer *authPeer, LAIKAPKT_SIZE sz, void *uData);
|
||||
void laikaC_handleAuthenticatedShellClose(struct sLaika_peer *authPeer, LAIKAPKT_SIZE sz, void *uData);
|
||||
void laikaC_handleAuthenticatedShellData(struct sLaika_peer *authPeer, LAIKAPKT_SIZE sz, void *uData);
|
||||
void laikaC_handleAuthenticatedHandshake(struct sLaika_peer *authPeer, LAIKAPKT_SIZE sz,
|
||||
void *uData);
|
||||
void laikaC_handleAuthenticatedShellOpen(struct sLaika_peer *authPeer, LAIKAPKT_SIZE sz,
|
||||
void *uData);
|
||||
void laikaC_handleAuthenticatedShellClose(struct sLaika_peer *authPeer, LAIKAPKT_SIZE sz,
|
||||
void *uData);
|
||||
void laikaC_handleAuthenticatedShellData(struct sLaika_peer *authPeer, LAIKAPKT_SIZE sz,
|
||||
void *uData);
|
||||
|
||||
#endif
|
@@ -3,18 +3,20 @@
|
||||
|
||||
#include "laika.h"
|
||||
#include "lpacket.h"
|
||||
#include "lsocket.h"
|
||||
#include "lpolllist.h"
|
||||
#include "lpeer.h"
|
||||
#include "lpolllist.h"
|
||||
#include "lsocket.h"
|
||||
|
||||
struct sLaika_peerInfo {
|
||||
struct sLaika_peerInfo
|
||||
{
|
||||
struct sLaika_shellInfo *shells[LAIKA_MAX_SHELLS]; /* currently connected shells */
|
||||
struct sLaika_cnc *cnc;
|
||||
long lastPing;
|
||||
bool completeHandshake;
|
||||
};
|
||||
|
||||
struct sLaika_shellInfo {
|
||||
struct sLaika_shellInfo
|
||||
{
|
||||
struct sLaika_peer *bot;
|
||||
struct sLaika_peer *auth;
|
||||
uint32_t botShellID, authShellID;
|
||||
@@ -24,25 +26,28 @@ struct sLaika_shellInfo {
|
||||
#define BASE_PEERINFO struct sLaika_peerInfo info;
|
||||
|
||||
/* these will differ someday */
|
||||
struct sLaika_botInfo {
|
||||
struct sLaika_botInfo
|
||||
{
|
||||
BASE_PEERINFO
|
||||
};
|
||||
|
||||
struct sLaika_authInfo {
|
||||
struct sLaika_authInfo
|
||||
{
|
||||
BASE_PEERINFO
|
||||
};
|
||||
|
||||
#undef BASE_PEERINFO
|
||||
|
||||
#define GETPINFOFROMPEER(x) ((struct sLaika_peerInfo*)x->uData)
|
||||
#define GETBINFOFROMPEER(x) ((struct sLaika_botInfo*)x->uData)
|
||||
#define GETAINFOFROMPEER(x) ((struct sLaika_authInfo*)x->uData)
|
||||
#define GETPINFOFROMPEER(x) ((struct sLaika_peerInfo *)x->uData)
|
||||
#define GETBINFOFROMPEER(x) ((struct sLaika_botInfo *)x->uData)
|
||||
#define GETAINFOFROMPEER(x) ((struct sLaika_authInfo *)x->uData)
|
||||
|
||||
struct sLaika_botInfo *laikaC_newBotInfo(struct sLaika_cnc *cnc);
|
||||
struct sLaika_authInfo *laikaC_newAuthInfo(struct sLaika_cnc *cnc);
|
||||
void laikaC_freePeerInfo(struct sLaika_peer *peer, struct sLaika_peerInfo *pInfo);
|
||||
|
||||
struct sLaika_shellInfo* laikaC_openShell(struct sLaika_peer *bot, struct sLaika_peer *auth, uint16_t cols, uint16_t rows);
|
||||
struct sLaika_shellInfo *laikaC_openShell(struct sLaika_peer *bot, struct sLaika_peer *auth,
|
||||
uint16_t cols, uint16_t rows);
|
||||
void laikaC_closeShell(struct sLaika_shellInfo *shell);
|
||||
|
||||
void laikaC_closeShells(struct sLaika_peer *peer);
|
||||
|
Reference in New Issue
Block a user