Commit 1fb8fa24 authored by Jeremy C. Reed's avatar Jeremy C. Reed
Browse files

The directory was renamed. The trac470 branch showed it removed.

But for some reason, it didn't get removed on the merge,
so deleting it now. This should have happened with commit r4165.


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@4166 e5f2f494-b856-4b98-b285-d166d9295462
parent 9a4f1e5f
SUBDIRS = . tests
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += -I$(top_srcdir)/src/bin -I$(top_builddir)/src/bin
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/cc -I$(top_builddir)/src/lib/cc
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/asiolink
AM_CPPFLAGS += -I$(top_builddir)/src/lib/asiolink
AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CXXFLAGS = $(B10_CXXFLAGS)
if USE_STATIC_LINK
AM_LDFLAGS = -static
endif
pkglibexecdir = $(libexecdir)/@PACKAGE@
CLEANFILES = *.gcno *.gcda recurse.spec spec_config.h
man_MANS = b10-recurse.8
EXTRA_DIST = $(man_MANS) b10-recurse.xml
if ENABLE_MAN
b10-recurse.8: b10-recurse.xml
xsltproc --novalid --xinclude --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $(srcdir)/b10-recurse.xml
endif
recurse.spec: recurse.spec.pre
$(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" recurse.spec.pre >$@
spec_config.h: spec_config.h.pre
$(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" spec_config.h.pre >$@
BUILT_SOURCES = spec_config.h
pkglibexec_PROGRAMS = b10-recurse
b10_recurse_SOURCES = recursor.cc recursor.h
b10_recurse_SOURCES += $(top_builddir)/src/bin/auth/change_user.h
b10_recurse_SOURCES += $(top_builddir)/src/bin/auth/common.h
b10_recurse_SOURCES += main.cc
b10_recurse_LDADD = $(top_builddir)/src/lib/dns/libdns++.la
b10_recurse_LDADD += $(top_builddir)/src/lib/config/libcfgclient.la
b10_recurse_LDADD += $(top_builddir)/src/lib/cc/libcc.la
b10_recurse_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
b10_recurse_LDADD += $(top_builddir)/src/lib/asiolink/libasiolink.la
b10_recurse_LDADD += $(top_builddir)/src/lib/xfr/libxfr.la
b10_recurse_LDADD += $(top_builddir)/src/lib/log/liblog.la
b10_recurse_LDADD += $(top_builddir)/src/bin/auth/change_user.o
b10_recurse_LDFLAGS = -pthread
# TODO: config.h.in is wrong because doesn't honor pkgdatadir
# and can't use @datadir@ because doesn't expand default ${prefix}
b10_recursedir = $(DESTDIR)$(pkgdatadir)
b10_recurse_DATA = recurse.spec
'\" t
.\" Title: b10-recurse
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\" Date: December 27, 2010
.\" Manual: BIND10
.\" Source: BIND10
.\" Language: English
.\"
.TH "B10\-RECURSE" "8" "December 27, 2010" "BIND10" "BIND10"
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
b10-recurse \- Recursive DNS server
.SH "SYNOPSIS"
.HP \w'\fBb10\-recurse\fR\ 'u
\fBb10\-recurse\fR [\fB\-u\ \fR\fB\fIusername\fR\fR] [\fB\-v\fR]
.SH "DESCRIPTION"
.PP
The
\fBb10\-recurse\fR
daemon provides the BIND 10 recursive DNS server\&. Normally it is started by the
\fBbind10\fR(8)
boss process\&.
.PP
This daemon communicates with other BIND 10 components over a
\fBb10-msgq\fR(8)
C\-Channel connection\&. If this connection is not established,
\fBb10\-recurse\fR
will exit\&.
.PP
It also receives its configurations from
\fBb10-cfgmgr\fR(8)\&. Currently no configuration commands are defined\&.
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
.PP
This prototype version only supports forwarding\&. Future versions will introduce full recursion, cache, lookup of local authoritative data (as in
\fBb10\-auth\fR), and DNSSEC validation\&.
.sp .5v
.RE
.SH "OPTIONS"
.PP
The arguments are as follows:
.PP
\fB\-u \fR\fB\fIusername\fR\fR
.RS 4
The user name of the
\fBb10\-recurse\fR
daemon\&. If specified, the daemon changes the process owner to the specified user\&. The
\fIusername\fR
must be either a valid numeric user ID or a valid user name\&. By default the daemon runs as the user who invokes it\&.
.RE
.PP
\fB\-v\fR
.RS 4
Enabled verbose mode\&. This enables diagnostic messages to STDERR\&.
.RE
.SH "FILES"
.PP
None\&.
.SH "SEE ALSO"
.PP
\fBb10-cfgmgr\fR(8),
\fBb10-cmdctl\fR(8),
\fBb10-msgq\fR(8),
\fBbind10\fR(8),
BIND 10 Guide\&.
.SH "HISTORY"
.PP
The
\fBb10\-recurse\fR
daemon was first coded in September 2010\&.
.SH "COPYRIGHT"
.br
Copyright \(co 2010 Internet Systems Consortium, Inc. ("ISC")
.br
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
[<!ENTITY mdash "&#8212;">]>
<!--
- Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- PERFORMANCE OF THIS SOFTWARE.
-->
<!-- $Id$ -->
<refentry>
<refentryinfo>
<date>December 27, 2010</date>
</refentryinfo>
<refmeta>
<refentrytitle>b10-recurse</refentrytitle>
<manvolnum>8</manvolnum>
<refmiscinfo>BIND10</refmiscinfo>
</refmeta>
<refnamediv>
<refname>b10-recurse</refname>
<refpurpose>Recursive DNS server</refpurpose>
</refnamediv>
<docinfo>
<copyright>
<year>2010</year>
<holder>Internet Systems Consortium, Inc. ("ISC")</holder>
</copyright>
</docinfo>
<refsynopsisdiv>
<cmdsynopsis>
<command>b10-recurse</command>
<arg><option>-u <replaceable>username</replaceable></option></arg>
<arg><option>-v</option></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>DESCRIPTION</title>
<para>The <command>b10-recurse</command> daemon provides the BIND 10
recursive DNS server. Normally it is started by the
<citerefentry><refentrytitle>bind10</refentrytitle><manvolnum>8</manvolnum></citerefentry>
boss process.
</para>
<para>
This daemon communicates with other BIND 10 components over a
<citerefentry><refentrytitle>b10-msgq</refentrytitle><manvolnum>8</manvolnum></citerefentry>
C-Channel connection. If this connection is not established,
<command>b10-recurse</command> will exit.
</para>
<para>
It also receives its configurations from
<citerefentry><refentrytitle>b10-cfgmgr</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
Currently no configuration commands are defined.
</para>
<note><para>
This prototype version only supports forwarding. Future versions
will introduce full recursion, cache, lookup of local authoritative
data (as in <command>b10-auth</command>), and DNSSEC validation.
</para></note>
</refsect1>
<refsect1>
<title>OPTIONS</title>
<para>The arguments are as follows:</para>
<variablelist>
<varlistentry>
<term><option>-u <replaceable>username</replaceable></option></term>
<listitem>
<para>
The user name of the <command>b10-recurse</command> daemon.
If specified, the daemon changes the process owner to the
specified user.
The <replaceable>username</replaceable> must be either a
valid numeric user ID or a valid user name.
By default the daemon runs as the user who invokes it.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option></term>
<listitem><para>
Enabled verbose mode. This enables diagnostic messages to
STDERR.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>FILES</title>
<para>
None.
</para>
<!-- TODO: this is not correct yet. -->
</refsect1>
<refsect1>
<title>SEE ALSO</title>
<para>
<citerefentry>
<refentrytitle>b10-cfgmgr</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>b10-cmdctl</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>b10-msgq</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle>bind10</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>,
<citetitle>BIND 10 Guide</citetitle>.
</para>
</refsect1>
<refsect1>
<title>HISTORY</title>
<para>
The <command>b10-recurse</command> daemon was first coded in
September 2010.
</para>
</refsect1>
</refentry><!--
- Local variables:
- mode: sgml
- End:
-->
// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
// $Id$
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <errno.h>
#include <string>
#include <iostream>
#include <boost/foreach.hpp>
#include <asiolink/asiolink.h>
#include <exceptions/exceptions.h>
#include <dns/buffer.h>
#include <dns/message.h>
#include <dns/messagerenderer.h>
#include <cc/session.h>
#include <cc/data.h>
#include <config/ccsession.h>
#include <xfr/xfrout_client.h>
#include <auth/change_user.h>
#include <auth/common.h>
#include <recurse/spec_config.h>
#include <recurse/recursor.h>
#include <log/dummylog.h>
using namespace std;
using namespace isc::cc;
using namespace isc::config;
using namespace isc::data;
using isc::log::dlog;
using namespace asiolink;
namespace {
// Default port current 5300 for testing purposes
static const string PROGRAM = "Recurse";
IOService io_service;
static Recursor *recursor;
ConstElementPtr
my_config_handler(ConstElementPtr new_config) {
return (recursor->updateConfig(new_config));
}
ConstElementPtr
my_command_handler(const string& command, ConstElementPtr args) {
ConstElementPtr answer = createAnswer();
if (command == "print_message") {
cout << args << endl;
/* let's add that message to our answer as well */
answer = createAnswer(0, args);
} else if (command == "shutdown") {
io_service.stop();
}
return (answer);
}
void
usage() {
cerr << "Usage: b10-recurse [-u user] [-v]" << endl;
cerr << "\t-u: change process UID to the specified user" << endl;
cerr << "\t-v: verbose output" << endl;
exit(1);
}
} // end of anonymous namespace
int
main(int argc, char* argv[]) {
isc::log::dprefix = "b10-recurse";
int ch;
const char* uid = NULL;
while ((ch = getopt(argc, argv, "u:v")) != -1) {
switch (ch) {
case 'u':
uid = optarg;
break;
case 'v':
isc::log::denabled = true;
break;
case '?':
default:
usage();
}
}
if (argc - optind > 0) {
usage();
}
if (isc::log::denabled) { // Show the command line
string cmdline("Command line:");
for (int i = 0; i < argc; ++ i) {
cmdline = cmdline + " " + argv[i];
}
dlog(cmdline);
}
int ret = 0;
Session* cc_session = NULL;
ModuleCCSession* config_session = NULL;
try {
string specfile;
if (getenv("B10_FROM_BUILD")) {
specfile = string(getenv("B10_FROM_BUILD")) +
"/src/bin/recurse/recurse.spec";
} else {
specfile = string(RECURSE_SPECFILE_LOCATION);
}
recursor = new Recursor();
dlog("Server created.");
SimpleCallback* checkin = recursor->getCheckinProvider();
DNSLookup* lookup = recursor->getDNSLookupProvider();
DNSAnswer* answer = recursor->getDNSAnswerProvider();
DNSService dns_service(io_service, checkin, lookup, answer);
recursor->setDNSService(dns_service);
dlog("IOService created.");
cc_session = new Session(io_service.get_io_service());
dlog("Configuration session channel created.");
config_session = new ModuleCCSession(specfile, *cc_session,
my_config_handler,
my_command_handler);
dlog("Configuration channel established.");
// FIXME: This does not belong here, but inside Boss
if (uid != NULL) {
changeUser(uid);
}
recursor->setConfigSession(config_session);
dlog("Config loaded");
dlog("Server started.");
io_service.run();
} catch (const std::exception& ex) {
dlog(string("Server failed: ") + ex.what());
ret = 1;
}
delete config_session;
delete cc_session;
delete recursor;
return (ret);
}
{
"module_spec": {
"module_name": "Recurse",
"module_description": "Recursive service",
"config_data": [
{
"item_name": "timeout",
"item_type": "integer",
"item_optional": False,
"item_default": 2000
},
{
"item_name": "retries",
"item_type": "integer",
"item_optional": False,
"item_default": 0
},
{
"item_name": "forward_addresses",
"item_type": "list",
"item_optional": True,
"item_default": [],
"list_item_spec" : {
"item_name": "address",
"item_type": "map",
"item_optional": False,
"item_default": {},
"map_item_spec": [
{
"item_name": "address",
"item_type": "string",
"item_optional": False,
"item_default": "::1"
},
{
"item_name": "port",
"item_type": "integer",
"item_optional": False,
"item_default": 53
}
]
}
},
{
"item_name": "listen_on",
"item_type": "list",
"item_optional": False,
"item_default": [
{
"address": "::1",
"port": 5300
},
{
"address": "127.0.0.1",
"port": 5300
},
],
"list_item_spec": {
"item_name": "address",
"item_type": "map",
"item_optional": False,
"item_default": {},
"map_item_spec": [
{
"item_name": "address",
"item_type": "string",
"item_optional": False,
"item_default": "::1"
},
{
"item_name": "port",
"item_type": "integer",
"item_optional": False,
"item_default": 5300
}
]
}
}
],
"commands": [
{
"command_name": "shutdown",
"command_description": "Shut down recursive DNS server",
"command_args": []
}
]
}
}
This diff is collapsed.
// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
// $Id$
#ifndef __RECURSOR_H
#define __RECURSOR_H 1
#include <string>
#include <vector>
#include <utility>
#include <cc/data.h>
#include <config/ccsession.h>
#include <asiolink/asiolink.h>
class RecursorImpl;
/**
* \short The recursive nameserver.
*
* It is a concreate class implementing recursive DNS server protocol
* processing. It is responsible for handling incoming DNS requests. It parses
* them, passes them deeper into the resolving machinery and then creates the
* answer. It doesn't really know about chasing referrals and similar, it
* simply plugs the parts that know into the network handling code.
*/
class Recursor {
///
/// \name Constructors, Assignment Operator and Destructor.
///
/// Note: The copy constructor and the assignment operator are
/// intentionally defined as private.
//@{
private:
Recursor(const Recursor& source);
Recursor& operator=(const Recursor& source);
public:
/// The constructor.
Recursor();
~Recursor();
//@}
/// \brief Process an incoming DNS message, then signal 'server' to resume