lokinet/llarp/config.hpp

55 lines
1.1 KiB
C++
Raw Normal View History

2018-01-25 16:24:33 +00:00
#ifndef LIBLLARP_CONFIG_HPP
#define LIBLLARP_CONFIG_HPP
2018-04-05 14:38:22 +00:00
#include <list>
2017-11-28 14:05:31 +00:00
#include <string>
2018-01-25 16:24:33 +00:00
#include <llarp/config.h>
2017-11-28 14:05:31 +00:00
namespace llarp
{
struct Config
{
typedef std::list< std::pair< std::string, std::string > > section_t;
2017-11-28 14:05:31 +00:00
section_t router;
section_t network;
section_t netdb;
2018-07-26 10:53:27 +00:00
section_t dns;
section_t iwp_links;
section_t connect;
2018-07-09 17:32:11 +00:00
section_t services;
2018-08-09 13:55:51 +00:00
section_t system;
2018-10-09 12:06:30 +00:00
section_t api;
2017-11-28 14:05:31 +00:00
bool
Load(const char *fname);
};
2018-07-09 17:32:11 +00:00
2018-02-01 13:21:00 +00:00
} // namespace llarp
2017-11-28 14:05:31 +00:00
struct llarp_config
{
2018-01-29 14:27:24 +00:00
llarp::Config impl;
};
2017-11-28 14:05:31 +00:00
2018-10-01 09:57:57 +00:00
/// ensure configuration exists
/// populate with defaults
/// return if this succeeded
/// if overwrite is true then overwrite old config file
/// if basedir is not nullptr then use basedir as an absolute
/// base path for all files in config
bool
llarp_ensure_config(const char *fname, const char *basedir = nullptr,
bool overwrite = false, bool asRouter = true);
void
llarp_generic_ensure_config(std::ofstream &f, std::string basepath);
void
llarp_ensure_router_config(std::ofstream &f, std::string basepath);
2018-10-01 09:57:57 +00:00
bool
llarp_ensure_client_config(std::ofstream &f, std::string basepath);
2017-11-28 14:05:31 +00:00
#endif