Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support boost-1.87.0 #328

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/tgbot/net/BoostHttpOnlySslClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ class TGBOT_API BoostHttpOnlySslClient : public HttpClient {
std::string makeRequest(const Url& url, const std::vector<HttpReqArg>& args) const override;

private:
#if BOOST_VERSION >= 108700
mutable boost::asio::io_context _ioService;
#else
mutable boost::asio::io_service _ioService;
#endif
const HttpParser _httpParser;
};

Expand Down
5 changes: 4 additions & 1 deletion include/tgbot/net/HttpServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,11 @@ class HttpServer {
_startAccept();
});
}

#if BOOST_VERSION >= 108700
boost::asio::io_context _ioService;
#else
boost::asio::io_service _ioService;
#endif
boost::asio::basic_socket_acceptor<Protocol> _acceptor;
boost::asio::basic_stream_socket<Protocol> _socket;
const ServerHandler _handler;
Expand Down
15 changes: 13 additions & 2 deletions src/net/BoostHttpOnlySslClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ BoostHttpOnlySslClient::~BoostHttpOnlySslClient() {

string BoostHttpOnlySslClient::makeRequest(const Url& url, const vector<HttpReqArg>& args) const {
tcp::resolver resolver(_ioService);
tcp::resolver::query query(url.host, "443");

ssl::context context(ssl::context::tlsv12_client);
context.set_default_verify_paths();

ssl::stream<tcp::socket> socket(_ioService, context);

#if BOOST_VERSION >= 108700
connect(socket.lowest_layer(), resolver.resolve(url.host, "443"));
#else
tcp::resolver::query query(url.host, "443");
connect(socket.lowest_layer(), resolver.resolve(query));
#endif

#ifdef TGBOT_DISABLE_NAGLES_ALGORITHM
socket.lowest_layer().set_option(tcp::no_delay(true));
Expand All @@ -41,7 +44,11 @@ string BoostHttpOnlySslClient::makeRequest(const Url& url, const vector<HttpReqA
#endif //Processor architecture
#endif //TGBOT_CHANGE_SOCKET_BUFFER_SIZE
socket.set_verify_mode(ssl::verify_none);
#if BOOST_VERSION >= 108700
socket.set_verify_callback(ssl::host_name_verification(url.host));
#else
socket.set_verify_callback(ssl::rfc2818_verification(url.host));
#endif

socket.handshake(ssl::stream<tcp::socket>::client);

Expand Down Expand Up @@ -69,7 +76,11 @@ string BoostHttpOnlySslClient::makeRequest(const Url& url, const vector<HttpReqA
std::string sMsg("TIMEOUT on read client data. Client IP: ");

sMsg.append(socket.next_layer().remote_endpoint().address().to_string());
#if BOOST_VERSION >= 108700
_ioService.restart();
#else
_ioService.reset();
#endif

throw std::exception();
}
Expand Down
Loading