]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/ws-recursor.hh
auth: switch circleci mssql image
[thirdparty/pdns.git] / pdns / ws-recursor.hh
CommitLineData
a7a902fb 1/*
12471842
PL
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 */
680f25f8
RK
22#ifndef PDNS_WSRECURSOR_HH
23#define PDNS_WSRECURSOR_HH
24
a7a902fb
BH
25#include <boost/utility.hpp>
26#include "namespaces.hh"
27#include "mplexer.hh"
825fa717 28#include "webserver.hh"
6ec5e728 29
6ec5e728
CH
30class HttpRequest;
31class HttpResponse;
a7a902fb 32
825fa717
CH
33class AsyncServer : public Server {
34public:
35 AsyncServer(const string &localaddress, int port) : Server(localaddress, port) { };
36
37 friend void AsyncServerNewConnectionMT(void *p);
38
d4c53d8c 39 typedef boost::function< void(std::shared_ptr<Socket>) > newconnectioncb_t;
825fa717
CH
40 void asyncWaitForConnections(FDMultiplexer* fdm, const newconnectioncb_t& callback);
41
42private:
43 void newConnection();
44
45 newconnectioncb_t d_asyncNewConnectionCallback;
46};
47
48class AsyncWebServer : public WebServer
49{
50public:
bbef8f04
CH
51 AsyncWebServer(FDMultiplexer* fdm, const string &listenaddress, int port) :
52 WebServer(listenaddress, port), d_fdm(fdm) { };
825fa717
CH
53 void go();
54
55private:
56 FDMultiplexer* d_fdm;
b184a9dc 57 void serveConnection(std::shared_ptr<Socket> socket) const;
825fa717
CH
58
59protected:
690984d4
RG
60 virtual std::shared_ptr<Server> createServer() override {
61 return std::make_shared<AsyncServer>(d_listenaddress, d_port);
825fa717
CH
62 };
63};
64
1ce57618 65class RecursorWebServer : public boost::noncopyable
a7a902fb 66{
3ae143b0 67public:
1ce57618 68 explicit RecursorWebServer(FDMultiplexer* fdm);
3ae143b0
CH
69 void jsonstat(HttpRequest* req, HttpResponse *resp);
70
71private:
72 AsyncWebServer* d_ws;
a7a902fb 73};
680f25f8
RK
74
75#endif /* PDNS_WSRECURSOR_HH */