2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
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.
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.
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.
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.
22 #ifndef PDNS_WSRECURSOR_HH
23 #define PDNS_WSRECURSOR_HH
25 #include <boost/utility.hpp>
26 #include "namespaces.hh"
28 #include "webserver.hh"
33 class AsyncServer : public Server {
35 AsyncServer(const string &localaddress, int port) : Server(localaddress, port) { };
37 friend void AsyncServerNewConnectionMT(void *p);
39 typedef boost::function< void(std::shared_ptr<Socket>) > newconnectioncb_t;
40 void asyncWaitForConnections(FDMultiplexer* fdm, const newconnectioncb_t& callback);
45 newconnectioncb_t d_asyncNewConnectionCallback;
48 class AsyncWebServer : public WebServer
51 AsyncWebServer(FDMultiplexer* fdm, const string &listenaddress, int port) :
52 WebServer(listenaddress, port), d_fdm(fdm) { };
57 void serveConnection(std::shared_ptr<Socket> socket) const;
60 virtual std::shared_ptr<Server> createServer() override {
61 return std::make_shared<AsyncServer>(d_listenaddress, d_port);
65 class RecursorWebServer : public boost::noncopyable
68 explicit RecursorWebServer(FDMultiplexer* fdm);
69 void jsonstat(HttpRequest* req, HttpResponse *resp);
75 #endif /* PDNS_WSRECURSOR_HH */