]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/dynlistener.hh
Merge pull request #14021 from Habbie/auth-lua-join-whitespace
[thirdparty/pdns.git] / pdns / dynlistener.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
BH
23#include <string>
24#include <vector>
12c86877 25#include <sys/types.h>
dc6aa7f5 26#include <cerrno>
12c86877
BH
27#include <iostream>
28#include <sstream>
040712e0
BH
29#include "iputils.hh"
30#include <boost/utility.hpp>
cc3afe25
BH
31#include <unistd.h>
32#include <sys/un.h>
33#include <dlfcn.h>
cc3afe25
BH
34#include <sys/socket.h>
35#include <netinet/in.h>
cc3afe25 36
10f4eea8 37#include "namespaces.hh"
12c86877 38
040712e0 39class DynListener : public boost::noncopyable
12c86877
BH
40{
41public:
040712e0
BH
42 explicit DynListener(const string &pname="");
43 explicit DynListener(const ComboAddress& addr);
e5d684f9 44 ~DynListener();
12c86877
BH
45 void go();
46 void theListener();
12c86877
BH
47
48 typedef string g_funk_t(const vector<string> &parts, Utility::pid_t ppid); // guido!
3c90953e
PD
49 typedef struct { g_funk_t *func; string args; string usage; } g_funkwithusage_t;
50 typedef map<string,g_funkwithusage_t> g_funkdb_t;
12c86877 51
3c90953e 52 static void registerFunc(const string &name, g_funk_t *gf, const string &usage="", const string &args="");
040712e0 53 static void registerRestFunc(g_funk_t *gf);
d267d1bf 54 static g_funk_t* getFunc(const string& fname) { return s_funcdb[fname].func; }
12c86877 55private:
e37300dc 56 void sendlines(const string &lines);
3c90953e 57 string getHelp();
cc3afe25
BH
58 string getLine();
59
040712e0
BH
60 void listenOnUnixDomain(const std::string& fname);
61 void listenOnTCP(const ComboAddress&);
62 void createSocketAndBind(int family, struct sockaddr*local, size_t len);
63
040712e0 64 NetmaskGroup d_tcprange;
eace2c24
RG
65 int d_s{-1};
66 int d_client{-1};
040712e0 67 bool d_nonlocal;
eace2c24
RG
68 bool d_tcp{false};
69 pid_t d_ppid{0};
12c86877 70
e5d684f9 71 string d_socketname;
040712e0
BH
72 ComboAddress d_socketaddress;
73 static g_funkdb_t s_funcdb;
74 static g_funk_t* s_restfunc;
ce19a815 75 bool testLive(const string& fname);
12c86877 76};