Sync with base.
This commit is contained in:
parent
d0953a507c
commit
8a167cb2a7
45 changed files with 1159 additions and 544 deletions
|
@ -17,29 +17,15 @@
|
|||
*/
|
||||
|
||||
#include "base/io/Env.h"
|
||||
#include "base/kernel/OS.h"
|
||||
#include "base/kernel/Process.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
#include <regex>
|
||||
#include <uv.h>
|
||||
#include <map>
|
||||
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef UV_MAXHOSTNAMESIZE
|
||||
# ifdef MAXHOSTNAMELEN
|
||||
# define UV_MAXHOSTNAMESIZE (MAXHOSTNAMELEN + 1)
|
||||
# else
|
||||
# define UV_MAXHOSTNAMESIZE 256
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
|
@ -51,17 +37,17 @@ static void createVariables()
|
|||
{
|
||||
variables.insert({ "XMRIG_VERSION", APP_VERSION });
|
||||
variables.insert({ "XMRIG_KIND", APP_KIND });
|
||||
variables.insert({ "XMRIG_HOSTNAME", Env::hostname() });
|
||||
variables.insert({ "XMRIG_EXE", Process::exepath() });
|
||||
variables.insert({ "XMRIG_EXE_DIR", Process::location(Process::ExeLocation) });
|
||||
variables.insert({ "XMRIG_CWD", Process::location(Process::CwdLocation) });
|
||||
variables.insert({ "XMRIG_HOME_DIR", Process::location(Process::HomeLocation) });
|
||||
variables.insert({ "XMRIG_TEMP_DIR", Process::location(Process::TempLocation) });
|
||||
variables.insert({ "XMRIG_DATA_DIR", Process::location(Process::DataLocation) });
|
||||
variables.insert({ "XMRIG_HOSTNAME", OS::hostname() });
|
||||
variables.insert({ "XMRIG_EXE", Process::locate(Process::ExePathLocation) });
|
||||
variables.insert({ "XMRIG_EXE_DIR", Process::locate(Process::ExeLocation) });
|
||||
variables.insert({ "XMRIG_CWD", Process::locate(Process::CwdLocation) });
|
||||
variables.insert({ "XMRIG_HOME_DIR", Process::locate(Process::HomeLocation) });
|
||||
variables.insert({ "XMRIG_TEMP_DIR", Process::locate(Process::TempLocation) });
|
||||
variables.insert({ "XMRIG_DATA_DIR", Process::locate(Process::DataLocation) });
|
||||
|
||||
String hostname = "HOSTNAME";
|
||||
if (!getenv(hostname)) { // NOLINT(concurrency-mt-unsafe)
|
||||
variables.insert({ std::move(hostname), Env::hostname() });
|
||||
variables.insert({ std::move(hostname), OS::hostname() });
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -138,15 +124,3 @@ xmrig::String xmrig::Env::get(const String &name, const std::map<String, String>
|
|||
|
||||
return static_cast<const char *>(getenv(name)); // NOLINT(concurrency-mt-unsafe)
|
||||
}
|
||||
|
||||
|
||||
xmrig::String xmrig::Env::hostname()
|
||||
{
|
||||
char buf[UV_MAXHOSTNAMESIZE]{};
|
||||
|
||||
if (gethostname(buf, sizeof(buf)) == 0) {
|
||||
return static_cast<const char *>(buf);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* XMRig
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -34,7 +34,6 @@ class Env
|
|||
public:
|
||||
static String expand(const char *in, const std::map<String, String> &extra = {});
|
||||
static String get(const String &name, const std::map<String, String> &extra = {});
|
||||
static String hostname();
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue