lokinet/daemon/main.c

42 lines
976 B
C
Raw Normal View History

2018-01-25 16:24:33 +00:00
#include <llarp.h>
2018-01-08 13:49:05 +00:00
#include <stdio.h>
2018-01-25 16:24:33 +00:00
struct llarp_router * router;
struct llarp_config * gconfig;
struct llarp_ev_loop * mainloop;
2017-09-28 17:02:05 +00:00
int main(int argc, char * argv[])
{
2018-01-08 13:49:05 +00:00
const char * conffname = "daemon.ini";
if (argc > 1)
conffname = argv[1];
2018-01-25 16:24:33 +00:00
llarp_mem_jemalloc();
llarp_new_config(&gconfig);
llarp_ev_loop_alloc(&mainloop);
printf("%s loaded\n", LLARP_VERSION);
if(!llarp_load_config(gconfig, conffname))
2018-01-08 13:49:05 +00:00
{
2018-01-25 16:11:45 +00:00
printf("Loaded config %s\n", conffname);
2018-01-25 16:24:33 +00:00
llarp_init_router(&router);
if(!llarp_configure_router(router, gconfig))
2018-01-25 16:11:45 +00:00
{
printf("Running\n");
2018-01-25 16:24:33 +00:00
llarp_run_router(router, mainloop);
llarp_ev_loop_run(mainloop);
2018-01-25 16:11:45 +00:00
}
else
printf("Failed to configure router\n");
2018-01-08 13:49:05 +00:00
}
2018-01-25 16:11:45 +00:00
else
printf("Failed to load config %s\n", conffname);
printf("Shutting down.");
2018-01-25 16:24:33 +00:00
llarp_free_router(&router);
2018-01-08 13:49:05 +00:00
printf(".");
2018-01-25 16:24:33 +00:00
llarp_free_config(&gconfig);
2018-01-08 13:49:05 +00:00
printf(".");
2018-01-25 16:24:33 +00:00
llarp_ev_loop_free(&mainloop);
2018-01-08 13:49:05 +00:00
printf(".\n");
2017-09-28 17:02:05 +00:00
return 0;
}