namedconf.c

来自「非常好的dns解析软件」· C语言 代码 · 共 2,050 行 · 第 1/5 页

C
2,050
字号
static keyword_type_t port_kw = { "port", &cfg_type_uint32 };static cfg_type_t cfg_type_optional_port = {	"optional_port", parse_optional_keyvalue, print_keyvalue,	doc_optional_keyvalue, &cfg_rep_uint32, &port_kw};/*% A list of keys, as in the "key" clause of the controls statement. */static cfg_type_t cfg_type_keylist = {	"keylist", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list, &cfg_rep_list,	&cfg_type_astring};static cfg_type_t cfg_type_trustedkeys = {	"trusted-keys", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list, &cfg_rep_list,	&cfg_type_trustedkey};static const char *forwardtype_enums[] = { "first", "only", NULL };static cfg_type_t cfg_type_forwardtype = {	"forwardtype", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string,	&forwardtype_enums};static const char *zonetype_enums[] = {	"master", "slave", "stub", "hint", "forward", "delegation-only", NULL };static cfg_type_t cfg_type_zonetype = {	"zonetype", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum,	&cfg_rep_string, &zonetype_enums};static const char *loglevel_enums[] = {	"critical", "error", "warning", "notice", "info", "dynamic", NULL };static cfg_type_t cfg_type_loglevel = {	"loglevel", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string,	&loglevel_enums};static const char *transferformat_enums[] = {	"many-answers", "one-answer", NULL };static cfg_type_t cfg_type_transferformat = {	"transferformat", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, &cfg_rep_string,	&transferformat_enums};/*% * The special keyword "none", as used in the pid-file option. */static voidprint_none(cfg_printer_t *pctx, const cfg_obj_t *obj) {	UNUSED(obj);	cfg_print_chars(pctx, "none", 4);}static cfg_type_t cfg_type_none = {	"none", NULL, print_none, NULL, &cfg_rep_void, NULL};/*% * A quoted string or the special keyword "none".  Used in the pid-file option. */static isc_result_tparse_qstringornone(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));	cfg_ungettoken(pctx);	return (cfg_parse_qstring(pctx, type, ret)); cleanup:	return (result);}static voiddoc_qstringornone(cfg_printer_t *pctx, const cfg_type_t *type) {	UNUSED(type);	cfg_print_chars(pctx, "( <quoted_string> | none )", 26);}static cfg_type_t cfg_type_qstringornone = {	"qstringornone", parse_qstringornone, NULL, doc_qstringornone, NULL, NULL };/*% * keyword hostname */static voidprint_hostname(cfg_printer_t *pctx, const 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" argument. */static isc_result_tparse_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 voiddoc_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 };/*% * Port list. */static isc_result_tparse_port(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {	isc_result_t result;		UNUSED(type);	CHECK(cfg_parse_uint32(pctx, NULL, ret));	if ((*ret)->value.uint32 > 0xffff) {		cfg_parser_error(pctx, CFG_LOG_NEAR, "invalid port");		cfg_obj_destroy(pctx, ret);		result = ISC_R_RANGE;	} cleanup:	return (result);}static cfg_type_t cfg_type_port = {	"port", parse_port, NULL, cfg_doc_terminal,	NULL, NULL};static cfg_type_t cfg_type_bracketed_portlist = {	"bracketed_sockaddrlist", cfg_parse_bracketed_list, cfg_print_bracketed_list, cfg_doc_bracketed_list,	&cfg_rep_list, &cfg_type_port};/*% * Clauses that can be found within the top level of the named.conf * file only. */static cfg_clausedef_tnamedconf_clauses[] = {	{ "options", &cfg_type_options, 0 },	{ "controls", &cfg_type_controls, CFG_CLAUSEFLAG_MULTI },	{ "acl", &cfg_type_acl, CFG_CLAUSEFLAG_MULTI },	{ "masters", &cfg_type_masters, CFG_CLAUSEFLAG_MULTI },	{ "logging", &cfg_type_logging, 0 },	{ "view", &cfg_type_view, CFG_CLAUSEFLAG_MULTI },	{ "lwres", &cfg_type_lwres, CFG_CLAUSEFLAG_MULTI },	{ NULL, NULL, 0 }};/*% * Clauses that can occur at the top level or in the view * statement, but not in the options block. */static cfg_clausedef_tnamedconf_or_view_clauses[] = {	{ "key", &cfg_type_key, CFG_CLAUSEFLAG_MULTI },	{ "zone", &cfg_type_zone, CFG_CLAUSEFLAG_MULTI },	/* only 1 DLZ per view allowed */ 	{ "dlz", &cfg_type_dynamically_loadable_zones, 0 },	{ "server", &cfg_type_server, CFG_CLAUSEFLAG_MULTI },	{ "trusted-keys", &cfg_type_trustedkeys, CFG_CLAUSEFLAG_MULTI },	{ NULL, NULL, 0 }};/*% * Clauses that can be found within the 'options' statement. */static cfg_clausedef_toptions_clauses[] = {	{ "avoid-v4-udp-ports", &cfg_type_bracketed_portlist, 0 },	{ "avoid-v6-udp-ports", &cfg_type_bracketed_portlist, 0 },	{ "blackhole", &cfg_type_bracketed_aml, 0 },	{ "coresize", &cfg_type_size, 0 },	{ "datasize", &cfg_type_size, 0 },	{ "deallocate-on-exit", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },	{ "directory", &cfg_type_qstring, CFG_CLAUSEFLAG_CALLBACK },	{ "dump-file", &cfg_type_qstring, 0 },	{ "fake-iquery", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },	{ "files", &cfg_type_size, 0 },	{ "has-old-clients", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },	{ "heartbeat-interval", &cfg_type_uint32, 0 },	{ "host-statistics", &cfg_type_boolean, CFG_CLAUSEFLAG_NOTIMP },	{ "host-statistics-max", &cfg_type_uint32, CFG_CLAUSEFLAG_NOTIMP },	{ "hostname", &cfg_type_qstringornone, 0 },	{ "interface-interval", &cfg_type_uint32, 0 },	{ "listen-on", &cfg_type_listenon, CFG_CLAUSEFLAG_MULTI },	{ "listen-on-v6", &cfg_type_listenon, CFG_CLAUSEFLAG_MULTI },	{ "match-mapped-addresses", &cfg_type_boolean, 0 },	{ "memstatistics-file", &cfg_type_qstring, 0 },	{ "multiple-cnames", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },	{ "named-xfer", &cfg_type_qstring, CFG_CLAUSEFLAG_OBSOLETE },	{ "pid-file", &cfg_type_qstringornone, 0 },	{ "port", &cfg_type_uint32, 0 },	{ "querylog", &cfg_type_boolean, 0 },	{ "recursing-file", &cfg_type_qstring, 0 },	{ "random-device", &cfg_type_qstring, 0 },	{ "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 },	{ "tcp-clients", &cfg_type_uint32, 0 },	{ "tcp-listen-queue", &cfg_type_uint32, 0 },	{ "tkey-dhkey", &cfg_type_tkey_dhkey, 0 },	{ "tkey-gssapi-credential", &cfg_type_qstring, 0 },	{ "tkey-domain", &cfg_type_qstring, 0 },	{ "transfers-per-ns", &cfg_type_uint32, 0 },	{ "transfers-in", &cfg_type_uint32, 0 },	{ "transfers-out", &cfg_type_uint32, 0 },	{ "treat-cr-as-space", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },	{ "use-id-pool", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },	{ "use-ixfr", &cfg_type_boolean, 0 },	{ "version", &cfg_type_qstringornone, 0 },	{ "flush-zones-on-shutdown", &cfg_type_boolean, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_namelist = {	"namelist", cfg_parse_bracketed_list, cfg_print_bracketed_list,	cfg_doc_bracketed_list, &cfg_rep_list, &cfg_type_qstring };static keyword_type_t exclude_kw = { "exclude", &cfg_type_namelist };static cfg_type_t cfg_type_optional_exclude = {	"optional_exclude", parse_optional_keyvalue, print_keyvalue,	doc_optional_keyvalue, &cfg_rep_list, &exclude_kw };static cfg_type_t cfg_type_algorithmlist = {	"algorithmlist", cfg_parse_bracketed_list, cfg_print_bracketed_list,	cfg_doc_bracketed_list, &cfg_rep_list, &cfg_type_astring };static cfg_tuplefielddef_t disablealgorithm_fields[] = {	{ "name", &cfg_type_astring, 0 },	{ "algorithms", &cfg_type_algorithmlist, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_disablealgorithm = {	"disablealgorithm", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple,	&cfg_rep_tuple, disablealgorithm_fields};static cfg_tuplefielddef_t mustbesecure_fields[] = {        { "name", &cfg_type_astring, 0 },        { "value", &cfg_type_boolean, 0 },        { NULL, NULL, 0 }};static cfg_type_t cfg_type_mustbesecure = {	"mustbesecure", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple,	&cfg_rep_tuple, mustbesecure_fields};static const char *masterformat_enums[] = { "text", "raw", NULL };static cfg_type_t cfg_type_masterformat = {	"masterformat", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum,	&cfg_rep_string, &masterformat_enums};/*% * dnssec-lookaside */static keyword_type_t trustanchor_kw = { "trust-anchor", &cfg_type_astring };static cfg_type_t cfg_type_trustanchor = {	"trust-anchor", parse_keyvalue, print_keyvalue, doc_keyvalue,	&cfg_rep_string, &trustanchor_kw};static cfg_tuplefielddef_t lookaside_fields[] = {	{ "domain", &cfg_type_astring, 0 },	{ "trust-anchor", &cfg_type_trustanchor, 0 },	{ NULL, NULL, 0 }};static cfg_type_t cfg_type_lookaside = {	"lookaside", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple,	&cfg_rep_tuple, lookaside_fields};/*% * Clauses that can be found within the 'view' statement, * with defaults in the 'options' statement. */static cfg_clausedef_tview_clauses[] = {	{ "allow-query-cache", &cfg_type_bracketed_aml, 0 },	{ "allow-recursion", &cfg_type_bracketed_aml, 0 },	{ "allow-v6-synthesis", &cfg_type_bracketed_aml,	  CFG_CLAUSEFLAG_OBSOLETE },	{ "sortlist", &cfg_type_bracketed_aml, 0 },	{ "topology", &cfg_type_bracketed_aml, CFG_CLAUSEFLAG_NOTIMP },	{ "auth-nxdomain", &cfg_type_boolean, CFG_CLAUSEFLAG_NEWDEFAULT },	{ "minimal-responses", &cfg_type_boolean, 0 },	{ "recursion", &cfg_type_boolean, 0 },	{ "rrset-order", &cfg_type_rrsetorder, 0 },	{ "provide-ixfr", &cfg_type_boolean, 0 },	{ "request-ixfr", &cfg_type_boolean, 0 },	{ "fetch-glue", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },	{ "rfc2308-type1", &cfg_type_boolean, CFG_CLAUSEFLAG_NYI },	{ "additional-from-auth", &cfg_type_boolean, 0 },	{ "additional-from-cache", &cfg_type_boolean, 0 },	/*	 * Note that the query-source option syntax is different	 * from the other -source options.	 */	{ "query-source", &cfg_type_querysource4, 0 },	{ "query-source-v6", &cfg_type_querysource6, 0 },	{ "cleaning-interval", &cfg_type_uint32, 0 },	{ "min-roots", &cfg_type_uint32, CFG_CLAUSEFLAG_NOTIMP },	{ "lame-ttl", &cfg_type_uint32, 0 },	{ "max-ncache-ttl", &cfg_type_uint32, 0 },	{ "max-cache-ttl", &cfg_type_uint32, 0 },	{ "transfer-format", &cfg_type_transferformat, 0 },	{ "max-cache-size", &cfg_type_sizenodefault, 0 },	{ "check-names", &cfg_type_checknames, CFG_CLAUSEFLAG_MULTI },	{ "cache-file", &cfg_type_qstring, 0 },	{ "suppress-initial-notify", &cfg_type_boolean, CFG_CLAUSEFLAG_NYI },	{ "preferred-glue", &cfg_type_astring, 0 },	{ "dual-stack-servers", &cfg_type_nameportiplist, 0 },	{ "edns-udp-size", &cfg_type_uint32, 0 },	{ "max-udp-size", &cfg_type_uint32, 0 },	{ "root-delegation-only",  &cfg_type_optional_exclude, 0 },	{ "disable-algorithms", &cfg_type_disablealgorithm,	  CFG_CLAUSEFLAG_MULTI },	{ "dnssec-enable", &cfg_type_boolean, 0 },	{ "dnssec-validation", &cfg_type_boolean, 0 },	{ "dnssec-lookaside", &cfg_type_lookaside, CFG_CLAUSEFLAG_MULTI },	{ "dnssec-must-be-secure",  &cfg_type_mustbesecure,	   CFG_CLAUSEFLAG_MULTI },	{ "dnssec-accept-expired", &cfg_type_boolean, 0 },	{ "ixfr-from-differences", &cfg_type_ixfrdifftype, 0 },	{ "acache-enable", &cfg_type_boolean, 0 },	{ "acache-cleaning-interval", &cfg_type_uint32, 0 },	{ "max-acache-size", &cfg_type_sizenodefault, 0 },	{ "clients-per-query", &cfg_type_uint32, 0 },	{ "max-clients-per-query", &cfg_type_uint32, 0 },	{ "empty-server", &cfg_type_astring, 0 },	{ "empty-contact", &cfg_type_astring, 0 },	{ "empty-zones-enable", &cfg_type_boolean, 0 },	{ "disable-empty-zone", &cfg_type_astring, CFG_CLAUSEFLAG_MULTI },	{ "zero-no-soa-ttl-cache", &cfg_type_boolean, 0 },	{ NULL, NULL, 0 }};/*% * Clauses that can be found within the 'view' statement only. */static cfg_clausedef_tview_only_clauses[] = {	{ "match-clients", &cfg_type_bracketed_aml, 0 },	{ "match-destinations", &cfg_type_bracketed_aml, 0 },	{ "match-recursive-only", &cfg_type_boolean, 0 },	{ NULL, NULL, 0 }};/*% * Clauses that can be found in a 'zone' statement, * with defaults in the 'view' or 'options' statement. */static cfg_clausedef_tzone_clauses[] = {	{ "allow-query", &cfg_type_bracketed_aml, 0 },	{ "allow-transfer", &cfg_type_bracketed_aml, 0 },	{ "allow-update", &cfg_type_bracketed_aml, 0 },	{ "allow-update-forwarding", &cfg_type_bracketed_aml, 0 },	{ "allow-notify", &cfg_type_bracketed_aml, 0 },	{ "masterfile-format", &cfg_type_masterformat, 0 },	{ "notify", &cfg_type_notifytype, 0 },	{ "notify-source", &cfg_type_sockaddr4wild, 0 },	{ "notify-source-v6", &cfg_type_sockaddr6wild, 0 },	{ "also-notify", &cfg_type_portiplist, 0 },	{ "notify-delay", &cfg_type_uint32, 0 },	{ "dialup", &cfg_type_dialuptype, 0 },	{ "forward", &cfg_type_forwardtype, 0 },	{ "forwarders", &cfg_type_portiplist, 0 },

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?