summaryrefslogtreecommitdiff
path: root/dev-libs/botan/files/botan-2.19.5-boost-1.87.patch
blob: a52fbaea130d369f021ea10b39fc7f921e5f0968 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
https://bugs.gentoo.org/946389
https://github.com/randombit/botan/commit/37fec38ff97604f964122cd2d33f5d503f319b10

From 37fec38ff97604f964122cd2d33f5d503f319b10 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Meusel?= <rene.meusel@rohde-schwarz.com>
Date: Thu, 19 Dec 2024 10:28:40 +0100
Subject: [PATCH] Backport: Remove usage of deprecated asio API

These were all finally dropped with boost 1.87, so this fixes
build with boost 1.87.

Co-Authored-By: Jack Lloyd <jack@randombit.net>
Co-Authored-By: q66 <q66@chimera-linux.org>
---
 src/cli/tls_http_server.cpp         | 16 +++++-----
 src/cli/tls_proxy.cpp               | 46 ++++++++++++++++-------------
 src/lib/utils/socket/socket.cpp     | 18 +++++------
 src/lib/utils/socket/socket_udp.cpp | 18 +++++------
 4 files changed, 50 insertions(+), 48 deletions(-)

diff --git a/src/cli/tls_http_server.cpp b/src/cli/tls_http_server.cpp
index fc0b5bbb77e..67ab126b145 100644
--- a/src/cli/tls_http_server.cpp
+++ b/src/cli/tls_http_server.cpp
@@ -176,7 +176,7 @@ class TLS_Asio_HTTP_Session final : public std::enable_shared_from_this<TLS_Asio
       typedef std::shared_ptr<TLS_Asio_HTTP_Session> pointer;
 
       static pointer create(
-         boost::asio::io_service& io,
+         boost::asio::io_context& io,
          Botan::TLS::Session_Manager& session_manager,
          Botan::Credentials_Manager& credentials,
          Botan::TLS::Policy& policy)
@@ -201,7 +201,7 @@ class TLS_Asio_HTTP_Session final : public std::enable_shared_from_this<TLS_Asio
          }
 
    private:
-      TLS_Asio_HTTP_Session(boost::asio::io_service& io,
+      TLS_Asio_HTTP_Session(boost::asio::io_context& io,
                             Botan::TLS::Session_Manager& session_manager,
                             Botan::Credentials_Manager& credentials,
                             Botan::TLS::Policy& policy)
@@ -230,7 +230,8 @@ class TLS_Asio_HTTP_Session final : public std::enable_shared_from_this<TLS_Asio
 
          m_client_socket.async_read_some(
             boost::asio::buffer(&m_c2s[0], m_c2s.size()),
-            m_strand.wrap(
+            boost::asio::bind_executor(
+               m_strand,
                boost::bind(
                   &TLS_Asio_HTTP_Session::client_read, shared_from_this(),
                   boost::asio::placeholders::error,
@@ -332,7 +333,8 @@ class TLS_Asio_HTTP_Session final : public std::enable_shared_from_this<TLS_Asio
             boost::asio::async_write(
                m_client_socket,
                boost::asio::buffer(&m_s2c[0], m_s2c.size()),
-               m_strand.wrap(
+               boost::asio::bind_executor(
+                  m_strand,
                   boost::bind(
                      &TLS_Asio_HTTP_Session::handle_client_write_completion,
                      shared_from_this(),
@@ -406,7 +408,7 @@ class TLS_Asio_HTTP_Session final : public std::enable_shared_from_this<TLS_Asio
             }
          }
 
-      boost::asio::io_service::strand m_strand;
+      boost::asio::io_context::strand m_strand;
 
       tcp::socket m_client_socket;
 
@@ -427,7 +429,7 @@ class TLS_Asio_HTTP_Server final
       typedef TLS_Asio_HTTP_Session session;
 
       TLS_Asio_HTTP_Server(
-         boost::asio::io_service& io, unsigned short port,
+         boost::asio::io_context& io, unsigned short port,
          Botan::Credentials_Manager& creds,
          Botan::TLS::Policy& policy,
          Botan::TLS::Session_Manager& session_mgr,
@@ -551,7 +553,7 @@ class TLS_HTTP_Server final : public Command
             session_mgr.reset(new Botan::TLS::Session_Manager_In_Memory(rng()));
             }
 
-         boost::asio::io_service io;
+         boost::asio::io_context io;
 
          TLS_Asio_HTTP_Server server(io, listen_port, creds, *policy, *session_mgr, max_clients);
 
diff --git a/src/cli/tls_proxy.cpp b/src/cli/tls_proxy.cpp
index bd96530c202..853be08161c 100644
--- a/src/cli/tls_proxy.cpp
+++ b/src/cli/tls_proxy.cpp
@@ -98,11 +98,11 @@ class tls_proxy_session final : public std::enable_shared_from_this<tls_proxy_se
       typedef std::shared_ptr<tls_proxy_session> pointer;
 
       static pointer create(
-         boost::asio::io_service& io,
+         boost::asio::io_context& io,
          Botan::TLS::Session_Manager& session_manager,
          Botan::Credentials_Manager& credentials,
          Botan::TLS::Policy& policy,
-         tcp::resolver::iterator endpoints)
+         tcp::resolver::results_type endpoints)
          {
          return pointer(
                    new tls_proxy_session(
@@ -141,11 +141,11 @@ class tls_proxy_session final : public std::enable_shared_from_this<tls_proxy_se
 
    private:
       tls_proxy_session(
-         boost::asio::io_service& io,
+         boost::asio::io_context& io,
          Botan::TLS::Session_Manager& session_manager,
          Botan::Credentials_Manager& credentials,
          Botan::TLS::Policy& policy,
-         tcp::resolver::iterator endpoints)
+         tcp::resolver::results_type endpoints)
          : m_strand(io)
          , m_server_endpoints(endpoints)
          , m_client_socket(io)
@@ -184,7 +184,8 @@ class tls_proxy_session final : public std::enable_shared_from_this<tls_proxy_se
 
          m_client_socket.async_read_some(
             boost::asio::buffer(&m_c2p[0], m_c2p.size()),
-            m_strand.wrap(
+            boost::asio::bind_executor(
+               m_strand,
                boost::bind(
                   &tls_proxy_session::client_read, shared_from_this(),
                   boost::asio::placeholders::error,
@@ -245,7 +246,8 @@ class tls_proxy_session final : public std::enable_shared_from_this<tls_proxy_se
             boost::asio::async_write(
                m_client_socket,
                boost::asio::buffer(&m_p2c[0], m_p2c.size()),
-               m_strand.wrap(
+               boost::asio::bind_executor(
+                  m_strand,
                   boost::bind(
                      &tls_proxy_session::handle_client_write_completion,
                      shared_from_this(),
@@ -270,11 +272,11 @@ class tls_proxy_session final : public std::enable_shared_from_this<tls_proxy_se
             boost::asio::async_write(
                m_server_socket,
                boost::asio::buffer(&m_p2s[0], m_p2s.size()),
-               m_strand.wrap(
-                  boost::bind(
-                     &tls_proxy_session::handle_server_write_completion,
-                     shared_from_this(),
-                     boost::asio::placeholders::error)));
+               boost::asio::bind_executor(m_strand,
+                                          boost::bind(
+                                             &tls_proxy_session::handle_server_write_completion,
+                                             shared_from_this(),
+                                             boost::asio::placeholders::error)));
             }
          }
 
@@ -308,7 +310,8 @@ class tls_proxy_session final : public std::enable_shared_from_this<tls_proxy_se
 
          m_server_socket.async_read_some(
             boost::asio::buffer(&m_s2p[0], m_s2p.size()),
-            m_strand.wrap(
+            boost::asio::bind_executor(
+               m_strand,
                boost::bind(&tls_proxy_session::server_read, shared_from_this(),
                            boost::asio::placeholders::error,
                            boost::asio::placeholders::bytes_transferred)));
@@ -318,7 +321,8 @@ class tls_proxy_session final : public std::enable_shared_from_this<tls_proxy_se
          {
          m_hostname = session.server_info().hostname();
 
-         auto onConnect = [this](boost::system::error_code ec, tcp::resolver::iterator /*endpoint*/)
+         auto onConnect = [this](boost::system::error_code ec,
+                                 const boost::asio::ip::tcp::resolver::results_type::iterator& /*endpoint*/)
             {
             if(ec)
                {
@@ -328,7 +332,7 @@ class tls_proxy_session final : public std::enable_shared_from_this<tls_proxy_se
             server_read(boost::system::error_code(), 0); // start read loop
             proxy_write_to_server(nullptr, 0);
             };
-         async_connect(m_server_socket, m_server_endpoints, onConnect);
+         async_connect(m_server_socket, m_server_endpoints.begin(), m_server_endpoints.end(), onConnect);
          return true;
          }
 
@@ -341,9 +345,9 @@ class tls_proxy_session final : public std::enable_shared_from_this<tls_proxy_se
             }
          }
 
-      boost::asio::io_service::strand m_strand;
+      boost::asio::io_context::strand m_strand;
 
-      tcp::resolver::iterator m_server_endpoints;
+      tcp::resolver::results_type m_server_endpoints;
 
       tcp::socket m_client_socket;
       tcp::socket m_server_socket;
@@ -369,8 +373,8 @@ class tls_proxy_server final
       typedef tls_proxy_session session;
 
       tls_proxy_server(
-         boost::asio::io_service& io, unsigned short port,
-         tcp::resolver::iterator endpoints,
+         boost::asio::io_context& io, unsigned short port,
+         tcp::resolver::results_type endpoints,
          Botan::Credentials_Manager& creds,
          Botan::TLS::Policy& policy,
          Botan::TLS::Session_Manager& session_mgr,
@@ -428,7 +432,7 @@ class tls_proxy_server final
          }
 
       tcp::acceptor m_acceptor;
-      tcp::resolver::iterator m_server_endpoints;
+      tcp::resolver::results_type m_server_endpoints;
 
       Botan::Credentials_Manager& m_creds;
       Botan::TLS::Policy& m_policy;
@@ -479,10 +483,10 @@ class TLS_Proxy final : public Command
 
          auto policy = load_tls_policy(get_arg("policy"));
 
-         boost::asio::io_service io;
+         boost::asio::io_context io;
 
          tcp::resolver resolver(io);
-         auto server_endpoint_iterator = resolver.resolve({ target, target_port });
+         auto server_endpoint_iterator = resolver.resolve(target, target_port);
 
          std::unique_ptr<Botan::TLS::Session_Manager> session_mgr;
 
diff --git a/src/lib/utils/socket/socket.cpp b/src/lib/utils/socket/socket.cpp
index bc632259a64..0ce4e85830f 100644
--- a/src/lib/utils/socket/socket.cpp
+++ b/src/lib/utils/socket/socket.cpp
@@ -48,19 +48,17 @@ class Asio_Socket final : public OS::Socket
                   std::chrono::milliseconds timeout) :
          m_timeout(timeout), m_timer(m_io), m_tcp(m_io)
          {
-         m_timer.expires_from_now(m_timeout);
+         m_timer.expires_after(m_timeout);
          check_timeout();
 
          boost::asio::ip::tcp::resolver resolver(m_io);
-         boost::asio::ip::tcp::resolver::query query(hostname, service);
-         boost::asio::ip::tcp::resolver::iterator dns_iter = resolver.resolve(query);
+         boost::asio::ip::tcp::resolver::results_type endpoints = resolver.resolve(hostname, service);
 
          boost::system::error_code ec = boost::asio::error::would_block;
 
          auto connect_cb = [&ec](const boost::system::error_code& e,
-                                 boost::asio::ip::tcp::resolver::iterator) { ec = e; };
-
-         boost::asio::async_connect(m_tcp, dns_iter, connect_cb);
+                                 const boost::asio::ip::tcp::resolver::results_type::iterator&) { ec = e; };
+         boost::asio::async_connect(m_tcp, endpoints.begin(), endpoints.end(), connect_cb);
 
          while(ec == boost::asio::error::would_block)
             {
@@ -75,7 +73,7 @@ class Asio_Socket final : public OS::Socket
 
       void write(const uint8_t buf[], size_t len) override
          {
-         m_timer.expires_from_now(m_timeout);
+         m_timer.expires_after(m_timeout);
 
          boost::system::error_code ec = boost::asio::error::would_block;
 
@@ -92,7 +90,7 @@ class Asio_Socket final : public OS::Socket
 
       size_t read(uint8_t buf[], size_t len) override
          {
-         m_timer.expires_from_now(m_timeout);
+         m_timer.expires_after(m_timeout);
 
          boost::system::error_code ec = boost::asio::error::would_block;
          size_t got = 0;
@@ -115,7 +113,7 @@ class Asio_Socket final : public OS::Socket
    private:
       void check_timeout()
          {
-         if(m_tcp.is_open() && m_timer.expires_at() < std::chrono::system_clock::now())
+         if(m_tcp.is_open() && m_timer.expiry() < std::chrono::system_clock::now())
             {
             boost::system::error_code err;
             m_tcp.close(err);
@@ -125,7 +123,7 @@ class Asio_Socket final : public OS::Socket
          }
 
       const std::chrono::milliseconds m_timeout;
-      boost::asio::io_service m_io;
+      boost::asio::io_context m_io;
       boost::asio::system_timer m_timer;
       boost::asio::ip::tcp::socket m_tcp;
    };
diff --git a/src/lib/utils/socket/socket_udp.cpp b/src/lib/utils/socket/socket_udp.cpp
index fbbdd9abbcc..82a25b49cda 100644
--- a/src/lib/utils/socket/socket_udp.cpp
+++ b/src/lib/utils/socket/socket_udp.cpp
@@ -48,19 +48,17 @@ class Asio_SocketUDP final : public OS::SocketUDP
                      std::chrono::microseconds timeout) :
          m_timeout(timeout), m_timer(m_io), m_udp(m_io)
          {
-         m_timer.expires_from_now(m_timeout);
+         m_timer.expires_after(m_timeout);
          check_timeout();
 
          boost::asio::ip::udp::resolver resolver(m_io);
-         boost::asio::ip::udp::resolver::query query(hostname, service);
-         boost::asio::ip::udp::resolver::iterator dns_iter = resolver.resolve(query);
+         boost::asio::ip::udp::resolver::results_type endpoints = resolver.resolve(hostname, service);
 
          boost::system::error_code ec = boost::asio::error::would_block;
 
          auto connect_cb = [&ec](const boost::system::error_code& e,
-         boost::asio::ip::udp::resolver::iterator) { ec = e; };
-
-         boost::asio::async_connect(m_udp, dns_iter, connect_cb);
+                                 const boost::asio::ip::udp::resolver::results_type::iterator&) { ec = e; };
+         boost::asio::async_connect(m_udp, endpoints.begin(), endpoints.end(), connect_cb);
 
          while(ec == boost::asio::error::would_block)
             {
@@ -75,7 +73,7 @@ class Asio_SocketUDP final : public OS::SocketUDP
 
       void write(const uint8_t buf[], size_t len) override
          {
-         m_timer.expires_from_now(m_timeout);
+         m_timer.expires_after(m_timeout);
 
          boost::system::error_code ec = boost::asio::error::would_block;
 
@@ -95,7 +93,7 @@ class Asio_SocketUDP final : public OS::SocketUDP
 
       size_t read(uint8_t buf[], size_t len) override
          {
-         m_timer.expires_from_now(m_timeout);
+         m_timer.expires_after(m_timeout);
 
          boost::system::error_code ec = boost::asio::error::would_block;
          size_t got = 0;
@@ -121,7 +119,7 @@ class Asio_SocketUDP final : public OS::SocketUDP
    private:
       void check_timeout()
          {
-         if(m_udp.is_open() && m_timer.expires_at() < std::chrono::system_clock::now())
+         if(m_udp.is_open() && m_timer.expiry() < std::chrono::system_clock::now())
             {
             boost::system::error_code err;
             m_udp.close(err);
@@ -131,7 +129,7 @@ class Asio_SocketUDP final : public OS::SocketUDP
          }
 
       const std::chrono::microseconds m_timeout;
-      boost::asio::io_service m_io;
+      boost::asio::io_context m_io;
       boost::asio::system_timer m_timer;
       boost::asio::ip::udp::socket m_udp;
    };