working now
parent
d4eaa5e1aa
commit
841597d46f
Binary file not shown.
|
@ -25,3 +25,9 @@
|
|||
7588 7791 1698262928938405252 insane_dns ff5ae500893d0be1
|
||||
5 7595 1698262972765775585 CMakeFiles/insane_dns.dir/src/main.cpp.o 727da43cdbc82421
|
||||
7595 7803 1698262972985772451 insane_dns ff5ae500893d0be1
|
||||
3 2885 1698265110010893560 CMakeFiles/insane_dns.dir/src/main.cpp.o 727da43cdbc82421
|
||||
2885 2976 1698265110106892250 insane_dns ff5ae500893d0be1
|
||||
2 2934 1698265309664228253 CMakeFiles/insane_dns.dir/src/main.cpp.o 727da43cdbc82421
|
||||
2935 3019 1698265309752227101 insane_dns ff5ae500893d0be1
|
||||
2 3015 1698266342759371787 CMakeFiles/insane_dns.dir/src/main.cpp.o 727da43cdbc82421
|
||||
3015 3112 1698266342859370576 insane_dns ff5ae500893d0be1
|
||||
|
|
Binary file not shown.
|
@ -1,3 +1,3 @@
|
|||
Start testing: Oct 25 15:42 EDT
|
||||
Start testing: Oct 25 16:39 EDT
|
||||
----------------------------------------------------------
|
||||
End testing: Oct 25 15:42 EDT
|
||||
End testing: Oct 25 16:39 EDT
|
||||
|
|
Binary file not shown.
5
src/ip.h
5
src/ip.h
|
@ -21,7 +21,10 @@ struct IPAddress
|
|||
auto data = blt::string::split(str, '.');
|
||||
BLT_ASSERT(data.size() == 4);
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
data[i] = static_cast<unsigned char>(std::stoul(data[i]));
|
||||
{
|
||||
octets[i] = static_cast<unsigned char>(std::stoul(data[i]));
|
||||
BLT_TRACE("%d", octets[i]);
|
||||
}
|
||||
}
|
||||
|
||||
constexpr IPAddress(unsigned char oct[4])
|
||||
|
|
33
src/main.cpp
33
src/main.cpp
|
@ -21,7 +21,7 @@
|
|||
* | CONFIG |
|
||||
* ----------------------------
|
||||
*/
|
||||
// should we strictly match results? ie block *.wikipedia.org or just wikipedia.org?
|
||||
// should we strictly match results? ie block *wikipedia.org* or just wikipedia.org?
|
||||
static constexpr bool STRICT_MATCHING = false;
|
||||
// true -> only match A records ; false -> match any named record (A, AAAA, CNAME)
|
||||
static constexpr bool STRICT_FILTERING = false;
|
||||
|
@ -170,6 +170,11 @@ class answer
|
|||
BLT_TRACE("%d, %d, %d, %d, %d", NAME, TYPE, CLASS, TTL, RDLENGTH);
|
||||
}
|
||||
|
||||
[[nodiscard]] uint16_t type() const
|
||||
{
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
void substitute(const IPAddress& addr)
|
||||
{
|
||||
BLT_ASSERT(RDLENGTH == 4);
|
||||
|
@ -235,9 +240,6 @@ class send_buffer
|
|||
} else if constexpr (std::is_same_v<T, std::string>)
|
||||
{
|
||||
static_assert("No");
|
||||
// std::memcpy(&internal_data[write_index], &t[0], t.length());
|
||||
// write_index += t.length();
|
||||
// write('\0');
|
||||
} else if constexpr (std::is_same_v<T, answer>)
|
||||
{
|
||||
write(t.NAME);
|
||||
|
@ -291,6 +293,19 @@ class send_buffer
|
|||
}
|
||||
};
|
||||
|
||||
bool shouldReplace(const answer& a)
|
||||
{
|
||||
return a.type() == 1;
|
||||
}
|
||||
|
||||
void process_answers(std::vector<answer>& answers)
|
||||
{
|
||||
for (auto& a : answers)
|
||||
{
|
||||
if (shouldReplace(a))
|
||||
a.substitute(REPLACEMENT_IP());
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -336,8 +351,14 @@ int main()
|
|||
}
|
||||
|
||||
BLT_INFO("DOMAIN: %s", q().c_str());
|
||||
for (auto& a : answers)
|
||||
a.substitute(REPLACEMENT_IP());
|
||||
if (STRICT_MATCHING && DISALLOWED_DOMAINS.contains(q()))
|
||||
process_answers(answers);
|
||||
else if (!STRICT_MATCHING)
|
||||
{
|
||||
for (const auto& v : DISALLOWED_DOMAINS)
|
||||
if (blt::string::contains(q(), v))
|
||||
process_answers(answers);
|
||||
}
|
||||
|
||||
send_buffer send;
|
||||
send.write(mod_recv_buf.data(), 12);
|
||||
|
|
Loading…
Reference in New Issue