66#include " DnstapException.h"
77#include " ThreadName.h"
88#include < filesystem>
9+ #ifdef __GNUC__
10+ #pragma GCC diagnostic push
11+ #pragma GCC diagnostic ignored "-Wunused-parameter"
12+ #endif
913#include < uvw/async.h>
1014#include < uvw/loop.h>
1115#include < uvw/pipe.h>
1216#include < uvw/stream.h>
1317#include < uvw/tcp.h>
1418#include < uvw/timer.h>
19+ #ifdef __GNUC__
20+ #pragma GCC diagnostic pop
21+ #endif
1522
1623namespace visor ::input::dnstap {
1724
@@ -129,16 +136,16 @@ void DnstapInputStream::_create_frame_stream_tcp_socket()
129136 }
130137
131138 // main io loop, run in its own thread
132- _io_loop = uvw::Loop ::create ();
139+ _io_loop = uvw::loop ::create ();
133140 if (!_io_loop) {
134141 throw DnstapException (" unable to create io loop" );
135142 }
136143 // AsyncHandle lets us stop the loop from its own thread
137- _async_h = _io_loop->resource <uvw::AsyncHandle >();
144+ _async_h = _io_loop->resource <uvw::async_handle >();
138145 if (!_async_h) {
139146 throw DnstapException (" unable to initialize AsyncHandle" );
140147 }
141- _async_h->once <uvw::AsyncEvent >([this ](const auto &, auto &handle) {
148+ _async_h->on <uvw::async_event >([this ](const auto &, auto &handle) {
142149 _timer->stop ();
143150 _timer->close ();
144151 _tcp_server_h->stop ();
@@ -147,16 +154,16 @@ void DnstapInputStream::_create_frame_stream_tcp_socket()
147154 _io_loop->close ();
148155 handle.close ();
149156 });
150- _async_h->on <uvw::ErrorEvent >([this ](const auto &err, auto &handle) {
157+ _async_h->on <uvw::error_event >([this ](const auto &err, auto &handle) {
151158 _logger->error (" [{}] AsyncEvent error: {}" , _name, err.what ());
152159 handle.close ();
153160 });
154161
155- _timer = _io_loop->resource <uvw::TimerHandle >();
162+ _timer = _io_loop->resource <uvw::timer_handle >();
156163 if (!_timer) {
157164 throw DnstapException (" unable to initialize TimerHandle" );
158165 }
159- _timer->on <uvw::TimerEvent >([this ](const auto &, auto &) {
166+ _timer->on <uvw::timer_event >([this ](const auto &, auto &) {
160167 timespec stamp;
161168 // use now()
162169 std::timespec_get (&stamp, TIME_UTC);
@@ -165,25 +172,25 @@ void DnstapInputStream::_create_frame_stream_tcp_socket()
165172 static_cast <DnstapInputEventProxy *>(proxy.get ())->heartbeat_cb (stamp);
166173 }
167174 });
168- _timer->on <uvw::ErrorEvent >([this ](const auto &err, auto &handle) {
175+ _timer->on <uvw::error_event >([this ](const auto &err, auto &handle) {
169176 _logger->error (" [{}] TimerEvent error: {}" , _name, err.what ());
170177 handle.close ();
171178 });
172179
173180 // setup server socket
174- _tcp_server_h = _io_loop->resource <uvw::TCPHandle >();
181+ _tcp_server_h = _io_loop->resource <uvw::tcp_handle >();
175182 if (!_tcp_server_h) {
176- throw DnstapException (" unable to initialize server PipeHandle " );
183+ throw DnstapException (" unable to initialize server pipe_handle " );
177184 }
178185
179- _tcp_server_h->on <uvw::ErrorEvent >([this ](const auto &err, auto &) {
186+ _tcp_server_h->on <uvw::error_event >([this ](const auto &err, auto &) {
180187 _logger->error (" [{}] socket error: {}" , _name, err.what ());
181188 throw DnstapException (err.what ());
182189 });
183190
184- // ListenEvent happens on client connection
185- _tcp_server_h->on <uvw::ListenEvent >([this ](const uvw::ListenEvent &, uvw::TCPHandle &) {
186- auto client = _io_loop->resource <uvw::TCPHandle >();
191+ // listen_event happens on client connection
192+ _tcp_server_h->on <uvw::listen_event >([this ](const uvw::listen_event &, uvw::tcp_handle &) {
193+ auto client = _io_loop->resource <uvw::tcp_handle >();
187194 if (!client) {
188195 throw DnstapException (" unable to initialize connected client TCPHandle" );
189196 }
@@ -209,14 +216,14 @@ void DnstapInputStream::_create_frame_stream_tcp_socket()
209216 }
210217 };
211218
212- client->on <uvw::ErrorEvent >([this ](const uvw::ErrorEvent &err, uvw::TCPHandle &c_sock) {
219+ client->on <uvw::error_event >([this ](const uvw::error_event &err, uvw::tcp_handle &c_sock) {
213220 _logger->error (" [{}]: dnstap client socket error: {}" , _name, err.what ());
214221 c_sock.stop ();
215222 c_sock.close ();
216223 });
217224
218225 // client sent data
219- client->on <uvw::DataEvent >([this ](const uvw::DataEvent &data, uvw::TCPHandle &c_sock) {
226+ client->on <uvw::data_event >([this ](const uvw::data_event &data, uvw::tcp_handle &c_sock) {
220227 assert (_tcp_sessions[c_sock.fd ()]);
221228 try {
222229 _tcp_sessions[c_sock.fd ()]->receive_socket_data (reinterpret_cast <uint8_t *>(data.data .get ()), data.length );
@@ -227,20 +234,20 @@ void DnstapInputStream::_create_frame_stream_tcp_socket()
227234 }
228235 });
229236 // client was closed
230- client->on <uvw::CloseEvent >([this ](const uvw::CloseEvent &, uvw::TCPHandle &c_sock) {
237+ client->on <uvw::close_event >([this ](const uvw::close_event &, uvw::tcp_handle &c_sock) {
231238 _logger->info (" [{}]: dnstap client disconnected" , _name);
232239 _tcp_sessions.erase (c_sock.fd ());
233240 });
234241 // client read EOF
235- client->on <uvw::EndEvent >([this ](const uvw::EndEvent &, uvw::TCPHandle &c_sock) {
242+ client->on <uvw::end_event >([this ](const uvw::end_event &, uvw::tcp_handle &c_sock) {
236243 _logger->info (" [{}]: dnstap client EOF {}" , _name, c_sock.peer ().ip );
237244 c_sock.stop ();
238245 c_sock.close ();
239246 });
240247
241248 _tcp_server_h->accept (*client);
242249 _logger->info (" [{}]: dnstap client connected {}" , _name, client->peer ().ip );
243- _tcp_sessions[client->fd ()] = std::make_unique<FrameSessionData<uvw::TCPHandle >>(client, CONTENT_TYPE, on_data_frame);
250+ _tcp_sessions[client->fd ()] = std::make_unique<FrameSessionData<uvw::tcp_handle >>(client, CONTENT_TYPE, on_data_frame);
244251 client->read ();
245252 });
246253
@@ -250,7 +257,7 @@ void DnstapInputStream::_create_frame_stream_tcp_socket()
250257
251258 // spawn the loop
252259 _io_thread = std::make_unique<std::thread>([this ] {
253- _timer->start (uvw::TimerHandle::Time {1000 }, uvw::TimerHandle::Time {HEARTBEAT_INTERVAL * 1000 });
260+ _timer->start (uvw::timer_handle::time {1000 }, uvw::timer_handle::time {HEARTBEAT_INTERVAL * 1000 });
254261 thread::change_self_name (schema_key (), name ());
255262 _io_loop->run ();
256263 });
@@ -260,16 +267,16 @@ void DnstapInputStream::_create_frame_stream_unix_socket()
260267 assert (config_exists (" socket" ));
261268
262269 // main io loop, run in its own thread
263- _io_loop = uvw::Loop ::create ();
270+ _io_loop = uvw::loop ::create ();
264271 if (!_io_loop) {
265272 throw DnstapException (" unable to create io loop" );
266273 }
267274 // AsyncHandle lets us stop the loop from its own thread
268- _async_h = _io_loop->resource <uvw::AsyncHandle >();
275+ _async_h = _io_loop->resource <uvw::async_handle >();
269276 if (!_async_h) {
270277 throw DnstapException (" unable to initialize AsyncHandle" );
271278 }
272- _async_h->once <uvw::AsyncEvent >([this ](const auto &, auto &handle) {
279+ _async_h->on <uvw::async_event >([this ](const auto &, auto &handle) {
273280 _timer->stop ();
274281 _timer->close ();
275282 _unix_server_h->stop ();
@@ -278,16 +285,16 @@ void DnstapInputStream::_create_frame_stream_unix_socket()
278285 _io_loop->close ();
279286 handle.close ();
280287 });
281- _async_h->on <uvw::ErrorEvent >([this ](const auto &err, auto &handle) {
288+ _async_h->on <uvw::error_event >([this ](const auto &err, auto &handle) {
282289 _logger->error (" [{}] AsyncEvent error: {}" , _name, err.what ());
283290 handle.close ();
284291 });
285292
286- _timer = _io_loop->resource <uvw::TimerHandle >();
293+ _timer = _io_loop->resource <uvw::timer_handle >();
287294 if (!_timer) {
288295 throw DnstapException (" unable to initialize TimerHandle" );
289296 }
290- _timer->on <uvw::TimerEvent >([this ](const auto &, auto &) {
297+ _timer->on <uvw::timer_event >([this ](const auto &, auto &) {
291298 timespec stamp;
292299 // use now()
293300 std::timespec_get (&stamp, TIME_UTC);
@@ -296,27 +303,27 @@ void DnstapInputStream::_create_frame_stream_unix_socket()
296303 static_cast <DnstapInputEventProxy *>(proxy.get ())->heartbeat_cb (stamp);
297304 }
298305 });
299- _timer->on <uvw::ErrorEvent >([this ](const auto &err, auto &handle) {
306+ _timer->on <uvw::error_event >([this ](const auto &err, auto &handle) {
300307 _logger->error (" [{}] TimerEvent error: {}" , _name, err.what ());
301308 handle.close ();
302309 });
303310
304311 // setup server socket
305- _unix_server_h = _io_loop->resource <uvw::PipeHandle >();
312+ _unix_server_h = _io_loop->resource <uvw::pipe_handle >();
306313 if (!_unix_server_h) {
307- throw DnstapException (" unable to initialize server PipeHandle " );
314+ throw DnstapException (" unable to initialize server pipe_handle " );
308315 }
309316
310- _unix_server_h->on <uvw::ErrorEvent >([this ](const auto &err, auto &) {
317+ _unix_server_h->on <uvw::error_event >([this ](const auto &err, auto &) {
311318 _logger->error (" [{}] socket error: {}" , _name, err.what ());
312319 throw DnstapException (err.what ());
313320 });
314321
315- // ListenEvent happens on client connection
316- _unix_server_h->on <uvw::ListenEvent >([this ](const uvw::ListenEvent &, uvw::PipeHandle &) {
317- auto client = _io_loop->resource <uvw::PipeHandle >();
322+ // listen_event happens on client connection
323+ _unix_server_h->on <uvw::listen_event >([this ](const uvw::listen_event &, uvw::pipe_handle &) {
324+ auto client = _io_loop->resource <uvw::pipe_handle >();
318325 if (!client) {
319- throw DnstapException (" unable to initialize connected client PipeHandle " );
326+ throw DnstapException (" unable to initialize connected client pipe_handle " );
320327 }
321328
322329 auto on_data_frame = [this ](const void *data, std::size_t len_data) {
@@ -339,14 +346,14 @@ void DnstapInputStream::_create_frame_stream_unix_socket()
339346 }
340347 };
341348
342- client->on <uvw::ErrorEvent >([this ](const uvw::ErrorEvent &err, uvw::PipeHandle &c_sock) {
349+ client->on <uvw::error_event >([this ](const uvw::error_event &err, uvw::pipe_handle &c_sock) {
343350 _logger->error (" [{}]: dnstap client socket error: {}" , _name, err.what ());
344351 c_sock.stop ();
345352 c_sock.close ();
346353 });
347354
348355 // client sent data
349- client->on <uvw::DataEvent >([this ](const uvw::DataEvent &data, uvw::PipeHandle &c_sock) {
356+ client->on <uvw::data_event >([this ](const uvw::data_event &data, uvw::pipe_handle &c_sock) {
350357 assert (_unix_sessions[c_sock.fd ()]);
351358 try {
352359 _unix_sessions[c_sock.fd ()]->receive_socket_data (reinterpret_cast <uint8_t *>(data.data .get ()), data.length );
@@ -357,20 +364,20 @@ void DnstapInputStream::_create_frame_stream_unix_socket()
357364 }
358365 });
359366 // client was closed
360- client->on <uvw::CloseEvent >([this ](const uvw::CloseEvent &, uvw::PipeHandle &c_sock) {
367+ client->on <uvw::close_event >([this ](const uvw::close_event &, uvw::pipe_handle &c_sock) {
361368 _logger->info (" [{}]: dnstap client disconnected" , _name);
362369 _unix_sessions.erase (c_sock.fd ());
363370 });
364371 // client read EOF
365- client->on <uvw::EndEvent >([this ](const uvw::EndEvent &, uvw::PipeHandle &c_sock) {
372+ client->on <uvw::end_event >([this ](const uvw::end_event &, uvw::pipe_handle &c_sock) {
366373 _logger->info (" [{}]: dnstap client EOF {}" , _name, c_sock.sock ());
367374 c_sock.stop ();
368375 c_sock.close ();
369376 });
370377
371378 _unix_server_h->accept (*client);
372379 _logger->info (" [{}]: dnstap client connected {}" , _name, client->sock ());
373- _unix_sessions[client->fd ()] = std::make_unique<FrameSessionData<uvw::PipeHandle >>(client, CONTENT_TYPE, on_data_frame);
380+ _unix_sessions[client->fd ()] = std::make_unique<FrameSessionData<uvw::pipe_handle >>(client, CONTENT_TYPE, on_data_frame);
374381 client->read ();
375382 });
376383
@@ -383,7 +390,7 @@ void DnstapInputStream::_create_frame_stream_unix_socket()
383390
384391 // spawn the loop
385392 _io_thread = std::make_unique<std::thread>([this ] {
386- _timer->start (uvw::TimerHandle::Time {1000 }, uvw::TimerHandle::Time {HEARTBEAT_INTERVAL * 1000 });
393+ _timer->start (uvw::timer_handle::time {1000 }, uvw::timer_handle::time {HEARTBEAT_INTERVAL * 1000 });
387394 thread::change_self_name (schema_key (), name ());
388395 _io_loop->run ();
389396 });
0 commit comments