forked from townforge/townforge
game: do not auto start daemon if a running daemon needs a login
This commit is contained in:
parent
07d97136bd
commit
9c32d54af6
@ -14,6 +14,7 @@
|
||||
#include "misc_log_ex.h"
|
||||
#include "misc_language.h"
|
||||
#include "file_io_utils.h"
|
||||
#include "net/http_auth.h"
|
||||
#include "common/util.h"
|
||||
#include "rpc/bootstrap_daemon.h"
|
||||
#include "rpc/core_rpc_server_commands_defs.h"
|
||||
@ -169,14 +170,14 @@ int run_daemon(const char *filename, const std::vector<std::string>& args, bool
|
||||
#endif
|
||||
}
|
||||
|
||||
DaemonController::DaemonController(cryptonote::network_type nettype, const std::string &host, uint16_t port, const std::string &path):
|
||||
DaemonController::DaemonController(cryptonote::network_type nettype, const std::string &host, uint16_t port, const boost::optional<epee::net_utils::http::login> &login, const std::string &path):
|
||||
nettype(nettype),
|
||||
host(host.empty() ? "127.0.0.1" : host),
|
||||
port(port ? port : cryptonote::get_config(nettype).RPC_DEFAULT_PORT),
|
||||
path(path),
|
||||
controlling(false)
|
||||
{
|
||||
daemon.reset(new cryptonote::bootstrap_daemon(host + ":" + std::to_string(port), {}, false, "", epee::net_utils::ssl_support_t::e_ssl_support_disabled));
|
||||
daemon.reset(new cryptonote::bootstrap_daemon(host + ":" + std::to_string(port), login, false, "", epee::net_utils::ssl_support_t::e_ssl_support_disabled));
|
||||
}
|
||||
|
||||
std::string DaemonController::FindDaemonBinary() const
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace epee { namespace net_utils { namespace http { struct login; } } }
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
class bootstrap_daemon;
|
||||
@ -11,7 +13,7 @@ namespace cryptonote
|
||||
class DaemonController
|
||||
{
|
||||
public:
|
||||
DaemonController(cryptonote::network_type nettype, const std::string &host, uint16_t port, const std::string &path);
|
||||
DaemonController(cryptonote::network_type nettype, const std::string &host, uint16_t port, const boost::optional<epee::net_utils::http::login> &login, const std::string &path);
|
||||
|
||||
std::vector<std::string> Start();
|
||||
bool Stop();
|
||||
|
@ -442,6 +442,8 @@ public:
|
||||
|
||||
std::string get_daemon_address();
|
||||
cryptonote::network_type nettype();
|
||||
const boost::optional<epee::net_utils::http::login>& get_daemon_login();
|
||||
|
||||
uint8_t get_hf_version();
|
||||
bool use_fork_rules(uint8_t version);
|
||||
bool needs_refresh();
|
||||
@ -2132,6 +2134,12 @@ cryptonote::network_type GameWalletInternal::nettype()
|
||||
return w->nettype();
|
||||
}
|
||||
|
||||
const boost::optional<epee::net_utils::http::login>& GameWalletInternal::get_daemon_login()
|
||||
{
|
||||
std::shared_ptr<tools::wallet2> w = wallet();
|
||||
return w->get_daemon_login();
|
||||
}
|
||||
|
||||
uint8_t GameWalletInternal::get_hf_version()
|
||||
{
|
||||
std::shared_ptr<tools::wallet2> w = wallet();
|
||||
@ -2806,6 +2814,11 @@ cryptonote::network_type GameWallet::nettype()
|
||||
return internal->nettype();
|
||||
}
|
||||
|
||||
const boost::optional<epee::net_utils::http::login>& GameWallet::get_daemon_login()
|
||||
{
|
||||
return internal->get_daemon_login();
|
||||
}
|
||||
|
||||
uint8_t GameWallet::get_hf_version()
|
||||
{
|
||||
return internal->get_hf_version();
|
||||
|
@ -27,6 +27,8 @@ URHO3D_EVENT(E_WALLET_NEW_POOL_COMMAND, NewPoolCommand) { URHO3D_PARAM(P_TXID, T
|
||||
URHO3D_EVENT(E_WALLET_POOL_COMMAND_GONE, PoolCommandGone) { URHO3D_PARAM(P_TXID, TXID); }
|
||||
URHO3D_EVENT(E_WALLET_CREATING_NEW_ACCOUNT, CreatingNewAccount) { }
|
||||
|
||||
namespace epee { namespace net_utils { namespace http { struct login; } } }
|
||||
|
||||
namespace cryptonote
|
||||
{
|
||||
struct cc_account_data_t;
|
||||
@ -154,6 +156,7 @@ public:
|
||||
|
||||
std::string get_daemon_address();
|
||||
cryptonote::network_type nettype();
|
||||
const boost::optional<epee::net_utils::http::login>& get_daemon_login();
|
||||
|
||||
uint8_t get_hf_version();
|
||||
bool use_fork_rules(uint8_t version);
|
||||
|
@ -1192,7 +1192,7 @@ void CryptoCityUrho3D::SetupDaemon()
|
||||
const uint16_t port = ptr ? atoi(ptr + 1) : 0;
|
||||
|
||||
const String path = GetSubsystem<FileSystem>()->GetProgramDir();
|
||||
daemon_controller.reset(new DaemonController(wallet->nettype(), host, port, path.CString()));
|
||||
daemon_controller.reset(new DaemonController(wallet->nettype(), host, port, wallet->get_daemon_login(), path.CString()));
|
||||
const std::string data_dir = GetConfigValue(CONFIG_NODE_SECTION, CONFIG_DAEMON_DATA_DIR, DEFAULT_DAEMON_DATA_DIR).CString();
|
||||
const std::string log = GetConfigValue(CONFIG_NODE_SECTION, CONFIG_DAEMON_LOG, DEFAULT_DAEMON_LOG).CString();
|
||||
daemon_controller->Configure(data_dir, log);
|
||||
|
Loading…
Reference in New Issue
Block a user