Skip to content

Commit f460fdf

Browse files
authored
Boost 1.81 (#122)
* Upgrade to Boost 1.81
1 parent 851de4c commit f460fdf

File tree

8 files changed

+59
-55
lines changed

8 files changed

+59
-55
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ jobs:
2424
- name: Install boost
2525
working-directory: ${{ github.workspace }}
2626
run: |
27-
wget https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.gz -O /tmp/boost.tar.gz
27+
wget https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.gz -O /tmp/boost.tar.gz
2828
tar xzvf /tmp/boost.tar.gz
29-
cd boost_1_79_0
29+
cd boost_1_81_0
3030
./bootstrap.sh --with-toolset=clang
3131
./b2 install toolset=clang link=static
3232
- name: Install protobuf
@@ -66,9 +66,9 @@ jobs:
6666
- name: Install boost
6767
working-directory: ${{ github.workspace }}
6868
run: |
69-
wget https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.gz -O /tmp/boost.tar.gz
69+
wget https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.gz -O /tmp/boost.tar.gz
7070
tar xzvf /tmp/boost.tar.gz
71-
cd boost_1_79_0
71+
cd boost_1_81_0
7272
./bootstrap.sh
7373
sudo ./b2 install link=static
7474
- name: Install protobuf

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ endif(BUILD_TESTS)
7575
set(Boost_USE_STATIC_LIBS ON)
7676
set(Boost_USE_DEBUG_RUNTIME OFF)
7777
#set_property(GLOBAL PROPERTY Boost_USE_MULTITHREADED ON)
78-
set(BOOST_PKG_VERSION "1.79.0" CACHE STRING "")
79-
find_package(Boost ${BOOST_PKG_VERSION} REQUIRED COMPONENTS system log log_setup thread program_options date_time filesystem)
78+
set(BOOST_PKG_VERSION "1.81.0" CACHE STRING "")
79+
find_package(Boost ${BOOST_PKG_VERSION} REQUIRED COMPONENTS system log log_setup thread program_options date_time filesystem chrono)
8080
include_directories(${Boost_INCLUDE_DIRS})
8181
foreach(BOOST_LIB ${Boost_LIBRARIES})
8282
string(REPLACE ${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_STATIC_LIBRARY_SUFFIX} BOOST_STATIC_LIB ${BOOST_LIB})

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ RUN wget https://www.zlib.net/zlib-1.2.13.tar.gz -O /tmp/zlib-1.2.13.tar.gz && \
2222
make install && \
2323
cd /home/dependencies
2424

25-
RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.gz -O /tmp/boost.tar.gz && \
25+
RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.gz -O /tmp/boost.tar.gz && \
2626
tar xzvf /tmp/boost.tar.gz && \
27-
cd boost_1_79_0 && \
27+
cd boost_1_81_0 && \
2828
./bootstrap.sh && \
2929
./b2 install link=static && \
3030
cd /home/dependencies

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ previous step, or you can run `./docker-run.sh -p <port_number>` to expose a por
3434
* C++ 14 compiler
3535
* CMake 3.6+
3636
* Development libraries required:
37-
* Boost 1.79
37+
* Boost 1.81
3838
* Protobuf 3.17.x
3939
* zlib 1.12.13+
4040
* OpenSSL 1.0+ OR OpenSSL 3
@@ -63,9 +63,9 @@ Fedora example:
6363

6464
#### 2. Download and install Boost dependency
6565

66-
wget https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.gz -O /tmp/boost.tar.gz
66+
wget https://boostorg.jfrog.io/artifactory/main/release/1.81.0/source/boost_1_81_0.tar.gz -O /tmp/boost.tar.gz
6767
tar xzvf /tmp/boost.tar.gz
68-
cd boost_1_79_0
68+
cd boost_1_81_0
6969
./bootstrap.sh
7070
sudo ./b2 install link=static
7171

src/TcpAdapterProxy.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ namespace aws { namespace iot { namespace securedtunneling {
184184
{
185185
throw e;
186186
}
187-
BOOST_LOG_SEV(log, error) << "Failed web socket session ID: " << tac.wss_response["channel-id"].to_string();
187+
BOOST_LOG_SEV(log, error) << "Failed web socket session ID: " << tac.wss_response["channel-id"];
188188
}
189189
}
190190
}
@@ -836,12 +836,12 @@ namespace aws { namespace iot { namespace securedtunneling {
836836
tac.wss->binary(true);
837837
tac.wss->auto_fragment(true);
838838
//output this first because it'll be necessary to have this if any further errors need support/debugging
839-
BOOST_LOG_SEV(log, info) << "Web socket session ID: " << tac.wss_response["channel-id"].to_string();
839+
BOOST_LOG_SEV(log, info) << "Web socket session ID: " << tac.wss_response["channel-id"];
840840
if (!tac.wss_response.count(boost::beast::http::field::sec_websocket_protocol))
841841
{
842842
throw proxy_exception("No websocket subprotocol returned from proxy server!");
843843
}
844-
BOOST_LOG_SEV(log, debug) << "Web socket subprotocol selected: " << tac.wss_response[boost::beast::http::field::sec_websocket_protocol].to_string();
844+
BOOST_LOG_SEV(log, debug) << "Web socket subprotocol selected: " << tac.wss_response[boost::beast::http::field::sec_websocket_protocol];
845845
BOOST_LOG_SEV(log, info) << "Successfully established websocket connection with proxy server: wss://" << tac.adapter_config.proxy_host << ":" << tac.adapter_config.proxy_port;
846846
std::shared_ptr<boost::beast::websocket::ping_data> ping_data = std::make_shared<boost::beast::websocket::ping_data>();
847847
do_ping_data(tac, *ping_data);

src/config/ConfigFile.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
#include <cstdlib>
43
#include <chrono>
54
#include <algorithm>
65
#include <functional>
76
#include <iostream>
8-
#include <string>
9-
#include <utility>
107
#include <tuple>
11-
#include <unordered_map>
12-
#include <unordered_set>
138

149
#include <boost/phoenix.hpp>
1510
#include <boost/program_options.hpp>

src/main.cpp

Lines changed: 42 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <utility>
1010
#include <tuple>
1111

12-
#include <boost/phoenix.hpp>
1312
#include <boost/program_options.hpp>
1413
#include <boost/program_options/parsers.hpp>
1514
#include <boost/property_tree/ptree.hpp>
@@ -21,6 +20,7 @@
2120
#include <boost/log/utility/setup/common_attributes.hpp>
2221
#include <boost/log/expressions.hpp>
2322
#include <boost/uuid/uuid.hpp>
23+
#include <boost/log/support/date_time.hpp>
2424

2525
#include <boost/lexical_cast.hpp>
2626
#include <boost/regex.hpp>
@@ -99,41 +99,52 @@ void log_formatter(boost::log::formatting_ostream& strm, boost::log::record_view
9999
" " << rec["Message"].extract<std::string>();
100100
}
101101

102-
void set_logging_filter(std::uint16_t level_numeric)
102+
void init_logging(std::uint16_t &logging_level)
103103
{
104-
level_numeric = level_numeric > 6 ? 6 : level_numeric;
104+
boost::log::add_common_attributes();
105+
logging_level = logging_level > 6 ? 6 : logging_level;
105106

106-
switch (level_numeric)
107+
switch (logging_level)
107108
{
108-
case 6:
109-
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::trace);
110-
break;
111-
case 5:
112-
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::debug);
113-
break;
114-
case 4:
115-
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::info);
116-
break;
117-
case 3:
118-
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::warning);
119-
break;
120-
case 2:
121-
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::error);
122-
break;
123-
case 1:
124-
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::fatal);
125-
break;
126-
case 0:
127-
boost::log::core::get()->set_logging_enabled(false);
128-
break;
109+
case 6:
110+
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::trace);
111+
break;
112+
case 5:
113+
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::debug);
114+
break;
115+
case 4:
116+
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::info);
117+
break;
118+
case 3:
119+
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::warning);
120+
break;
121+
case 2:
122+
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::error);
123+
break;
124+
case 1:
125+
boost::log::core::get()->set_filter(boost::log::trivial::severity >= boost::log::trivial::fatal);
126+
break;
127+
case 0:
128+
boost::log::core::get()->set_logging_enabled(false);
129+
break;
129130
}
130-
}
131131

132-
void init_logging(std::uint16_t &logging_level)
133-
{
134-
boost::log::add_common_attributes();
135-
boost::log::add_console_log(std::cout, boost::log::keywords::format = boost::phoenix::bind(&log_formatter, boost::log::expressions::stream, boost::log::expressions::record));
136-
set_logging_filter(logging_level);
132+
/* log formatter:
133+
* [TimeStamp] [ThreadId] [Severity Level] [Scope] Log message
134+
*/
135+
auto fmtTimeStamp = boost::log::expressions::
136+
format_date_time<boost::posix_time::ptime>("TimeStamp", "%Y-%m-%d %H:%M:%S.%f");
137+
auto fmtThreadId = boost::log::expressions::
138+
attr<boost::log::attributes::current_thread_id::value_type>("ThreadID");
139+
auto fmtSeverity = boost::log::expressions::
140+
attr<boost::log::trivial::severity_level>("Severity");
141+
boost::log::formatter logFmt =
142+
boost::log::expressions::format("[%1%] (%2%) [%3%] %4%")
143+
% fmtTimeStamp % fmtThreadId % fmtSeverity % boost::log::expressions::smessage;
144+
145+
auto consoleSink = boost::log::add_console_log(std::clog);
146+
consoleSink->set_formatter(logFmt);
147+
137148
}
138149

139150
bool process_cli(int argc, char ** argv, LocalproxyConfig &cfg, ptree &settings, std::uint16_t &logging_level)
@@ -400,7 +411,6 @@ int main(int argc, char ** argv)
400411

401412
if (process_cli(argc, argv, cfg, settings, logging_level))
402413
{
403-
set_logging_filter(logging_level);
404414
tcp_adapter_proxy proxy{ settings, cfg };
405415
return proxy.run_proxy();
406416
}

test/TestHttpServer.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <memory>
1111

1212

13-
using boost::beast::string_view;
1413
namespace base64 = boost::beast::detail::base64;
1514

1615
/**
@@ -25,17 +24,17 @@ template<class Body, class Allocator, class Send>
2524
void handle_request(http::request<Body, http::basic_fields<Allocator>>&& req, Send&& send) {
2625
// Returns a 4xx response
2726
auto const client_error =
28-
[&req](string_view why, http::status status) {
27+
[&req](std::string why, http::status status) {
2928
http::response<http::string_body> res{status, req.version()};
3029
res.set(http::field::content_type, "text/html");
3130
res.keep_alive(req.keep_alive());
32-
res.body() = why.to_string();
31+
res.body() = why;
3332
res.prepare_payload();
3433
return res;
3534
};
3635
// Returns a 500 response
3736
auto const server_error =
38-
[&req](boost::beast::string_view what)
37+
[&req](std::string what)
3938
{
4039
http::response<http::string_body> res{http::status::internal_server_error, req.version()};
4140
res.set(http::field::content_type, "text/html");

0 commit comments

Comments
 (0)