Skip to content

Commit de4bd25

Browse files
committed
Move html settings from network.
1 parent 8460ab3 commit de4bd25

File tree

7 files changed

+292
-58
lines changed

7 files changed

+292
-58
lines changed

include/bitcoin/node/configuration.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class BCN_API configuration
6060

6161
/// Settings.
6262
log::settings log;
63+
server::settings server;
6364
node::settings node;
6465
network::settings network;
6566
database::settings database;

include/bitcoin/node/protocols/protocol_html.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <bitcoin/node/channels/channels.hpp>
2323
#include <bitcoin/node/define.hpp>
2424
#include <bitcoin/node/protocols/protocol.hpp>
25+
#include <bitcoin/node/settings.hpp>
2526

2627
namespace libbitcoin {
2728
namespace node {
@@ -33,7 +34,7 @@ class BCN_API protocol_html
3334
{
3435
public:
3536
/// http channel, but html settings.
36-
using options_t = network::settings::html_server;
37+
using options_t = server::settings::html_server;
3738
using channel_t = node::channel_http;
3839

3940
protected:

include/bitcoin/node/settings.hpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,62 @@ class BCN_API settings
9696
};
9797

9898
} // namespace node
99+
100+
namespace server {
101+
102+
/// [server] settings.
103+
class BCN_API settings
104+
{
105+
public:
106+
/// html (http/s) document server settings (has directory/default).
107+
/// This is for web servers that expose a local file system directory.
108+
struct html_server
109+
: public network::settings::http_server
110+
{
111+
/// Directory to serve.
112+
std::filesystem::path path{};
113+
114+
/// Default page for default URL (recommended).
115+
std::string default_{ "index.html" };
116+
117+
/// Validated against origins if configured (recommended).
118+
network::config::endpoints origins{};
119+
120+
/// Normalized origins.
121+
system::string_list origin_names() const NOEXCEPT;
122+
123+
/// !path.empty() && http_server::enabled() [hidden, not virtual]
124+
bool enabled() const NOEXCEPT;
125+
};
126+
127+
DEFAULT_COPY_MOVE_DESTRUCT(settings);
128+
129+
settings() NOEXCEPT {};
130+
settings(system::chain::selection) NOEXCEPT {};
131+
132+
/// native admin web interface, isolated (http/s, stateless html)
133+
server::settings::html_server web{ "web" };
134+
135+
/// native RESTful block explorer (http/s, stateless html/json)
136+
server::settings::html_server explore{ "explore" };
137+
138+
/// native websocket query interface (http/s->tcp/s, json, handshake)
139+
network::settings::webs_server websocket{ "websocket" };
140+
141+
/// bitcoind compat interface (http/s, stateless json-rpc-v2)
142+
network::settings::http_server bitcoind{ "bitcoind" };
143+
144+
/// electrum compat interface (tcp/s, json-rpc-v2)
145+
network::settings::tcp_server electrum{ "electrum" };
146+
147+
/// stratum v1 compat interface (tcp/s, json-rpc-v1, auth handshake)
148+
network::settings::tcp_server stratum_v1{ "stratum_v1" };
149+
150+
/// stratum v2 compat interface (tcp[/s], binary, auth/privacy handshake)
151+
network::settings::tcp_server stratum_v2{ "stratum_v2" };
152+
};
153+
154+
} // namespace server
99155
} // namespace libbitcoin
100156

101157
#endif

src/full_node.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -538,37 +538,37 @@ network::session_outbound::ptr full_node::attach_outbound_session() NOEXCEPT
538538

539539
session_web::ptr full_node::attach_web_session() NOEXCEPT
540540
{
541-
return net::attach<session_web>(*this, config_.network.web);
541+
return net::attach<session_web>(*this, config_.server.web);
542542
}
543543

544544
session_explore::ptr full_node::attach_explore_session() NOEXCEPT
545545
{
546-
return net::attach<session_explore>(*this, config_.network.explore);
546+
return net::attach<session_explore>(*this, config_.server.explore);
547547
}
548548

549549
session_websocket::ptr full_node::attach_websocket_session() NOEXCEPT
550550
{
551-
return net::attach<session_websocket>(*this, config_.network.websocket);
551+
return net::attach<session_websocket>(*this, config_.server.websocket);
552552
}
553553

554554
session_bitcoind::ptr full_node::attach_bitcoind_session() NOEXCEPT
555555
{
556-
return net::attach<session_bitcoind>(*this, config_.network.bitcoind);
556+
return net::attach<session_bitcoind>(*this, config_.server.bitcoind);
557557
}
558558

559559
session_electrum::ptr full_node::attach_electrum_session() NOEXCEPT
560560
{
561-
return net::attach<session_electrum>(*this, config_.network.electrum);
561+
return net::attach<session_electrum>(*this, config_.server.electrum);
562562
}
563563

564564
session_stratum_v1::ptr full_node::attach_stratum_v1_session() NOEXCEPT
565565
{
566-
return net::attach<session_stratum_v1>(*this, config_.network.stratum_v1);
566+
return net::attach<session_stratum_v1>(*this, config_.server.stratum_v1);
567567
}
568568

569569
session_stratum_v2::ptr full_node::attach_stratum_v2_session() NOEXCEPT
570570
{
571-
return net::attach<session_stratum_v2>(*this, config_.network.stratum_v2);
571+
return net::attach<session_stratum_v2>(*this, config_.server.stratum_v2);
572572
}
573573

574574
BC_POP_WARNING()

0 commit comments

Comments
 (0)