174 boost::optional<epee::net_utils::http::login> http_login{};
187 #define MKDIR(path, mode) mkdir(path) 189 #define MKDIR(path, mode) mkdir(path, mode) 191 if (!m_wallet_dir.empty() &&
MKDIR(m_wallet_dir.c_str(), 0700) < 0 && errno != EEXIST)
194 LOG_ERROR(
tr(
"Failed to create directory ") + m_wallet_dir);
196 LOG_ERROR((boost::format(
tr(
"Failed to create directory %s: %s")) % m_wallet_dir % strerror(errno)).str());
204 if (rpc_config->login)
207 LOG_ERROR(
tr(
"Cannot specify --") << arg_disable_rpc_login.name <<
tr(
" and --") << arg.rpc_login.name);
213 if (!rpc_config->login)
215 std::array<std::uint8_t, 16> rand_128bit{{}};
218 default_rpc_username,
222 std::string temp =
"electroneum-wallet-rpc." + bind_port +
".login";
224 if (!rpc_login_file.
handle())
226 LOG_ERROR(
tr(
"Failed to create file ") << temp <<
tr(
". Check permissions or remove file"));
229 std::fputs(http_login->username.c_str(), rpc_login_file.
handle());
230 std::fputc(
':', rpc_login_file.
handle());
232 std::fwrite(password.data(), 1, password.size(), rpc_login_file.
handle());
233 std::fflush(rpc_login_file.
handle());
234 if (std::ferror(rpc_login_file.
handle()))
239 LOG_PRINT_L0(
tr(
"RPC username/password is stored in file ") << temp);
244 std::move(rpc_config->login->username),
std::move(rpc_config->login->password).password()
247 assert(
bool(http_login));
251 m_last_auto_refresh_time = boost::posix_time::min_date_time;
253 check_background_mining();
std::string base64_encode(unsigned char const *bytes_to_encode, size_t in_len)
net_utils::boosted_tcp_server< net_utils::http::http_custom_handler< epee::net_utils::connection_context_base > > m_net_server
#define MKDIR(path, mode)
command_line::arg_descriptor< std::string > arg_wallet_file()
static boost::optional< rpc_args > process(const boost::program_options::variables_map &vm, const bool any_cert_option=false)
boost::filesystem::path data_dir
#define DEFAULT_AUTO_REFRESH_PERIOD
void rand(size_t N, uint8_t *bytes)
bool init(std::function< void(size_t, uint8_t *)> rng, const std::string &bind_port="0", const std::string &bind_ip="0.0.0.0", std::vector< std::string > access_control_origins=std::vector< std::string >(), boost::optional< net_utils::http::login > user=boost::none, net_utils::ssl_options_t ssl_options=net_utils::ssl_support_t::e_ssl_support_autodetect)
const command_line::arg_descriptor< std::string, false, true, 2 > arg_data_dir
const T & move(const T &t)
T get_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, false, true > &arg)
bool is_arg_defaulted(const boost::program_options::variables_map &vm, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg)