Skip to content

Commit

Permalink
Merge pull request #439 from AntelopeIO/http_server_header_main
Browse files Browse the repository at this point in the history
[3.2 -> main] change the HTTP Server header to be nodeos/keosd version
  • Loading branch information
spoonincode authored Nov 3, 2022
2 parents 27573c7 + fab0b7c commit bf33fda
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions plugins/http_plugin/http_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ class http_plugin_impl : public std::enable_shared_from_this<http_plugin_impl> {
}
}

my->plugin_state->server_header = current_http_plugin_defaults.server_header;


//watch out for the returns above when adding new code here
} FC_LOG_AND_RETHROW()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ class beast_http_session : public detail::abstract_conn {
res_->version(req.version());
res_->set(http::field::content_type, "application/json");
res_->keep_alive(req.keep_alive());
res_->set(http::field::server, BOOST_BEAST_VERSION_STRING);
if(plugin_state_->server_header.size())
res_->set(http::field::server, plugin_state_->server_header);

// Request path must be absolute and not contain "..".
if(req.target().empty() || req.target()[0] != '/' || req.target().find("..") != beast::string_view::npos) {
Expand Down
2 changes: 2 additions & 0 deletions plugins/http_plugin/include/eosio/http_plugin/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ struct http_plugin_state {
bool validate_host = true;
set<string> valid_hosts;

string server_header;

url_handlers_type url_handlers;
bool keep_alive = false;

Expand Down
2 changes: 2 additions & 0 deletions plugins/http_plugin/include/eosio/http_plugin/http_plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ namespace eosio {
//If non 0, HTTP will be enabled by default on the given port number. If
// 0, HTTP will not be enabled by default
uint16_t default_http_port{0};
//If set, a Server header will be added to the HTTP reply with this value
string server_header;
};

/**
Expand Down
3 changes: 2 additions & 1 deletion programs/keosd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ int main(int argc, char** argv)
app().set_default_config_dir(home / "eosio-wallet");
http_plugin::set_defaults({
.default_unix_socket_path = keosd::config::key_store_executable_name + ".sock",
.default_http_port = 0
.default_http_port = 0,
.server_header = keosd::config::key_store_executable_name + "/" + app().version_string()
});
app().register_plugin<wallet_api_plugin>();
if(!app().initialize<wallet_plugin, wallet_api_plugin, http_plugin>(argc, argv)) {
Expand Down
3 changes: 2 additions & 1 deletion programs/nodeos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ int main(int argc, char** argv)
app().set_default_config_dir(root / "eosio" / nodeos::config::node_executable_name / "config" );
http_plugin::set_defaults({
.default_unix_socket_path = "",
.default_http_port = 8888
.default_http_port = 8888,
.server_header = nodeos::config::node_executable_name + "/" + app().version_string()
});
if(!app().initialize<chain_plugin, net_plugin, producer_plugin, resource_monitor_plugin>(argc, argv)) {
const auto& opts = app().get_options();
Expand Down

0 comments on commit bf33fda

Please sign in to comment.