Skip to content

Commit 3c6134c

Browse files
authored
Merge pull request #4624 from EOSIO/release/1.0.x
1.0.10
2 parents ef654aa + 0f3cc88 commit 3c6134c

File tree

5 files changed

+40
-22
lines changed

5 files changed

+40
-22
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ set( CXX_STANDARD_REQUIRED ON)
2020

2121
set(VERSION_MAJOR 1)
2222
set(VERSION_MINOR 0)
23-
set(VERSION_PATCH 9)
23+
set(VERSION_PATCH 10)
2424

2525
set( CLI_CLIENT_EXECUTABLE_NAME cleos )
2626
set( GUI_CLIENT_EXECUTABLE_NAME eosio )

Docker/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ cd eos/Docker
2020
docker build . -t eosio/eos
2121
```
2222

23-
The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v1.0.9 tag, you could do the following:
23+
The above will build off the most recent commit to the master branch by default. If you would like to target a specific branch/tag, you may use a build argument. For example, if you wished to generate a docker image based off of the v1.0.10 tag, you could do the following:
2424

2525
```bash
26-
docker build -t eosio/eos:v1.0.9 --build-arg branch=v1.0.9 .
26+
docker build -t eosio/eos:v1.0.10 --build-arg branch=v1.0.10 .
2727
```
2828

2929
By default, the symbol in eosio.system is set to SYS. You can override this using the symbol argument while building the docker image.
@@ -35,7 +35,7 @@ docker build -t eosio/eos --build-arg symbol=<symbol> .
3535
## Start nodeos docker container only
3636

3737
```bash
38-
docker run --name nodeos -p 8888:8888 -p 9876:9876 -t eosio/eos nodeosd.sh -e arg1 arg2
38+
docker run --name nodeos -p 8888:8888 -p 9876:9876 -t eosio/eos nodeosd.sh -e --http-alias=nodeos:8888 --http-alias=127.0.0.1:8888 --http-alias=localhost:8888 arg1 arg2
3939
```
4040

4141
By default, all data is persisted in a docker volume. It can be deleted if the data is outdated or corrupted:
@@ -49,7 +49,7 @@ $ docker volume rm fdc265730a4f697346fa8b078c176e315b959e79365fc9cbd11f090ea0cb5
4949
Alternately, you can directly mount host directory into the container
5050

5151
```bash
52-
docker run --name nodeos -v /path-to-data-dir:/opt/eosio/bin/data-dir -p 8888:8888 -p 9876:9876 -t eosio/eos nodeosd.sh -e arg1 arg2
52+
docker run --name nodeos -v /path-to-data-dir:/opt/eosio/bin/data-dir -p 8888:8888 -p 9876:9876 -t eosio/eos nodeosd.sh -e --http-alias=nodeos:8888 --http-alias=127.0.0.1:8888 --http-alias=localhost:8888 arg1 arg2
5353
```
5454

5555
## Get chain info
@@ -142,7 +142,7 @@ version: "3"
142142
services:
143143
nodeosd:
144144
image: eosio/eos:latest
145-
command: /opt/eosio/bin/nodeosd.sh --data-dir /opt/eosio/bin/data-dir -e
145+
command: /opt/eosio/bin/nodeosd.sh --data-dir /opt/eosio/bin/data-dir -e --http-alias=nodeosd:8888 --http-alias=127.0.0.1:8888 --http-alias=localhost:8888
146146
hostname: nodeosd
147147
ports:
148148
- 8888:8888
@@ -154,7 +154,7 @@ services:
154154

155155
keosd:
156156
image: eosio/eos:latest
157-
command: /opt/eosio/bin/keosd --wallet-dir /opt/eosio/bin/data-dir --http-server-address=127.0.0.1:8900
157+
command: /opt/eosio/bin/keosd --wallet-dir /opt/eosio/bin/data-dir --http-server-address=127.0.0.1:8900 --http-alias=localhost:8900 --http-alias=keosd:8900
158158
hostname: keosd
159159
links:
160160
- nodeosd
@@ -181,7 +181,7 @@ Note: if you want to use the mongo db plugin, you have to enable it in your `dat
181181

182182
```
183183
# pull images
184-
docker pull eosio/eos:v1.0.9
184+
docker pull eosio/eos:v1.0.10
185185
186186
# create volume
187187
docker volume create --name=nodeos-data-volume

Docker/docker-compose-eosio1.0.yaml renamed to Docker/docker-compose-latest.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ version: "3"
22

33
services:
44
nodeosd:
5-
image: eosio/eos:v1.0.9
6-
command: /opt/eosio/bin/nodeosd.sh --data-dir /opt/eosio/bin/data-dir -e
5+
image: eosio/eos:latest
6+
command: /opt/eosio/bin/nodeosd.sh --data-dir /opt/eosio/bin/data-dir -e --http-alias=nodeosd:8888 --http-alias=127.0.0.1:8888 --http-alias=localhost:8888
77
hostname: nodeosd
88
ports:
99
- 8888:8888
@@ -14,8 +14,8 @@ services:
1414
- nodeos-data-volume:/opt/eosio/bin/data-dir
1515

1616
keosd:
17-
image: eosio/eos:v1.0.9
18-
command: /opt/eosio/bin/keosd --wallet-dir /opt/eosio/bin/data-dir --http-server-address=127.0.0.1:8900
17+
image: eosio/eos:latest
18+
command: /opt/eosio/bin/keosd --wallet-dir /opt/eosio/bin/data-dir --http-server-address=127.0.0.1:8900 --http-alias=keosd:8900 --http-alias=localhost:8900
1919
hostname: keosd
2020
links:
2121
- nodeosd

Docker/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
build:
1111
context: .
1212
image: eosio/eos
13-
command: /opt/eosio/bin/nodeosd.sh --data-dir /opt/eosio/bin/data-dir -e
13+
command: /opt/eosio/bin/nodeosd.sh --data-dir /opt/eosio/bin/data-dir -e --http-alias=nodeosd:8888 --http-alias=127.0.0.1:8888 --http-alias=localhost:8888
1414
hostname: nodeosd
1515
ports:
1616
- 8888:8888
@@ -22,7 +22,7 @@ services:
2222

2323
keosd:
2424
image: eosio/eos
25-
command: /opt/eosio/bin/keosd --wallet-dir /opt/eosio/bin/data-dir --http-server-address=127.0.0.1:8900
25+
command: /opt/eosio/bin/keosd --wallet-dir /opt/eosio/bin/data-dir --http-server-address=127.0.0.1:8900 --http-alias=keosd:8900 --http-alias=localhost:8900
2626
hostname: keosd
2727
links:
2828
- nodeosd

plugins/http_plugin/http_plugin.cpp

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ namespace eosio {
3838
using std::regex;
3939
using boost::optional;
4040
using boost::asio::ip::tcp;
41+
using boost::asio::ip::address_v4;
42+
using boost::asio::ip::address_v6;
4143
using std::shared_ptr;
4244
using websocketpp::connection_hdl;
4345

@@ -106,22 +108,22 @@ namespace eosio {
106108
bool validate_host;
107109
set<string> valid_hosts;
108110

109-
bool host_port_is_valid( const std::string& host_port ) {
110-
return !validate_host || valid_hosts.find(host_port) != valid_hosts.end();
111+
bool host_port_is_valid( const std::string& header_host_port, const string& endpoint_local_host_port ) {
112+
return !validate_host || header_host_port == endpoint_local_host_port || valid_hosts.find(header_host_port) != valid_hosts.end();
111113
}
112114

113-
bool host_is_valid( const std::string& host, bool secure) {
115+
bool host_is_valid( const std::string& host, const string& endpoint_local_host_port, bool secure) {
114116
if (!validate_host) {
115117
return true;
116118
}
117119

118120
// normalise the incoming host so that it always has the explicit port
119121
static auto has_port_expr = regex("[^:]:[0-9]+$"); /// ends in :<number> without a preceeding colon which implies ipv6
120122
if (std::regex_search(host, has_port_expr)) {
121-
return host_port_is_valid( host );
123+
return host_port_is_valid( host, endpoint_local_host_port );
122124
} else {
123125
// according to RFC 2732 ipv6 addresses should always be enclosed with brackets so we shouldn't need to special case here
124-
return host_port_is_valid( host + ":" + std::to_string(secure ? websocketpp::uri_default_secure_port : websocketpp::uri_default_port ));
126+
return host_port_is_valid( host + ":" + std::to_string(secure ? websocketpp::uri_default_secure_port : websocketpp::uri_default_port ), endpoint_local_host_port);
125127
}
126128
}
127129

@@ -195,9 +197,13 @@ namespace eosio {
195197
template<class T>
196198
void handle_http_request(typename websocketpp::server<detail::asio_with_stub_log<T>>::connection_ptr con) {
197199
try {
200+
bool is_secure = con->get_uri()->get_secure();
201+
const auto& local_endpoint = con->get_socket().lowest_layer().local_endpoint();
202+
auto local_socket_host_port = local_endpoint.address().to_string() + ":" + std::to_string(local_endpoint.port());
203+
198204
auto& req = con->get_request();
199205
const auto& host_str = req.get_header("Host");
200-
if (host_str.empty() || !host_is_valid(host_str, con->get_uri()->get_secure())) {
206+
if (host_str.empty() || !host_is_valid(host_str, local_socket_host_port, is_secure)) {
201207
con->set_status(websocketpp::http::status_code::bad_request);
202208
return;
203209
}
@@ -263,6 +269,12 @@ namespace eosio {
263269
}
264270
}
265271

272+
void add_aliases_for_endpoint( const tcp::endpoint& ep, string host, string port ) {
273+
auto resolved_port_str = std::to_string(ep.port());
274+
valid_hosts.emplace(host + ":" + port);
275+
valid_hosts.emplace(host + ":" + resolved_port_str);
276+
}
277+
266278
};
267279

268280
http_plugin::http_plugin():my(new http_plugin_impl()){}
@@ -333,7 +345,10 @@ namespace eosio {
333345
elog("failed to configure http to listen on ${h}:${p} (${m})", ("h",host)("p",port)("m", ec.what()));
334346
}
335347

336-
my->valid_hosts.emplace(lipstr);
348+
// add in resolved hosts and ports as well
349+
if (my->listen_endpoint) {
350+
my->add_aliases_for_endpoint(*my->listen_endpoint, host, port);
351+
}
337352
}
338353

339354
if(options.count("https-server-address") && options.at("https-server-address").as<string>().length()) {
@@ -359,7 +374,10 @@ namespace eosio {
359374
elog("failed to configure https to listen on ${h}:${p} (${m})", ("h",host)("p",port)("m", ec.what()));
360375
}
361376

362-
my->valid_hosts.emplace(lipstr);
377+
// add in resolved hosts and ports as well
378+
if (my->https_listen_endpoint) {
379+
my->add_aliases_for_endpoint(*my->https_listen_endpoint, host, port);
380+
}
363381
}
364382

365383
my->max_body_size = options.at("max-body-size").as<uint32_t>();

0 commit comments

Comments
 (0)