Implemented the letsencrypt challange
This commit is contained in:
parent
8639a7d05e
commit
ee608ad0c8
@ -69,6 +69,18 @@ void WebDNSHandler::handle_message(const std::shared_ptr<DNSServerBinding>& bind
|
||||
a.set_type(query->qtype());
|
||||
a.set_ttl(120);
|
||||
a.builder<rrbuilder::A>().set_address(resp);
|
||||
} else if(query->qclass() == rrclass::IN && query->qtype() == rrtype::TXT) {
|
||||
auto dn = query->qname();
|
||||
if(dn == "_acme-challenge.con-gate.work") {
|
||||
std::cout << " Letsencrypt request\n";
|
||||
std::cout << " Sending predefined key\n";
|
||||
|
||||
auto& a = response.push_answer(query->qname());
|
||||
a.set_class(query->qclass());
|
||||
a.set_type(query->qtype());
|
||||
a.set_ttl(120);
|
||||
a.builder<rrbuilder::TXT>().set_text("-YEqeIGJqoOz5uLbUiUfK06--n3jtVoI__6WJY-Ehgk");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,6 +143,12 @@ namespace ts::dns {
|
||||
uint32_t address{0};
|
||||
);
|
||||
|
||||
define_builder(TXT, base,
|
||||
inline void set_text(const std::string& text) { this->_text = text; }
|
||||
private:
|
||||
std::string _text;
|
||||
);
|
||||
|
||||
#undef define_builder
|
||||
}
|
||||
}
|
||||
|
@ -119,4 +119,17 @@ bool rrbuilder::A::build(char *&buffer, size_t &max_size, std::string &error) {
|
||||
buffer += 4;
|
||||
max_size -= 4;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rrbuilder::TXT::build(char *&buffer, size_t &max_size, std::string &error) {
|
||||
if(max_size + 1 < this->_text.size()) {
|
||||
error = "buffer too small";
|
||||
return false;
|
||||
}
|
||||
|
||||
*buffer = this->_text.size();
|
||||
memcpy(buffer + 1, this->_text.data(), this->_text.size());
|
||||
buffer += this->_text.size() + 1;
|
||||
max_size -= this->_text.size() + 1;
|
||||
return true;
|
||||
}
|
Loading…
Reference in New Issue
Block a user