]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/rec_control.cc
disable the broken 'storing unknown records' code for now
[thirdparty/pdns.git] / pdns / rec_control.cc
CommitLineData
aaacf7f2
BH
1/*
2 PowerDNS Versatile Database Driven Nameserver
3 Copyright (C) 2006 PowerDNS.COM BV
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License version 2 as
7 published by the Free Software Foundation
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
06bd9ccf 16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
aaacf7f2 17*/
1d5b3ce6
BH
18#include "rec_channel.hh"
19#include <iostream>
20#include "ahuexception.hh"
aaacf7f2 21#include "arguments.hh"
e2928fdb 22#include "config.h"
1d5b3ce6
BH
23
24using namespace std;
25
b0f7d001
BH
26#ifndef RECURSOR
27#include "statbag.hh"
28StatBag S;
29#endif
30
aaacf7f2
BH
31ArgvMap &arg()
32{
33 static ArgvMap arg;
34 return arg;
35}
36
37static void initArguments(int argc, char** argv)
38{
39 arg().set("config-dir","Location of configuration directory (pdns.conf)")=SYSCONFDIR;
41f7a068 40
aaacf7f2 41 arg().set("socket-dir","Where the controlsocket will live")=LOCALSTATEDIR;
41f7a068 42 arg().set("socket-pid","When controlling multiple recursors, the target pid")="";
61203240 43 arg().set("timeout", "Number of seconds to wait for the recursor to respond")="5";
aaacf7f2
BH
44 arg().setCmd("help","Provide this helpful message");
45
46 arg().laxParse(argc,argv);
85c143a2
BH
47 if(arg().getCommands().empty() || arg().mustDo("help")) {
48 cerr<<"syntax: rec_control [options] command, options as below: "<<endl<<endl;
aaacf7f2
BH
49 cerr<<arg().helpstring(arg()["help"])<<endl;
50 exit(99);
51 }
52
53}
54
f6f016d1 55int main(int argc, char** argv)
1d5b3ce6 56try
f6f016d1 57{
aaacf7f2
BH
58 initArguments(argc, argv);
59
1d5b3ce6 60 RecursorControlChannel rccS;
41f7a068
BH
61 string sockname="pdns_recursor.controlsocket";
62 if(!arg()["socket-pid"].empty())
63 sockname+="."+arg()["socket-pid"];
64
65 rccS.connect(arg()["socket-dir"], sockname);
1d5b3ce6 66
aaacf7f2 67 const vector<string>&commands=arg().getCommands();
1d5b3ce6 68 string command;
a2bfc3ff 69 for(unsigned int i=0; i< commands.size(); ++i) {
aaacf7f2 70 if(i>0)
1d5b3ce6 71 command+=" ";
aaacf7f2 72 command+=commands[i];
1d5b3ce6 73 }
1d5b3ce6 74 rccS.send(command);
61203240 75 string receive=rccS.recv(0, arg().asNum("timeout"));
1d5b3ce6 76 cout<<receive;
dd9e83ed 77 return 0;
1d5b3ce6
BH
78}
79catch(AhuException& ae)
80{
81 cerr<<"Fatal: "<<ae.reason<<"\n";
dd9e83ed 82 return 1;
f6f016d1 83}