]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/ws-recursor.cc
7e8e99468429eeb7c10b804cf39420b7fa2f99a9
[thirdparty/pdns.git] / pdns / ws-recursor.cc
1 /*
2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * In addition, for the avoidance of any doubt, permission is granted to
10 * link this program with OpenSSL and to (re)distribute the binaries
11 * produced as the result of such linking.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25 #include "ws-recursor.hh"
26 #include "json.hh"
27
28 #include <string>
29 #include "namespaces.hh"
30 #include <iostream>
31 #include "iputils.hh"
32 #include "rec_channel.hh"
33 #include "arguments.hh"
34 #include "misc.hh"
35 #include "syncres.hh"
36 #include "dnsparser.hh"
37 #include "json11.hpp"
38 #include "webserver.hh"
39 #include "ws-api.hh"
40 #include "logger.hh"
41 #include "ext/incbin/incbin.h"
42 #include "rec-lua-conf.hh"
43 #include "rpzloader.hh"
44
45 extern thread_local FDMultiplexer* t_fdm;
46
47 using json11::Json;
48
49 void productServerStatisticsFetch(map<string,string>& out)
50 {
51 map<string,string> stats = getAllStatsMap();
52 out.swap(stats);
53 }
54
55 static void apiWriteConfigFile(const string& filebasename, const string& content)
56 {
57 if (::arg()["api-config-dir"].empty()) {
58 throw ApiException("Config Option \"api-config-dir\" must be set");
59 }
60
61 string filename = ::arg()["api-config-dir"] + "/" + filebasename + ".conf";
62 ofstream ofconf(filename.c_str());
63 if (!ofconf) {
64 throw ApiException("Could not open config fragment file '"+filename+"' for writing: "+stringerror());
65 }
66 ofconf << "# Generated by pdns-recursor REST API, DO NOT EDIT" << endl;
67 ofconf << content << endl;
68 ofconf.close();
69 }
70
71 static void apiServerConfigAllowFrom(HttpRequest* req, HttpResponse* resp)
72 {
73 if (req->method == "PUT" && !::arg().mustDo("api-readonly")) {
74 Json document = req->json();
75
76 auto jlist = document["value"];
77 if (!jlist.is_array()) {
78 throw ApiException("'value' must be an array");
79 }
80
81 NetmaskGroup nmg;
82 for (auto value : jlist.array_items()) {
83 try {
84 nmg.addMask(value.string_value());
85 } catch (const NetmaskException &e) {
86 throw ApiException(e.reason);
87 }
88 }
89
90 ostringstream ss;
91
92 // Clear allow-from-file if set, so our changes take effect
93 ss << "allow-from-file=" << endl;
94
95 // Clear allow-from, and provide a "parent" value
96 ss << "allow-from=" << endl;
97 ss << "allow-from+=" << nmg.toString() << endl;
98
99 apiWriteConfigFile("allow-from", ss.str());
100
101 parseACLs();
102
103 // fall through to GET
104 } else if (req->method != "GET") {
105 throw HttpMethodNotAllowedException();
106 }
107
108 // Return currently configured ACLs
109 vector<string> entries;
110 t_allowFrom->toStringVector(&entries);
111
112 resp->setBody(Json::object {
113 { "name", "allow-from" },
114 { "value", entries },
115 });
116 }
117
118 static void fillZone(const DNSName& zonename, HttpResponse* resp)
119 {
120 auto iter = SyncRes::t_sstorage.domainmap->find(zonename);
121 if (iter == SyncRes::t_sstorage.domainmap->end())
122 throw ApiException("Could not find domain '"+zonename.toLogString()+"'");
123
124 const SyncRes::AuthDomain& zone = iter->second;
125
126 Json::array servers;
127 for(const ComboAddress& server : zone.d_servers) {
128 servers.push_back(server.toStringWithPort());
129 }
130
131 Json::array records;
132 for(const SyncRes::AuthDomain::records_t::value_type& dr : zone.d_records) {
133 records.push_back(Json::object {
134 { "name", dr.d_name.toString() },
135 { "type", DNSRecordContent::NumberToType(dr.d_type) },
136 { "ttl", (double)dr.d_ttl },
137 { "content", dr.d_content->getZoneRepresentation() }
138 });
139 }
140
141 // id is the canonical lookup key, which doesn't actually match the name (in some cases)
142 string zoneId = apiZoneNameToId(iter->first);
143 Json::object doc = {
144 { "id", zoneId },
145 { "url", "/api/v1/servers/localhost/zones/" + zoneId },
146 { "name", iter->first.toString() },
147 { "kind", zone.d_servers.empty() ? "Native" : "Forwarded" },
148 { "servers", servers },
149 { "recursion_desired", zone.d_servers.empty() ? false : zone.d_rdForward },
150 { "records", records }
151 };
152
153 resp->setBody(doc);
154 }
155
156 static void doCreateZone(const Json document)
157 {
158 if (::arg()["api-config-dir"].empty()) {
159 throw ApiException("Config Option \"api-config-dir\" must be set");
160 }
161
162 DNSName zonename = apiNameToDNSName(stringFromJson(document, "name"));
163 apiCheckNameAllowedCharacters(zonename.toString());
164
165 string singleIPTarget = document["single_target_ip"].string_value();
166 string kind = toUpper(stringFromJson(document, "kind"));
167 bool rd = boolFromJson(document, "recursion_desired");
168 string confbasename = "zone-" + apiZoneNameToId(zonename);
169
170 if (kind == "NATIVE") {
171 if (rd)
172 throw ApiException("kind=Native and recursion_desired are mutually exclusive");
173 if(!singleIPTarget.empty()) {
174 try {
175 ComboAddress rem(singleIPTarget);
176 if(rem.sin4.sin_family != AF_INET)
177 throw ApiException("");
178 singleIPTarget = rem.toString();
179 }
180 catch(...) {
181 throw ApiException("Single IP target '"+singleIPTarget+"' is invalid");
182 }
183 }
184 string zonefilename = ::arg()["api-config-dir"] + "/" + confbasename + ".zone";
185 ofstream ofzone(zonefilename.c_str());
186 if (!ofzone) {
187 throw ApiException("Could not open '"+zonefilename+"' for writing: "+stringerror());
188 }
189 ofzone << "; Generated by pdns-recursor REST API, DO NOT EDIT" << endl;
190 ofzone << zonename << "\tIN\tSOA\tlocal.zone.\thostmaster."<<zonename<<" 1 1 1 1 1" << endl;
191 if(!singleIPTarget.empty()) {
192 ofzone <<zonename << "\t3600\tIN\tA\t"<<singleIPTarget<<endl;
193 ofzone <<"*."<<zonename << "\t3600\tIN\tA\t"<<singleIPTarget<<endl;
194 }
195 ofzone.close();
196
197 apiWriteConfigFile(confbasename, "auth-zones+=" + zonename.toString() + "=" + zonefilename);
198 } else if (kind == "FORWARDED") {
199 string serverlist;
200 for (auto value : document["servers"].array_items()) {
201 string server = value.string_value();
202 if (server == "") {
203 throw ApiException("Forwarded-to server must not be an empty string");
204 }
205 try {
206 ComboAddress ca = parseIPAndPort(server, 53);
207 if (!serverlist.empty()) {
208 serverlist += ";";
209 }
210 serverlist += ca.toStringWithPort();
211 } catch (const PDNSException &e) {
212 throw ApiException(e.reason);
213 }
214 }
215 if (serverlist == "")
216 throw ApiException("Need at least one upstream server when forwarding");
217
218 if (rd) {
219 apiWriteConfigFile(confbasename, "forward-zones-recurse+=" + zonename.toString() + "=" + serverlist);
220 } else {
221 apiWriteConfigFile(confbasename, "forward-zones+=" + zonename.toString() + "=" + serverlist);
222 }
223 } else {
224 throw ApiException("invalid kind");
225 }
226 }
227
228 static bool doDeleteZone(const DNSName& zonename)
229 {
230 if (::arg()["api-config-dir"].empty()) {
231 throw ApiException("Config Option \"api-config-dir\" must be set");
232 }
233
234 string filename;
235
236 // this one must exist
237 filename = ::arg()["api-config-dir"] + "/zone-" + apiZoneNameToId(zonename) + ".conf";
238 if (unlink(filename.c_str()) != 0) {
239 return false;
240 }
241
242 // .zone file is optional
243 filename = ::arg()["api-config-dir"] + "/zone-" + apiZoneNameToId(zonename) + ".zone";
244 unlink(filename.c_str());
245
246 return true;
247 }
248
249 static void apiServerZones(HttpRequest* req, HttpResponse* resp)
250 {
251 if (req->method == "POST" && !::arg().mustDo("api-readonly")) {
252 if (::arg()["api-config-dir"].empty()) {
253 throw ApiException("Config Option \"api-config-dir\" must be set");
254 }
255
256 Json document = req->json();
257
258 DNSName zonename = apiNameToDNSName(stringFromJson(document, "name"));
259
260 auto iter = SyncRes::t_sstorage.domainmap->find(zonename);
261 if (iter != SyncRes::t_sstorage.domainmap->end())
262 throw ApiException("Zone already exists");
263
264 doCreateZone(document);
265 reloadAuthAndForwards();
266 fillZone(zonename, resp);
267 resp->status = 201;
268 return;
269 }
270
271 if(req->method != "GET")
272 throw HttpMethodNotAllowedException();
273
274 Json::array doc;
275 for(const SyncRes::domainmap_t::value_type& val : *SyncRes::t_sstorage.domainmap) {
276 const SyncRes::AuthDomain& zone = val.second;
277 Json::array servers;
278 for(const ComboAddress& server : zone.d_servers) {
279 servers.push_back(server.toStringWithPort());
280 }
281 // id is the canonical lookup key, which doesn't actually match the name (in some cases)
282 string zoneId = apiZoneNameToId(val.first);
283 doc.push_back(Json::object {
284 { "id", zoneId },
285 { "url", "/api/v1/servers/localhost/zones/" + zoneId },
286 { "name", val.first.toString() },
287 { "kind", zone.d_servers.empty() ? "Native" : "Forwarded" },
288 { "servers", servers },
289 { "recursion_desired", zone.d_servers.empty() ? false : zone.d_rdForward }
290 });
291 }
292 resp->setBody(doc);
293 }
294
295 static void apiServerZoneDetail(HttpRequest* req, HttpResponse* resp)
296 {
297 DNSName zonename = apiZoneIdToName(req->parameters["id"]);
298
299 SyncRes::domainmap_t::const_iterator iter = SyncRes::t_sstorage.domainmap->find(zonename);
300 if (iter == SyncRes::t_sstorage.domainmap->end())
301 throw ApiException("Could not find domain '"+zonename.toLogString()+"'");
302
303 if(req->method == "PUT" && !::arg().mustDo("api-readonly")) {
304 Json document = req->json();
305
306 doDeleteZone(zonename);
307 doCreateZone(document);
308 reloadAuthAndForwards();
309 resp->body = "";
310 resp->status = 204; // No Content, but indicate success
311 }
312 else if(req->method == "DELETE" && !::arg().mustDo("api-readonly")) {
313 if (!doDeleteZone(zonename)) {
314 throw ApiException("Deleting domain failed");
315 }
316
317 reloadAuthAndForwards();
318 // empty body on success
319 resp->body = "";
320 resp->status = 204; // No Content: declare that the zone is gone now
321 } else if(req->method == "GET") {
322 fillZone(zonename, resp);
323 } else {
324 throw HttpMethodNotAllowedException();
325 }
326 }
327
328 static void apiServerSearchData(HttpRequest* req, HttpResponse* resp) {
329 if(req->method != "GET")
330 throw HttpMethodNotAllowedException();
331
332 string q = req->getvars["q"];
333 if (q.empty())
334 throw ApiException("Query q can't be blank");
335
336 Json::array doc;
337 for(const SyncRes::domainmap_t::value_type& val : *SyncRes::t_sstorage.domainmap) {
338 string zoneId = apiZoneNameToId(val.first);
339 string zoneName = val.first.toString();
340 if (pdns_ci_find(zoneName, q) != string::npos) {
341 doc.push_back(Json::object {
342 { "type", "zone" },
343 { "zone_id", zoneId },
344 { "name", zoneName }
345 });
346 }
347
348 // if zone name is an exact match, don't bother with returning all records/comments in it
349 if (val.first == DNSName(q)) {
350 continue;
351 }
352
353 const SyncRes::AuthDomain& zone = val.second;
354
355 for(const SyncRes::AuthDomain::records_t::value_type& rr : zone.d_records) {
356 if (pdns_ci_find(rr.d_name.toString(), q) == string::npos && pdns_ci_find(rr.d_content->getZoneRepresentation(), q) == string::npos)
357 continue;
358
359 doc.push_back(Json::object {
360 { "type", "record" },
361 { "zone_id", zoneId },
362 { "zone_name", zoneName },
363 { "name", rr.d_name.toString() },
364 { "content", rr.d_content->getZoneRepresentation() }
365 });
366 }
367 }
368 resp->setBody(doc);
369 }
370
371 static void apiServerCacheFlush(HttpRequest* req, HttpResponse* resp) {
372 if(req->method != "PUT")
373 throw HttpMethodNotAllowedException();
374
375 DNSName canon = apiNameToDNSName(req->getvars["domain"]);
376
377 int count = broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeCache, canon, false));
378 count += broadcastAccFunction<uint64_t>(boost::bind(pleaseWipePacketCache, canon, false));
379 count += broadcastAccFunction<uint64_t>(boost::bind(pleaseWipeAndCountNegCache, canon, false));
380 resp->setBody(Json::object {
381 { "count", count },
382 { "result", "Flushed cache." }
383 });
384 }
385
386 static void apiServerRPZStats(HttpRequest* req, HttpResponse* resp) {
387 if(req->method != "GET")
388 throw HttpMethodNotAllowedException();
389
390 auto luaconf = g_luaconfs.getLocal();
391 auto numZones = luaconf->dfe.size();
392
393 Json::object ret;
394
395 for (size_t i=0; i < numZones; i++) {
396 auto zone = luaconf->dfe.getZone(i);
397 if (zone == nullptr)
398 continue;
399 auto name = zone->getName();
400 auto stats = getRPZZoneStats(*name);
401 if (stats == nullptr)
402 continue;
403 Json::object zoneInfo = {
404 {"transfers_failed", (double)stats->d_failedTransfers},
405 {"transfers_success", (double)stats->d_successfulTransfers},
406 {"transfers_full", (double)stats->d_fullTransfers},
407 {"records", (double)stats->d_numberOfRecords},
408 {"last_update", (double)stats->d_lastUpdate},
409 {"serial", (double)stats->d_serial},
410 };
411 ret[*name] = zoneInfo;
412 }
413 resp->setBody(ret);
414 }
415
416 #include "htmlfiles.h"
417
418 static void serveStuff(HttpRequest* req, HttpResponse* resp)
419 {
420 resp->headers["Cache-Control"] = "max-age=86400";
421
422 if(req->url.path == "/")
423 req->url.path = "/index.html";
424
425 const string charset = "; charset=utf-8";
426 if(boost::ends_with(req->url.path, ".html"))
427 resp->headers["Content-Type"] = "text/html" + charset;
428 else if(boost::ends_with(req->url.path, ".css"))
429 resp->headers["Content-Type"] = "text/css" + charset;
430 else if(boost::ends_with(req->url.path,".js"))
431 resp->headers["Content-Type"] = "application/javascript" + charset;
432 else if(boost::ends_with(req->url.path, ".png"))
433 resp->headers["Content-Type"] = "image/png";
434
435 resp->headers["X-Content-Type-Options"] = "nosniff";
436 resp->headers["X-Frame-Options"] = "deny";
437 resp->headers["X-Permitted-Cross-Domain-Policies"] = "none";
438
439 resp->headers["X-XSS-Protection"] = "1; mode=block";
440 // resp->headers["Content-Security-Policy"] = "default-src 'self'; style-src 'self' 'unsafe-inline'";
441
442 resp->body = g_urlmap[req->url.path.c_str()+1];
443 resp->status = 200;
444 }
445
446
447 RecursorWebServer::RecursorWebServer(FDMultiplexer* fdm)
448 {
449 registerAllStats();
450
451 d_ws = new AsyncWebServer(fdm, arg()["webserver-address"], arg().asNum("webserver-port"));
452 d_ws->bind();
453
454 // legacy dispatch
455 d_ws->registerApiHandler("/jsonstat", boost::bind(&RecursorWebServer::jsonstat, this, _1, _2));
456 d_ws->registerApiHandler("/api/v1/servers/localhost/cache/flush", &apiServerCacheFlush);
457 d_ws->registerApiHandler("/api/v1/servers/localhost/config/allow-from", &apiServerConfigAllowFrom);
458 d_ws->registerApiHandler("/api/v1/servers/localhost/config", &apiServerConfig);
459 d_ws->registerApiHandler("/api/v1/servers/localhost/rpzstatistics", &apiServerRPZStats);
460 d_ws->registerApiHandler("/api/v1/servers/localhost/search-log", &apiServerSearchLog);
461 d_ws->registerApiHandler("/api/v1/servers/localhost/search-data", &apiServerSearchData);
462 d_ws->registerApiHandler("/api/v1/servers/localhost/statistics", &apiServerStatistics);
463 d_ws->registerApiHandler("/api/v1/servers/localhost/zones/<id>", &apiServerZoneDetail);
464 d_ws->registerApiHandler("/api/v1/servers/localhost/zones", &apiServerZones);
465 d_ws->registerApiHandler("/api/v1/servers/localhost", &apiServerDetail);
466 d_ws->registerApiHandler("/api/v1/servers", &apiServer);
467 d_ws->registerApiHandler("/api", &apiDiscovery);
468
469 for(const auto& u : g_urlmap)
470 d_ws->registerWebHandler("/"+u.first, serveStuff);
471 d_ws->registerWebHandler("/", serveStuff);
472 d_ws->go();
473 }
474
475 void RecursorWebServer::jsonstat(HttpRequest* req, HttpResponse *resp)
476 {
477 string command;
478
479 if(req->getvars.count("command")) {
480 command = req->getvars["command"];
481 req->getvars.erase("command");
482 }
483
484 map<string, string> stats;
485 if(command == "get-query-ring") {
486 typedef pair<DNSName,uint16_t> query_t;
487 vector<query_t> queries;
488 bool filter=!req->getvars["public-filtered"].empty();
489
490 if(req->getvars["name"]=="servfail-queries")
491 queries=broadcastAccFunction<vector<query_t> >(pleaseGetServfailQueryRing);
492 else if(req->getvars["name"]=="queries")
493 queries=broadcastAccFunction<vector<query_t> >(pleaseGetQueryRing);
494
495 typedef map<query_t,unsigned int> counts_t;
496 counts_t counts;
497 unsigned int total=0;
498 for(const query_t& q : queries) {
499 total++;
500 if(filter)
501 counts[make_pair(getRegisteredName(q.first), q.second)]++;
502 else
503 counts[make_pair(q.first, q.second)]++;
504 }
505
506 typedef std::multimap<int, query_t> rcounts_t;
507 rcounts_t rcounts;
508
509 for(counts_t::const_iterator i=counts.begin(); i != counts.end(); ++i)
510 rcounts.insert(make_pair(-i->second, i->first));
511
512 Json::array entries;
513 unsigned int tot=0, totIncluded=0;
514 for(const rcounts_t::value_type& q : rcounts) {
515 totIncluded-=q.first;
516 entries.push_back(Json::array {
517 -q.first, q.second.first.toString(), DNSRecordContent::NumberToType(q.second.second)
518 });
519 if(tot++>=100)
520 break;
521 }
522 if(queries.size() != totIncluded) {
523 entries.push_back(Json::array {
524 (int)(queries.size() - totIncluded), "", ""
525 });
526 }
527 resp->setBody(Json::object { { "entries", entries } });
528 return;
529 }
530 else if(command == "get-remote-ring") {
531 vector<ComboAddress> queries;
532 if(req->getvars["name"]=="remotes")
533 queries=broadcastAccFunction<vector<ComboAddress> >(pleaseGetRemotes);
534 else if(req->getvars["name"]=="servfail-remotes")
535 queries=broadcastAccFunction<vector<ComboAddress> >(pleaseGetServfailRemotes);
536 else if(req->getvars["name"]=="large-answer-remotes")
537 queries=broadcastAccFunction<vector<ComboAddress> >(pleaseGetLargeAnswerRemotes);
538
539 typedef map<ComboAddress,unsigned int,ComboAddress::addressOnlyLessThan> counts_t;
540 counts_t counts;
541 unsigned int total=0;
542 for(const ComboAddress& q : queries) {
543 total++;
544 counts[q]++;
545 }
546
547 typedef std::multimap<int, ComboAddress> rcounts_t;
548 rcounts_t rcounts;
549
550 for(counts_t::const_iterator i=counts.begin(); i != counts.end(); ++i)
551 rcounts.insert(make_pair(-i->second, i->first));
552
553 Json::array entries;
554 unsigned int tot=0, totIncluded=0;
555 for(const rcounts_t::value_type& q : rcounts) {
556 totIncluded-=q.first;
557 entries.push_back(Json::array {
558 -q.first, q.second.toString()
559 });
560 if(tot++>=100)
561 break;
562 }
563 if(queries.size() != totIncluded) {
564 entries.push_back(Json::array {
565 (int)(queries.size() - totIncluded), ""
566 });
567 }
568
569 resp->setBody(Json::object { { "entries", entries } });
570 return;
571 } else {
572 resp->setErrorResult("Command '"+command+"' not found", 404);
573 }
574 }
575
576
577 void AsyncServerNewConnectionMT(void *p) {
578 AsyncServer *server = (AsyncServer*)p;
579
580 try {
581 auto socket = server->accept(); // this is actually a shared_ptr
582 if (socket) {
583 server->d_asyncNewConnectionCallback(socket);
584 }
585 } catch (NetworkError &e) {
586 // we're running in a shared process/thread, so can't just terminate/abort.
587 L<<Logger::Warning<<"Network error in web thread: "<<e.what()<<endl;
588 return;
589 }
590 catch (...) {
591 L<<Logger::Warning<<"Unknown error in web thread"<<endl;
592
593 return;
594 }
595
596 }
597
598 void AsyncServer::asyncWaitForConnections(FDMultiplexer* fdm, const newconnectioncb_t& callback)
599 {
600 d_asyncNewConnectionCallback = callback;
601 fdm->addReadFD(d_server_socket.getHandle(), boost::bind(&AsyncServer::newConnection, this));
602 }
603
604 void AsyncServer::newConnection()
605 {
606 getMT()->makeThread(&AsyncServerNewConnectionMT, this);
607 }
608
609 // This is an entry point from FDM, so it needs to catch everything.
610 void AsyncWebServer::serveConnection(std::shared_ptr<Socket> client) const
611 try {
612 HttpRequest req;
613 YaHTTP::AsyncRequestLoader yarl;
614 yarl.initialize(&req);
615 client->setNonBlocking();
616
617 string data;
618 try {
619 while(!req.complete) {
620 int bytes = arecvtcp(data, 16384, client.get(), true);
621 if (bytes > 0) {
622 req.complete = yarl.feed(data);
623 } else {
624 // read error OR EOF
625 break;
626 }
627 }
628 yarl.finalize();
629 } catch (YaHTTP::ParseError &e) {
630 // request stays incomplete
631 }
632
633 HttpResponse resp;
634 handleRequest(req, resp);
635 ostringstream ss;
636 resp.write(ss);
637 data = ss.str();
638
639 // now send the reply
640 if (asendtcp(data, client.get()) == -1 || data.empty()) {
641 L<<Logger::Error<<"Failed sending reply to HTTP client"<<endl;
642 }
643 }
644 catch(PDNSException &e) {
645 L<<Logger::Error<<"HTTP Exception: "<<e.reason<<endl;
646 }
647 catch(std::exception &e) {
648 if(strstr(e.what(), "timeout")==0)
649 L<<Logger::Error<<"HTTP STL Exception: "<<e.what()<<endl;
650 }
651 catch(...) {
652 L<<Logger::Error<<"HTTP: Unknown exception"<<endl;
653 }
654
655 void AsyncWebServer::go() {
656 if (!d_server)
657 return;
658 auto server = std::dynamic_pointer_cast<AsyncServer>(d_server);
659 if (!server)
660 return;
661 server->asyncWaitForConnections(d_fdm, boost::bind(&AsyncWebServer::serveConnection, this, _1));
662 }