main
Brett 2023-10-27 15:36:20 -04:00
parent deb4ee52eb
commit 229e605c15
1 changed files with 7 additions and 5 deletions

View File

@ -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<unsigned char> input_recv_buffer{PACKET_BUFFER_SIZE};
blt::scoped_buffer<unsigned char> 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<unsigned char> input_recv_buffer{PACKET_BUFFER_SIZE};
blt::scoped_buffer<unsigned char> forward_recv_buffer{PACKET_BUFFER_SIZE};