lokinet/llarp/constants/files.hpp

59 lines
1.0 KiB
C++
Raw Normal View History

#pragma once
#include <llarp/util/fs.hpp>
#include <stdlib.h>
#ifndef _WIN32
2021-04-15 17:39:45 +00:00
#include <unistd.h>
#include <pwd.h>
#endif
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";
constexpr auto nodedb_dirname = "nodedb";
inline fs::path
GetDefaultDataDir()
{
#ifdef _WIN32
2021-04-15 17:39:45 +00:00
return "C:/programdata/lokinet";
#else
2021-04-15 17:39:45 +00:00
fs::path datadir{"/var/lib/lokinet"};
2021-04-15 17:39:45 +00:00
if (auto uid = ::geteuid())
{
2021-04-15 17:39:45 +00:00
if (auto* pw = getpwuid(uid))
{
datadir = fs::path{pw->pw_dir} / ".lokinet";
}
}
2021-04-15 17:39:45 +00:00
return datadir;
#endif
}
inline fs::path
GetDefaultConfigFilename()
{
return "lokinet.ini";
}
inline fs::path
GetDefaultConfigPath()
{
return GetDefaultDataDir() / GetDefaultConfigFilename();
}
2021-04-15 17:39:45 +00:00
inline fs::path
GetDefaultBootstrap()
{
return GetDefaultDataDir() / "bootstrap.signed";
}
} // namespace llarp