Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #4624 from EOSIO/release/1.0.x
Browse files Browse the repository at this point in the history
1.0.10
  • Loading branch information
b1bart authored Jul 13, 2018
2 parents ef654aa + 0f3cc88 commit 3c6134c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set( CXX_STANDARD_REQUIRED ON)

set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
set(VERSION_PATCH 9)
set(VERSION_PATCH 10)

set( CLI_CLIENT_EXECUTABLE_NAME cleos )
set( GUI_CLIENT_EXECUTABLE_NAME eosio )
Expand Down
14 changes: 7 additions & 7 deletions Docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ cd eos/Docker
docker build . -t eosio/eos
```

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:
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:

```bash
docker build -t eosio/eos:v1.0.9 --build-arg branch=v1.0.9 .
docker build -t eosio/eos:v1.0.10 --build-arg branch=v1.0.10 .
```

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

```bash
docker run --name nodeos -p 8888:8888 -p 9876:9876 -t eosio/eos nodeosd.sh -e arg1 arg2
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
```

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

```bash
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
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
```

## Get chain info
Expand Down Expand Up @@ -142,7 +142,7 @@ version: "3"
services:
nodeosd:
image: eosio/eos:latest
command: /opt/eosio/bin/nodeosd.sh --data-dir /opt/eosio/bin/data-dir -e
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
hostname: nodeosd
ports:
- 8888:8888
Expand All @@ -154,7 +154,7 @@ services:

keosd:
image: eosio/eos:latest
command: /opt/eosio/bin/keosd --wallet-dir /opt/eosio/bin/data-dir --http-server-address=127.0.0.1:8900
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
hostname: keosd
links:
- nodeosd
Expand All @@ -181,7 +181,7 @@ Note: if you want to use the mongo db plugin, you have to enable it in your `dat

```
# pull images
docker pull eosio/eos:v1.0.9
docker pull eosio/eos:v1.0.10
# create volume
docker volume create --name=nodeos-data-volume
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ version: "3"

services:
nodeosd:
image: eosio/eos:v1.0.9
command: /opt/eosio/bin/nodeosd.sh --data-dir /opt/eosio/bin/data-dir -e
image: eosio/eos:latest
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
hostname: nodeosd
ports:
- 8888:8888
Expand All @@ -14,8 +14,8 @@ services:
- nodeos-data-volume:/opt/eosio/bin/data-dir

keosd:
image: eosio/eos:v1.0.9
command: /opt/eosio/bin/keosd --wallet-dir /opt/eosio/bin/data-dir --http-server-address=127.0.0.1:8900
image: eosio/eos:latest
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
hostname: keosd
links:
- nodeosd
Expand Down
4 changes: 2 additions & 2 deletions Docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
build:
context: .
image: eosio/eos
command: /opt/eosio/bin/nodeosd.sh --data-dir /opt/eosio/bin/data-dir -e
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
hostname: nodeosd
ports:
- 8888:8888
Expand All @@ -22,7 +22,7 @@ services:

keosd:
image: eosio/eos
command: /opt/eosio/bin/keosd --wallet-dir /opt/eosio/bin/data-dir --http-server-address=127.0.0.1:8900
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
hostname: keosd
links:
- nodeosd
Expand Down
34 changes: 26 additions & 8 deletions plugins/http_plugin/http_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ namespace eosio {
using std::regex;
using boost::optional;
using boost::asio::ip::tcp;
using boost::asio::ip::address_v4;
using boost::asio::ip::address_v6;
using std::shared_ptr;
using websocketpp::connection_hdl;

Expand Down Expand Up @@ -106,22 +108,22 @@ namespace eosio {
bool validate_host;
set<string> valid_hosts;

bool host_port_is_valid( const std::string& host_port ) {
return !validate_host || valid_hosts.find(host_port) != valid_hosts.end();
bool host_port_is_valid( const std::string& header_host_port, const string& endpoint_local_host_port ) {
return !validate_host || header_host_port == endpoint_local_host_port || valid_hosts.find(header_host_port) != valid_hosts.end();
}

bool host_is_valid( const std::string& host, bool secure) {
bool host_is_valid( const std::string& host, const string& endpoint_local_host_port, bool secure) {
if (!validate_host) {
return true;
}

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

Expand Down Expand Up @@ -195,9 +197,13 @@ namespace eosio {
template<class T>
void handle_http_request(typename websocketpp::server<detail::asio_with_stub_log<T>>::connection_ptr con) {
try {
bool is_secure = con->get_uri()->get_secure();
const auto& local_endpoint = con->get_socket().lowest_layer().local_endpoint();
auto local_socket_host_port = local_endpoint.address().to_string() + ":" + std::to_string(local_endpoint.port());

auto& req = con->get_request();
const auto& host_str = req.get_header("Host");
if (host_str.empty() || !host_is_valid(host_str, con->get_uri()->get_secure())) {
if (host_str.empty() || !host_is_valid(host_str, local_socket_host_port, is_secure)) {
con->set_status(websocketpp::http::status_code::bad_request);
return;
}
Expand Down Expand Up @@ -263,6 +269,12 @@ namespace eosio {
}
}

void add_aliases_for_endpoint( const tcp::endpoint& ep, string host, string port ) {
auto resolved_port_str = std::to_string(ep.port());
valid_hosts.emplace(host + ":" + port);
valid_hosts.emplace(host + ":" + resolved_port_str);
}

};

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

my->valid_hosts.emplace(lipstr);
// add in resolved hosts and ports as well
if (my->listen_endpoint) {
my->add_aliases_for_endpoint(*my->listen_endpoint, host, port);
}
}

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

my->valid_hosts.emplace(lipstr);
// add in resolved hosts and ports as well
if (my->https_listen_endpoint) {
my->add_aliases_for_endpoint(*my->https_listen_endpoint, host, port);
}
}

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

0 comments on commit 3c6134c

Please sign in to comment.