From 229e605c15f9c299dcb1050197eaf772700d124d Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Fri, 27 Oct 2023 15:36:20 -0400 Subject: [PATCH] welp: --- src/main.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e51e085..a36b956 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,7 +33,9 @@ static constexpr unsigned short int SERVER_PORT = 5555; * How should we bind to the local machine? By default this will use IPv4 and IPv6 with the default ASIO endpoint. * Only change this if you really need to and know what you are doing. */ -static constexpr bind_address address{SERVER_PORT}; +static BLT_CPP20_CONSTEXPR bind_address address() { + return {SERVER_PORT}; +}; /** should we strictly match results? ie block `*wikipedia.org*` or just `wikipedia.org`? */ static constexpr bool STRICT_MATCHING = false; @@ -350,8 +352,7 @@ request_info handle_forward_request(MESSENGER messenger, const INFO& info, const // forward to google. size_t out_bytes; - const auto* const data = input_recv_buffer.data(); - messenger(DNS_SERVER_IP(), data, bytes, forward_recv_buffer, out_bytes); + messenger(DNS_SERVER_IP(), input_recv_buffer.data(), bytes, forward_recv_buffer, out_bytes); uint16_t num_of_answers; blt::mem::fromBytes(&forward_recv_buffer[info.ANSWERS_BEGIN], num_of_answers); @@ -390,6 +391,7 @@ void handle_response(const INFO& info, send_buffer& return_send_buffer, request_ } return_send_buffer.write(forward_recv_buffer.data(), info.HEADER_END); + // need to cache this value oh wait we aren't doing this anymore auto question_offset = return_send_buffer.size(); return_send_buffer.write(q); for (const answer& a : answers) @@ -407,7 +409,7 @@ void run_udp_server() { asio::io_context io_context; - udp::socket socket(io_context, toUDPEndpoint(address)); + udp::socket socket(io_context, toUDPEndpoint(address())); blt::scoped_buffer input_recv_buffer{PACKET_BUFFER_SIZE}; blt::scoped_buffer forward_recv_buffer{PACKET_BUFFER_SIZE}; @@ -437,7 +439,7 @@ void run_tcp_server() { asio::io_context io_context; - tcp::acceptor acceptor(io_context, toTCPEndpoint(address)); + tcp::acceptor acceptor(io_context, toTCPEndpoint(address())); blt::scoped_buffer input_recv_buffer{PACKET_BUFFER_SIZE}; blt::scoped_buffer forward_recv_buffer{PACKET_BUFFER_SIZE};