From e6d5dd2b71fc7df8f4ab3320cd35342ae4a00b83 Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Sun, 18 Sep 2016 10:46:45 +0200 Subject: [PATCH] New utility --- tlib/include/tlib/dns.hpp | 2 ++ tlib/src/dns.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tlib/include/tlib/dns.hpp b/tlib/include/tlib/dns.hpp index 0b952c6f..d7f29ad6 100644 --- a/tlib/include/tlib/dns.hpp +++ b/tlib/include/tlib/dns.hpp @@ -24,6 +24,8 @@ std::expected send_request(tlib::socket& sock, const std::string& domain, std::expected resolve(const std::string& domain, size_t timeout = 1000, size_t retries = 1); +tlib::ip::address gateway_address(); + } // end of namespace dns } // end of namespace tlib diff --git a/tlib/src/dns.cpp b/tlib/src/dns.cpp index 2d4e82de..2d5fea7e 100644 --- a/tlib/src/dns.cpp +++ b/tlib/src/dns.cpp @@ -37,6 +37,10 @@ std::string tlib::dns::decode_domain(char* payload, size_t& offset) { return domain; } +tlib::ip::address tlib::dns::gateway_address(){ + return tlib::ip::make_address(10, 0, 2, 3); +} + std::expected tlib::dns::send_request(tlib::socket& sock, const std::string& domain, uint16_t rr_type, uint16_t rr_class){ auto parts = std::split(domain, '.'); @@ -45,7 +49,7 @@ std::expected tlib::dns::send_request(tlib::socket& sock, const std::strin tlib::dns::packet_descriptor desc; desc.payload_size = labels + characters + 1 + 2 * 2; - desc.target_ip = tlib::ip::make_address(10, 0, 2, 3); + desc.target_ip = gateway_address(); desc.identification = 0x666; desc.query = true;