2020-04-02 15:48:20 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/util/fs.hpp>
|
2020-04-02 15:48:20 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2020-06-16 14:04:30 +00:00
|
|
|
#ifndef _WIN32
|
2021-04-15 17:39:45 +00:00
|
|
|
#include <unistd.h>
|
2020-06-16 14:04:30 +00:00
|
|
|
#include <pwd.h>
|
|
|
|
#endif
|
|
|
|
|
2020-04-02 15:48:20 +00:00
|
|
|
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";
|
|
|
|
|
2020-04-02 18:11:49 +00:00
|
|
|
constexpr auto nodedb_dirname = "nodedb";
|
|
|
|
|
2020-04-07 20:41:11 +00:00
|
|
|
inline fs::path
|
2020-04-02 15:48:20 +00:00
|
|
|
GetDefaultDataDir()
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
2021-04-15 17:39:45 +00:00
|
|
|
return "C:/programdata/lokinet";
|
2020-04-02 15:48:20 +00:00
|
|
|
#else
|
2021-04-15 17:39:45 +00:00
|
|
|
fs::path datadir{"/var/lib/lokinet"};
|
2020-06-16 14:04:30 +00:00
|
|
|
|
2021-04-15 17:39:45 +00:00
|
|
|
if (auto uid = ::geteuid())
|
2020-06-16 14:04:30 +00:00
|
|
|
{
|
2021-04-15 17:39:45 +00:00
|
|
|
if (auto* pw = getpwuid(uid))
|
|
|
|
{
|
|
|
|
datadir = fs::path{pw->pw_dir} / ".lokinet";
|
|
|
|
}
|
2020-06-16 14:04:30 +00:00
|
|
|
}
|
2021-04-15 17:39:45 +00:00
|
|
|
return datadir;
|
2020-10-21 12:58:08 +00:00
|
|
|
#endif
|
2020-04-02 15:48:20 +00:00
|
|
|
}
|
|
|
|
|
2020-04-07 20:41:11 +00:00
|
|
|
inline fs::path
|
2020-04-02 15:48:20 +00:00
|
|
|
GetDefaultConfigFilename()
|
|
|
|
{
|
|
|
|
return "lokinet.ini";
|
|
|
|
}
|
|
|
|
|
2020-04-07 20:41:11 +00:00
|
|
|
inline fs::path
|
2020-04-02 15:48:20 +00:00
|
|
|
GetDefaultConfigPath()
|
|
|
|
{
|
|
|
|
return GetDefaultDataDir() / GetDefaultConfigFilename();
|
|
|
|
}
|
|
|
|
|
2021-04-15 17:39:45 +00:00
|
|
|
inline fs::path
|
|
|
|
GetDefaultBootstrap()
|
|
|
|
{
|
|
|
|
return GetDefaultDataDir() / "bootstrap.signed";
|
|
|
|
}
|
|
|
|
|
2020-04-02 15:48:20 +00:00
|
|
|
} // namespace llarp
|