]>
Commit | Line | Data |
---|---|---|
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 |
30 | class HttpRequest; |
31 | class HttpResponse; | |
a7a902fb | 32 | |
825fa717 CH |
33 | class AsyncServer : public Server { |
34 | public: | |
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 | ||
42 | private: | |
43 | void newConnection(); | |
44 | ||
45 | newconnectioncb_t d_asyncNewConnectionCallback; | |
46 | }; | |
47 | ||
48 | class AsyncWebServer : public WebServer | |
49 | { | |
50 | public: | |
bbef8f04 CH |
51 | AsyncWebServer(FDMultiplexer* fdm, const string &listenaddress, int port) : |
52 | WebServer(listenaddress, port), d_fdm(fdm) { }; | |
825fa717 CH |
53 | void go(); |
54 | ||
55 | private: | |
56 | FDMultiplexer* d_fdm; | |
b184a9dc | 57 | void serveConnection(std::shared_ptr<Socket> socket) const; |
825fa717 CH |
58 | |
59 | protected: | |
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 | 65 | class RecursorWebServer : public boost::noncopyable |
a7a902fb | 66 | { |
3ae143b0 | 67 | public: |
1ce57618 | 68 | explicit RecursorWebServer(FDMultiplexer* fdm); |
3ae143b0 CH |
69 | void jsonstat(HttpRequest* req, HttpResponse *resp); |
70 | ||
71 | private: | |
72 | AsyncWebServer* d_ws; | |
a7a902fb | 73 | }; |
680f25f8 RK |
74 | |
75 | #endif /* PDNS_WSRECURSOR_HH */ |