]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/tcpreceiver.hh
rec: allow exception to proxy protocal usage for specific listen addresses
[thirdparty/pdns.git] / pdns / tcpreceiver.hh
CommitLineData
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>
8edfedf1 28#include <poll.h>
76473b92
KM
29#include <sys/select.h>
30#include <sys/socket.h>
31#include <netinet/in.h>
32#include <arpa/inet.h>
33#include <sys/stat.h>
34#include <unistd.h>
35#include <netdb.h>
36#include <sys/uio.h>
37#include <sys/select.h>
12c86877 38
24fb5774 39#include "lock.hh"
10f4eea8 40#include "namespaces.hh"
12c86877
BH
41
42class TCPNameserver
43{
44public:
092f210a 45 TCPNameserver();
12c86877
BH
46 ~TCPNameserver();
47 void go();
d322f931 48 unsigned int numTCPConnections();
12c86877
BH
49private:
50
02b4b703 51 static void sendPacket(std::unique_ptr<DNSPacket>& p, int outsock, bool last=true);
cb0af1a1 52 static void getQuestion(int fd, char *mesg, int pktlen, const ComboAddress& remote, unsigned int totalTime);
c2826d2e
RG
53 static int doAXFR(const DNSName &target, std::unique_ptr<DNSPacket>& q, int outsock);
54 static int doIXFR(std::unique_ptr<DNSPacket>& q, int outsock);
24fb5774 55 static bool canDoAXFR(std::unique_ptr<DNSPacket>& q, bool isAXFR, std::unique_ptr<PacketHandler>& packetHandler);
0ddde5fb 56 static void doConnection(int fd);
cb0af1a1 57 static void decrementClientCount(const ComboAddress& remote);
df8248ca 58 void thread();
24fb5774
RG
59 static LockGuarded<std::map<ComboAddress,size_t,ComboAddress::addressOnlyLessThan>> s_clientsCount;
60 static LockGuarded<std::unique_ptr<PacketHandler>> s_P;
c2826d2e 61 static std::unique_ptr<Semaphore> d_connectionroom_sem;
d322f931 62 static unsigned int d_maxTCPConnections;
9f1d5826 63 static NetmaskGroup d_ng;
cb0af1a1
RG
64 static size_t d_maxTransactionsPerConn;
65 static size_t d_maxConnectionsPerClient;
66 static unsigned int d_idleTimeout;
67 static unsigned int d_maxConnectionDuration;
12c86877
BH
68
69 vector<int>d_sockets;
8edfedf1 70 vector<struct pollfd> d_prfds;
12c86877 71};