]>
Commit | Line | Data |
---|---|---|
12c86877 | 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 | */ | |
e8c59f2d | 22 | #pragma once |
12c86877 | 23 | #include "dns.hh" |
9f1d5826 | 24 | #include "iputils.hh" |
12c86877 BH |
25 | #include "dnsbackend.hh" |
26 | #include "packethandler.hh" | |
092f210a | 27 | #include <vector> |
cb0af1a1 | 28 | #include <mutex> |
8edfedf1 | 29 | #include <poll.h> |
76473b92 KM |
30 | #include <sys/select.h> |
31 | #include <sys/socket.h> | |
32 | #include <netinet/in.h> | |
33 | #include <arpa/inet.h> | |
34 | #include <sys/stat.h> | |
35 | #include <unistd.h> | |
36 | #include <netdb.h> | |
37 | #include <sys/uio.h> | |
38 | #include <sys/select.h> | |
12c86877 | 39 | |
10f4eea8 | 40 | #include "namespaces.hh" |
12c86877 BH |
41 | |
42 | class TCPNameserver | |
43 | { | |
44 | public: | |
092f210a | 45 | TCPNameserver(); |
12c86877 BH |
46 | ~TCPNameserver(); |
47 | void go(); | |
d322f931 | 48 | unsigned int numTCPConnections(); |
12c86877 BH |
49 | private: |
50 | ||
c2826d2e | 51 | static void sendPacket(std::unique_ptr<DNSPacket>& p, int outsock); |
809fe23f | 52 | static int readLength(int fd, ComboAddress *remote); |
cb0af1a1 | 53 | static void getQuestion(int fd, char *mesg, int pktlen, const ComboAddress& remote, unsigned int totalTime); |
c2826d2e RG |
54 | static int doAXFR(const DNSName &target, std::unique_ptr<DNSPacket>& q, int outsock); |
55 | static int doIXFR(std::unique_ptr<DNSPacket>& q, int outsock); | |
56 | static bool canDoAXFR(std::unique_ptr<DNSPacket>& q); | |
0ddde5fb | 57 | static void doConnection(int fd); |
cb0af1a1 | 58 | static void decrementClientCount(const ComboAddress& remote); |
12c86877 | 59 | void thread(void); |
0ddde5fb | 60 | static std::mutex s_plock; |
cb0af1a1 RG |
61 | static std::mutex s_clientsCountMutex; |
62 | static std::map<ComboAddress,size_t,ComboAddress::addressOnlyLessThan> s_clientsCount; | |
c2826d2e | 63 | static std::unique_ptr<PacketHandler> s_P; |
c2826d2e | 64 | static std::unique_ptr<Semaphore> d_connectionroom_sem; |
d322f931 | 65 | static unsigned int d_maxTCPConnections; |
9f1d5826 | 66 | static NetmaskGroup d_ng; |
cb0af1a1 RG |
67 | static size_t d_maxTransactionsPerConn; |
68 | static size_t d_maxConnectionsPerClient; | |
69 | static unsigned int d_idleTimeout; | |
70 | static unsigned int d_maxConnectionDuration; | |
12c86877 BH |
71 | |
72 | vector<int>d_sockets; | |
8edfedf1 | 73 | vector<struct pollfd> d_prfds; |
12c86877 | 74 | }; |