mirror of https://github.com/oxen-io/lokinet
Organize some constants and default values
This commit is contained in:
parent
91206725cb
commit
d3bcc05aa6
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <config/ini.hpp>
|
||||
#include <constants/defaults.hpp>
|
||||
#include <constants/files.hpp>
|
||||
#include <net/net.hpp>
|
||||
#include <router_contact.hpp>
|
||||
#include <stdexcept>
|
||||
|
@ -307,7 +308,7 @@ namespace llarp
|
|||
constexpr bool DefaultWhitelistRouters = false;
|
||||
constexpr auto DefaultLokidRPCAddr = "127.0.0.1:22023";
|
||||
|
||||
conf.defineOption<std::string>("lokid", "service-node-seed", false, "",
|
||||
conf.defineOption<std::string>("lokid", "service-node-seed", false, our_identity_filename,
|
||||
[this](std::string arg) {
|
||||
if (not arg.empty())
|
||||
{
|
||||
|
@ -383,7 +384,7 @@ namespace llarp
|
|||
m_keyfile = arg;
|
||||
});
|
||||
|
||||
conf.defineOption<bool>("snapp", "keyfile", false, ReachableDefault,
|
||||
conf.defineOption<bool>("snapp", "reachable", false, ReachableDefault,
|
||||
AssignmentAcceptor(m_reachable));
|
||||
|
||||
conf.defineOption<int>("snapp", "hops", false, HopsDefault,
|
||||
|
@ -495,29 +496,6 @@ namespace llarp
|
|||
logging.defineConfigOptions(conf, params);
|
||||
}
|
||||
|
||||
fs::path
|
||||
GetDefaultDataDir()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const fs::path homedir = fs::path(getenv("APPDATA"));
|
||||
#else
|
||||
const fs::path homedir = fs::path(getenv("HOME"));
|
||||
#endif
|
||||
return homedir / fs::path(".lokinet/");
|
||||
}
|
||||
|
||||
fs::path
|
||||
GetDefaultConfigFilename()
|
||||
{
|
||||
return fs::path("lokinet.ini");
|
||||
}
|
||||
|
||||
fs::path
|
||||
GetDefaultConfigPath()
|
||||
{
|
||||
return GetDefaultDataDir() / GetDefaultConfigFilename();
|
||||
}
|
||||
|
||||
void
|
||||
ensureConfig(const fs::path& defaultDataDir,
|
||||
const fs::path& confFile,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <util/str.hpp>
|
||||
#include <config/ini.hpp>
|
||||
#include <config/definition.hpp>
|
||||
#include <constants/files.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
|
@ -131,7 +132,7 @@ namespace llarp
|
|||
{
|
||||
bool usingSNSeed;
|
||||
bool whitelistRouters;
|
||||
fs::path ident_keyfile = "identity.key"; // TODO: derive from [router]:data-dir
|
||||
fs::path ident_keyfile;
|
||||
std::string lokidRPCAddr;
|
||||
std::string lokidRPCUser;
|
||||
std::string lokidRPCPassword;
|
||||
|
@ -211,15 +212,6 @@ namespace llarp
|
|||
generateBaseRouterConfig(fs::path defaultDataDir);
|
||||
};
|
||||
|
||||
fs::path
|
||||
GetDefaultDataDir();
|
||||
|
||||
fs::path
|
||||
GetDefaultConfigFilename();
|
||||
|
||||
fs::path
|
||||
GetDefaultConfigPath();
|
||||
|
||||
void
|
||||
ensureConfig(const fs::path& defaultDataDir,
|
||||
const fs::path& confFile,
|
||||
|
|
|
@ -34,10 +34,10 @@ namespace llarp
|
|||
fs::path root = config.router.m_dataDir;
|
||||
|
||||
// TODO: use fs::path, or at least support windows-style separators
|
||||
m_rcPath = root / "self.signed";
|
||||
m_idKeyPath = root / "identity.key";
|
||||
m_encKeyPath = root / "encryption.key";
|
||||
m_transportKeyPath = root / "transport.key";
|
||||
m_rcPath = root / our_rc_filename;
|
||||
m_idKeyPath = root / our_identity_filename;
|
||||
m_encKeyPath = root / our_enc_key_filename;
|
||||
m_transportKeyPath = root / our_transport_key_filename;
|
||||
|
||||
m_usingLokid = config.lokid.whitelistRouters;
|
||||
m_lokidRPCAddr = config.lokid.lokidRPCAddr;
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
#pragma once
|
||||
|
||||
#include <util/fs.hpp>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace llarp
|
||||
{
|
||||
constexpr auto our_rc_filename = "self.signed";
|
||||
constexpr auto our_identity_filename = "identity.key";
|
||||
constexpr auto our_enc_key_filename = "encryption.key";
|
||||
constexpr auto our_transport_key_filename = "transport.key";
|
||||
|
||||
inline
|
||||
fs::path
|
||||
GetDefaultDataDir()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const fs::path homedir = getenv("APPDATA");
|
||||
#else
|
||||
const fs::path homedir = getenv("HOME");
|
||||
#endif
|
||||
return homedir / ".lokinet/";
|
||||
}
|
||||
|
||||
inline
|
||||
fs::path
|
||||
GetDefaultConfigFilename()
|
||||
{
|
||||
return "lokinet.ini";
|
||||
}
|
||||
|
||||
inline
|
||||
fs::path
|
||||
GetDefaultConfigPath()
|
||||
{
|
||||
return GetDefaultDataDir() / GetDefaultConfigFilename();
|
||||
}
|
||||
|
||||
} // namespace llarp
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <config/config.hpp>
|
||||
#include <constants/proto.hpp>
|
||||
#include <constants/files.hpp>
|
||||
#include <crypto/crypto_libsodium.hpp>
|
||||
#include <crypto/crypto.hpp>
|
||||
#include <dht/context.hpp>
|
||||
|
@ -395,9 +396,9 @@ namespace llarp
|
|||
conf->router.m_maxConnectedRouters;
|
||||
_outboundSessionMaker.minConnectedRouters =
|
||||
conf->router.m_minConnectedRouters;
|
||||
encryption_keyfile = conf->router.m_dataDir / "encryption.key";
|
||||
our_rc_file = conf->router.m_dataDir / "rc.signed";
|
||||
transport_keyfile = conf->router.m_dataDir / "transport.key";
|
||||
encryption_keyfile = conf->router.m_dataDir / our_enc_key_filename;
|
||||
our_rc_file = conf->router.m_dataDir / our_rc_filename;
|
||||
transport_keyfile = conf->router.m_dataDir / our_transport_key_filename;
|
||||
addrInfo = conf->router.m_addrInfo;
|
||||
publicOverride = conf->router.m_publicOverride;
|
||||
ip4addr = conf->router.m_ip4addr;
|
||||
|
@ -534,7 +535,7 @@ namespace llarp
|
|||
|
||||
if (!usingSNSeed)
|
||||
{
|
||||
ident_keyfile = conf->router.m_dataDir / "identity.key";
|
||||
ident_keyfile = conf->router.m_dataDir / our_identity_filename;
|
||||
}
|
||||
|
||||
// create inbound links, if we are a service node
|
||||
|
|
|
@ -54,19 +54,15 @@ namespace llarp
|
|||
llarp_time_t _lastPump = 0s;
|
||||
bool ready;
|
||||
// transient iwp encryption key
|
||||
fs::path transport_keyfile = "transport.key";
|
||||
|
||||
// nodes to connect to on startup
|
||||
// DEPRECATED
|
||||
// std::map< std::string, fs::path > connect;
|
||||
fs::path transport_keyfile;
|
||||
|
||||
// long term identity key
|
||||
fs::path ident_keyfile = "identity.key";
|
||||
fs::path ident_keyfile;
|
||||
|
||||
fs::path encryption_keyfile = "encryption.key";
|
||||
fs::path encryption_keyfile;
|
||||
|
||||
// path to write our self signed rc to
|
||||
fs::path our_rc_file = "rc.signed";
|
||||
fs::path our_rc_file;
|
||||
|
||||
// use file based logging?
|
||||
bool m_UseFileLogging = false;
|
||||
|
|
Loading…
Reference in New Issue