mirror of
https://github.com/isc-projects/bind9.git
synced 2026-04-21 14:17:27 -04:00
1417. [func] ID.SERVER/CHAOS is now a built in zone.
See "server-id" for how to configure.
This commit is contained in:
parent
4154634631
commit
c4dc4fd856
7 changed files with 137 additions and 27 deletions
3
CHANGES
3
CHANGES
|
|
@ -6,6 +6,9 @@
|
|||
1500. [bug] host failed to lookup MX records. Also look up
|
||||
AAAA records.
|
||||
|
||||
1417. [func] ID.SERVER/CHAOS is now a built in zone.
|
||||
See "server-id" for how to configure.
|
||||
|
||||
1412. [func] You can now specify servers to be tried if a nameserver
|
||||
has IPv6 address and you only support IPv4 or the
|
||||
reverse. See dual-stack-servers.
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@
|
|||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: builtin.c,v 1.4.106.1 2003/08/13 03:58:09 marka Exp $ */
|
||||
/* $Id: builtin.c,v 1.4.106.2 2003/08/26 04:34:14 marka Exp $ */
|
||||
|
||||
/*
|
||||
* The built-in "version", "hostname", and "authors" databases.
|
||||
* The built-in "version", "hostname", "id" and "authors" databases.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
|
@ -43,6 +43,7 @@ typedef struct builtin builtin_t;
|
|||
static isc_result_t do_version_lookup(dns_sdblookup_t *lookup);
|
||||
static isc_result_t do_hostname_lookup(dns_sdblookup_t *lookup);
|
||||
static isc_result_t do_authors_lookup(dns_sdblookup_t *lookup);
|
||||
static isc_result_t do_id_lookup(dns_sdblookup_t *lookup);
|
||||
|
||||
/*
|
||||
* We can't use function pointers as the db_data directly
|
||||
|
|
@ -57,6 +58,7 @@ struct builtin {
|
|||
static builtin_t version_builtin = { do_version_lookup };
|
||||
static builtin_t hostname_builtin = { do_hostname_lookup };
|
||||
static builtin_t authors_builtin = { do_authors_lookup };
|
||||
static builtin_t id_builtin = { do_id_lookup };
|
||||
|
||||
static dns_sdbimplementation_t *builtin_impl;
|
||||
|
||||
|
|
@ -147,6 +149,23 @@ do_authors_lookup(dns_sdblookup_t *lookup) {
|
|||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
do_id_lookup(dns_sdblookup_t *lookup) {
|
||||
|
||||
if (ns_g_server->server_usehostname) {
|
||||
char buf[256];
|
||||
isc_result_t result = ns_os_gethostname(buf, sizeof(buf));
|
||||
if (result != ISC_R_SUCCESS)
|
||||
return (result);
|
||||
return (put_txt(lookup, buf));
|
||||
}
|
||||
|
||||
if (ns_g_server->server_id == NULL)
|
||||
return (ISC_R_SUCCESS);
|
||||
else
|
||||
return (put_txt(lookup, ns_g_server->server_id));
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
builtin_authority(const char *zone, void *dbdata, dns_sdblookup_t *lookup) {
|
||||
isc_result_t result;
|
||||
|
|
@ -178,6 +197,8 @@ builtin_create(const char *zone, int argc, char **argv,
|
|||
*dbdata = &hostname_builtin;
|
||||
else if (strcmp(argv[0], "authors") == 0)
|
||||
*dbdata = &authors_builtin;
|
||||
else if (strcmp(argv[0], "id") == 0)
|
||||
*dbdata = &id_builtin;
|
||||
else
|
||||
return (ISC_R_NOTIMPLEMENTED);
|
||||
return (ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: config.c,v 1.11.2.4.8.11 2003/08/25 04:16:16 marka Exp $ */
|
||||
/* $Id: config.c,v 1.11.2.4.8.12 2003/08/26 04:34:14 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
|
@ -76,6 +76,7 @@ options {\n\
|
|||
rrset-order {order cyclic;};\n\
|
||||
serial-queries 20;\n\
|
||||
serial-query-rate 20;\n\
|
||||
server-id none;\n\
|
||||
stacksize default;\n\
|
||||
statistics-file \"named.stats\";\n\
|
||||
statistics-interval 60;\n\
|
||||
|
|
@ -148,26 +149,30 @@ options {\n\
|
|||
zone-statistics false;\n\
|
||||
max-journal-size unlimited;\n\
|
||||
ixfr-from-differences false;\n\
|
||||
};
|
||||
|
||||
view \"_bind\" chaos {
|
||||
recursion no;
|
||||
|
||||
zone \"version.bind\" chaos {
|
||||
type master;
|
||||
database \"_builtin version\";
|
||||
};
|
||||
|
||||
zone \"hostname.bind\" chaos {
|
||||
type master;
|
||||
database \"_builtin hostname\";
|
||||
};
|
||||
|
||||
zone \"authors.bind\" chaos {
|
||||
type master;
|
||||
database \"_builtin authors\";
|
||||
};
|
||||
};
|
||||
};\n\
|
||||
\n\
|
||||
view \"_bind\" chaos {\n\
|
||||
recursion no;\n\
|
||||
\n\
|
||||
zone \"version.bind\" chaos {\n\
|
||||
type master;\n\
|
||||
database \"_builtin version\";\n\
|
||||
};\n\
|
||||
\n\
|
||||
zone \"hostname.bind\" chaos {\n\
|
||||
type master;\n\
|
||||
database \"_builtin hostname\";\n\
|
||||
};\n\
|
||||
\n\
|
||||
zone \"authors.bind\" chaos {\n\
|
||||
type master;\n\
|
||||
database \"_builtin authors\";\n\
|
||||
};\n\
|
||||
zone \"id.server\" chaos {\n\
|
||||
type master;\n\
|
||||
database \"_builtin id\";\n\
|
||||
};\n\
|
||||
};\n\
|
||||
";
|
||||
|
||||
isc_result_t
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: server.h,v 1.58.2.1.10.7 2003/08/21 06:17:57 marka Exp $ */
|
||||
/* $Id: server.h,v 1.58.2.1.10.8 2003/08/26 04:34:15 marka Exp $ */
|
||||
|
||||
#ifndef NAMED_SERVER_H
|
||||
#define NAMED_SERVER_H 1
|
||||
|
|
@ -56,6 +56,9 @@ struct ns_server {
|
|||
char * version; /* User-specified version */
|
||||
isc_boolean_t hostname_set; /* User has set hostname */
|
||||
char * hostname; /* User-specified hostname */
|
||||
/* Use hostname for server id */
|
||||
isc_boolean_t server_usehostname;
|
||||
char * server_id; /* User-specified server id */
|
||||
|
||||
/*
|
||||
* Current ACL environment. This defines the
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: server.c,v 1.339.2.15.2.26 2003/08/26 03:24:07 marka Exp $ */
|
||||
/* $Id: server.c,v 1.339.2.15.2.27 2003/08/26 04:34:14 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
|
@ -2301,6 +2301,18 @@ load_configuration(const char *filename, ns_server_t *server,
|
|||
server->hostname_set = ISC_FALSE;
|
||||
}
|
||||
|
||||
obj = NULL;
|
||||
result = ns_config_get(maps, "server-id", &obj);
|
||||
server->server_usehostname = ISC_FALSE;
|
||||
if (result == ISC_R_SUCCESS && cfg_obj_isboolean(obj)) {
|
||||
server->server_usehostname = ISC_TRUE;
|
||||
} else if (result == ISC_R_SUCCESS) {
|
||||
CHECKM(setoptstring(server, &server->server_id, obj), "strdup");
|
||||
} else {
|
||||
result = setoptstring(server, &server->server_id, NULL);
|
||||
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
obj = NULL;
|
||||
result = ns_config_get(maps, "flush-zones-on-shutdown", &obj);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
|
|
@ -2621,6 +2633,8 @@ ns_server_create(isc_mem_t *mctx, ns_server_t **serverp) {
|
|||
server->hostname = NULL;
|
||||
server->version_set = ISC_FALSE;
|
||||
server->version = NULL;
|
||||
server->server_usehostname = ISC_FALSE;
|
||||
server->server_id = NULL;
|
||||
|
||||
CHECKFATAL(dns_stats_alloccounters(ns_g_mctx, &server->querystats),
|
||||
"dns_stats_alloccounters");
|
||||
|
|
@ -2653,6 +2667,8 @@ ns_server_destroy(ns_server_t **serverp) {
|
|||
isc_mem_free(server->mctx, server->version);
|
||||
if (server->hostname != NULL)
|
||||
isc_mem_free(server->mctx, server->hostname);
|
||||
if (server->server_id != NULL)
|
||||
isc_mem_free(server->mctx, server->server_id);
|
||||
|
||||
dns_zonemgr_detach(&server->zonemgr);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.0//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd">
|
||||
|
||||
<!-- File: $Id: Bv9ARM-book.xml,v 1.155.2.27.2.20 2003/08/26 03:24:08 marka Exp $ -->
|
||||
<!-- File: $Id: Bv9ARM-book.xml,v 1.155.2.27.2.21 2003/08/26 04:34:16 marka Exp $ -->
|
||||
|
||||
<book>
|
||||
<title>BIND 9 Administrator Reference Manual</title>
|
||||
|
|
@ -2657,6 +2657,7 @@ statement in the <filename>named.conf</filename> file:</para>
|
|||
<programlisting>options {
|
||||
<optional> version <replaceable>version_string</replaceable>; </optional>
|
||||
<optional> hostname <replaceable>hostname_string</replaceable>; </optional>
|
||||
<optional> server-id <replaceable>server_id_string</replaceable>; </optional>
|
||||
<optional> directory <replaceable>path_name</replaceable>; </optional>
|
||||
<optional> key-directory <replaceable>path_name</replaceable>; </optional>
|
||||
<optional> named-xfer <replaceable>path_name</replaceable>; </optional>
|
||||
|
|
@ -2783,6 +2784,20 @@ answering your queries. Specifying <command>hostname none;</command>
|
|||
disables processing of the queries.</para>
|
||||
</listitem></varlistentry>
|
||||
|
||||
<varlistentry><term><command>server-id</command></term>
|
||||
<listitem><para>The ID of the server should report via a query of
|
||||
the name <filename>ID.SERVER</filename>
|
||||
with type <command>TXT</command>, class <command>CHAOS</command>.
|
||||
The primary purpose of such queries is to
|
||||
identify which of a group of anycast servers is actually
|
||||
answering your queries. Specifying <command>server-id none;</command>
|
||||
disables processing of the queries.
|
||||
Specifying <command>server-id hostname;</command> will cause named to
|
||||
use the hostname as found by gethostname().
|
||||
The default <command>server-id</command> is <command>none</command>.
|
||||
</para>
|
||||
</listitem></varlistentry>
|
||||
|
||||
<varlistentry><term><command>directory</command></term>
|
||||
<listitem><para>The working directory of the server.
|
||||
Any non-absolute pathnames in the configuration file will be taken
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: namedconf.c,v 1.21.44.10 2003/08/26 03:24:14 marka Exp $ */
|
||||
/* $Id: namedconf.c,v 1.21.44.11 2003/08/26 04:34:17 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
|
|
@ -442,6 +442,52 @@ doc_qstringornone(cfg_printer_t *pctx, const cfg_type_t *type) {
|
|||
static cfg_type_t cfg_type_qstringornone = {
|
||||
"qstringornone", parse_qstringornone, NULL, doc_qstringornone, NULL, NULL };
|
||||
|
||||
/*
|
||||
* keyword hostname
|
||||
*/
|
||||
|
||||
static void
|
||||
print_hostname(cfg_printer_t *pctx, cfg_obj_t *obj) {
|
||||
UNUSED(obj);
|
||||
cfg_print_chars(pctx, "hostname", 4);
|
||||
}
|
||||
|
||||
static cfg_type_t cfg_type_hostname = {
|
||||
"hostname", NULL, print_hostname, NULL, &cfg_rep_boolean, NULL
|
||||
};
|
||||
|
||||
/*
|
||||
* "server-id" arguement.
|
||||
*/
|
||||
|
||||
static isc_result_t
|
||||
parse_serverid(cfg_parser_t *pctx, const cfg_type_t *type,
|
||||
cfg_obj_t **ret)
|
||||
{
|
||||
isc_result_t result;
|
||||
CHECK(cfg_gettoken(pctx, CFG_LEXOPT_QSTRING));
|
||||
if (pctx->token.type == isc_tokentype_string &&
|
||||
strcasecmp(TOKEN_STRING(pctx), "none") == 0)
|
||||
return (cfg_create_obj(pctx, &cfg_type_none, ret));
|
||||
if (pctx->token.type == isc_tokentype_string &&
|
||||
strcasecmp(TOKEN_STRING(pctx), "hostname") == 0) {
|
||||
return (cfg_create_obj(pctx, &cfg_type_hostname, ret));
|
||||
}
|
||||
cfg_ungettoken(pctx);
|
||||
return (cfg_parse_qstring(pctx, type, ret));
|
||||
cleanup:
|
||||
return (result);
|
||||
}
|
||||
|
||||
static void
|
||||
doc_serverid(cfg_printer_t *pctx, const cfg_type_t *type) {
|
||||
UNUSED(type);
|
||||
cfg_print_chars(pctx, "( <quoted_string> | none | hostname )", 26);
|
||||
}
|
||||
|
||||
static cfg_type_t cfg_type_serverid = {
|
||||
"serverid", parse_serverid, NULL, doc_serverid, NULL, NULL };
|
||||
|
||||
/*
|
||||
* Clauses that can be found within the top level of the named.conf
|
||||
* file only.
|
||||
|
|
@ -507,6 +553,7 @@ options_clauses[] = {
|
|||
{ "recursive-clients", &cfg_type_uint32, 0 },
|
||||
{ "serial-queries", &cfg_type_uint32, CFG_CLAUSEFLAG_OBSOLETE },
|
||||
{ "serial-query-rate", &cfg_type_uint32, 0 },
|
||||
{ "server-id", &cfg_type_serverid, 0 },
|
||||
{ "stacksize", &cfg_type_size, 0 },
|
||||
{ "statistics-file", &cfg_type_qstring, 0 },
|
||||
{ "statistics-interval", &cfg_type_uint32, CFG_CLAUSEFLAG_NYI },
|
||||
|
|
|
|||
Loading…
Reference in a new issue