system: task'ify every pending dns request

allow more than one request, until lwip api rejects the call
This commit is contained in:
Maxim Prokhorov
2023-03-15 17:01:54 +03:00
parent 8804de2130
commit 175c04acc1
3 changed files with 161 additions and 110 deletions

View File

@@ -934,7 +934,7 @@ void reverse(::terminal::CommandContext&& ctx) {
return;
}
const auto ip = networkGetHostByName(ctx.argv[1]);
const auto ip = network::dns::gethostbyname(ctx.argv[1]);
if (!ip.isSet()) {
terminalError(ctx, F("Host not found"));
return;
@@ -984,17 +984,22 @@ void connect_url(String url) {
}
const auto port = parsed.port;
networkGetHostByName(std::move(parsed.host),
[port](const String& host, IPAddress ip) {
const auto addr = Address{
.ip = ip,
.port = port,
};
network::dns::resolve(
std::move(parsed.host),
[port](network::dns::HostPtr host) {
if (host->err == ERR_OK) {
const auto addr = Address{
.ip = host->addr,
.port = port,
};
if (!connect(addr)) {
DEBUG_MSG_P(PSTR("[TELNET] Cannot connect to %s:%hu\n"),
host.c_str(), port);
if (connect(addr)) {
return;
}
}
DEBUG_MSG_P(PSTR("[TELNET] Cannot connect to %s:%hu\n"),
host->name.c_str(), port);
});
}