Skip to content

Commit 831edbb

Browse files
committed
Move origin processing to http settings (in network).
1 parent b04e463 commit 831edbb

File tree

5 files changed

+0
-34
lines changed

5 files changed

+0
-34
lines changed

include/bitcoin/node/protocols/protocol_html.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ class BCN_API protocol_html
8181
const network::http::request& request={}) NOEXCEPT;
8282

8383
/// Utilities.
84-
bool is_allowed_origin(const network::http::fields& fields,
85-
size_t version) const NOEXCEPT;
8684
std::filesystem::path to_path(
8785
const std::string& target = "/") const NOEXCEPT;
8886
std::filesystem::path to_local_path(

include/bitcoin/node/settings.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,6 @@ class BCN_API settings
147147
/// Default page for default URL (recommended).
148148
std::string default_{ "index.html" };
149149

150-
/// Validated against origins if configured (recommended).
151-
network::config::endpoints origins{};
152-
153-
/// Normalized origins.
154-
virtual system::string_list origin_names() const NOEXCEPT;
155-
156150
/// !path.empty() && http_server::enabled() [hidden, not virtual]
157151
virtual bool enabled() const NOEXCEPT;
158152
};

src/protocols/protocol_html.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -238,19 +238,6 @@ void protocol_html::send_buffer(buffer_body::value_type&& buffer,
238238
// Utilities.
239239
// ----------------------------------------------------------------------------
240240

241-
bool protocol_html::is_allowed_origin(const fields& fields,
242-
size_t version) const NOEXCEPT
243-
{
244-
// Allow same-origin and no-origin requests.
245-
// Origin header field is not available until http 1.1.
246-
const auto origin = fields[field::origin];
247-
if (origin.empty() || version < version_1_1)
248-
return true;
249-
250-
return options_.origins.empty() || system::contains(options_.origins,
251-
network::config::to_normal_host(origin, default_port()));
252-
}
253-
254241
std::filesystem::path protocol_html::to_path(
255242
const std::string& target) const NOEXCEPT
256243
{

src/settings.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,6 @@ settings::html_server::html_server(const std::string_view& logging_name,
180180
{
181181
}
182182

183-
system::string_list settings::html_server::origin_names() const NOEXCEPT
184-
{
185-
// secure changes default port from 80 to 443.
186-
const auto port = secure ? http::default_tls : http::default_http;
187-
return network::config::to_host_names(hosts, port);
188-
}
189-
190183
bool settings::html_server::enabled() const NOEXCEPT
191184
{
192185
return (!path.empty() || pages.enabled()) && http_server::enabled();

test/settings.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ BOOST_AUTO_TEST_CASE(server__html_server__defaults__expected)
115115
BOOST_REQUIRE(instance.websocket);
116116
BOOST_REQUIRE(instance.path.empty());
117117
BOOST_REQUIRE_EQUAL(instance.default_, "index.html");
118-
BOOST_REQUIRE(instance.origins.empty());
119-
BOOST_REQUIRE(instance.origin_names().empty());
120118
}
121119

122120
BOOST_AUTO_TEST_CASE(server__web_server__defaults__expected)
@@ -152,8 +150,6 @@ BOOST_AUTO_TEST_CASE(server__web_server__defaults__expected)
152150
BOOST_REQUIRE(server.path.empty());
153151
BOOST_REQUIRE(server.websocket);
154152
BOOST_REQUIRE_EQUAL(server.default_, "index.html");
155-
BOOST_REQUIRE(server.origins.empty());
156-
BOOST_REQUIRE(server.origin_names().empty());
157153
}
158154

159155
BOOST_AUTO_TEST_CASE(server__explore_server__defaults__expected)
@@ -189,8 +185,6 @@ BOOST_AUTO_TEST_CASE(server__explore_server__defaults__expected)
189185
BOOST_REQUIRE(server.path.empty());
190186
BOOST_REQUIRE(server.websocket);
191187
BOOST_REQUIRE_EQUAL(server.default_, "index.html");
192-
BOOST_REQUIRE(server.origins.empty());
193-
BOOST_REQUIRE(server.origin_names().empty());
194188
}
195189

196190
// TODO: could add websocket under bitcoind as a custom property.

0 commit comments

Comments
 (0)