build valid name
This commit is contained in:
@@ -71,8 +71,28 @@ dynptrr_nxdomain_begin(void *arg, void *cbdata, isc_result_t *resp) {
|
||||
* dns_name_t. (I attempted putting a raw string instead, and it was a
|
||||
* crash)
|
||||
*/
|
||||
synthdata->data = name->ndata;
|
||||
synthdata->length = name->length;
|
||||
/* ------------------------------------------------- */
|
||||
|
||||
isc_netaddr_t peeraddr;
|
||||
isc_netaddr_fromsockaddr(&peeraddr, &qctx->client->peeraddr);
|
||||
|
||||
char createdptrnamed[512];
|
||||
isc_buffer_t createdptrnameb;
|
||||
isc_buffer_init(&createdptrnameb, createdptrnamed, 512);
|
||||
|
||||
dns_name_t *createdptrname = isc_mem_get(mctx, sizeof(*createdptrname));
|
||||
dns_name_init(createdptrname);
|
||||
dns_name_setbuffer(createdptrname, &createdptrnameb);
|
||||
isc_result_t r = dns_byaddr_createptrname(&peeraddr, createdptrname);
|
||||
isc_log_write(NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_HOOKS,
|
||||
ISC_LOG_DEBUG(1), "dynptrr %s", isc_result_totext(r));
|
||||
dns_name_format(createdptrname, n, 512);
|
||||
isc_log_write(NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_HOOKS,
|
||||
ISC_LOG_DEBUG(1), "dynptrr ptr %s", n);
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
synthdata->data = createdptrname->ndata;//name->ndata;
|
||||
synthdata->length = createdptrname->length;//name->length;
|
||||
|
||||
ISC_LIST_APPEND(synthlist->rdata, synthdata, link);
|
||||
|
||||
@@ -84,27 +104,8 @@ dynptrr_nxdomain_begin(void *arg, void *cbdata, isc_result_t *resp) {
|
||||
isc_result_t result = ns_query_done(qctx);
|
||||
*resp = result;
|
||||
|
||||
/* ------------------------------------------------- */
|
||||
|
||||
// isc_netaddr_t peeraddr;
|
||||
// isc_netaddr_fromsockaddr(&peeraddr, &qctx->client->peeraddr);
|
||||
//
|
||||
// char createdptrnamed[512];
|
||||
// isc_buffer_t createdptrnameb;
|
||||
// isc_buffer_init(&createdptrnameb, createdptrnamed, 512);
|
||||
//
|
||||
// dns_name_t *createdptrname = isc_mem_get(mctx, sizeof(*createdptrname));
|
||||
// dns_name_init(createdptrname);
|
||||
// dns_name_setbuffer(createdptrname, &createdptrnameb);
|
||||
// isc_result_t r = dns_byaddr_createptrname(&peeraddr, createdptrname);
|
||||
// isc_log_write(NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_HOOKS,
|
||||
// ISC_LOG_DEBUG(1), "dynptrr %s", isc_result_totext(r));
|
||||
// dns_name_format(createdptrname, n, 512);
|
||||
// isc_log_write(NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_HOOKS,
|
||||
// ISC_LOG_DEBUG(1), "dynptrr ptr %s", n);
|
||||
// isc_mem_put(mctx, createdptrname, sizeof(*createdptrname));
|
||||
//
|
||||
/* ------------------------------------------------- */
|
||||
isc_mem_put(mctx, createdptrname, sizeof(*createdptrname));
|
||||
|
||||
return NS_HOOK_RETURN;
|
||||
}
|
||||
|
||||
16
bin/tests/system/dynptrr/ns1/0.53.10.in-addr.arpa.db
Normal file
16
bin/tests/system/dynptrr/ns1/0.53.10.in-addr.arpa.db
Normal file
@@ -0,0 +1,16 @@
|
||||
; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
;
|
||||
; SPDX-License-Identifier: MPL-2.0
|
||||
;
|
||||
; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
; file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
;
|
||||
; See the COPYRIGHT file distributed with this work for additional
|
||||
; information regarding copyright ownership.
|
||||
|
||||
$TTL 120
|
||||
@ SOA ns.example. hostmaster.ns.example. ( 1 3600 1200 604800 60 )
|
||||
@ NS ns.example.
|
||||
4 PTR a.example.
|
||||
|
||||
@@ -9,17 +9,8 @@
|
||||
; See the COPYRIGHT file distributed with this work for additional
|
||||
; information regarding copyright ownership.
|
||||
|
||||
$TTL 120
|
||||
@ SOA ns.example. hostmaster.ns.example. ( 1 3600 1200 604800 60 )
|
||||
@ NS ns
|
||||
@ MX 10 mx
|
||||
|
||||
ns A 10.53.0.1
|
||||
AAAA fd92:7065:b8e:ffff::1
|
||||
|
||||
a-only NS 1.0.0.4
|
||||
aaaa-only AAAA 2001:db8::5
|
||||
dual A 1.0.0.6
|
||||
dual AAAA 2001:db8::6
|
||||
mx A 1.0.0.3
|
||||
mx AAAA 2001:db8::3
|
||||
$TTL 120
|
||||
@ SOA ns.example. hostmaster.ns.example. ( 1 3600 1200 604800 60 )
|
||||
@ NS ns
|
||||
ns A 10.53.0.1
|
||||
a A 10.53.0.4
|
||||
|
||||
@@ -33,5 +33,17 @@ controls {
|
||||
};
|
||||
|
||||
|
||||
zone "." { type primary; file "root.db"; };
|
||||
zone "example" { type primary; file "example.db"; };
|
||||
zone "." {
|
||||
type primary;
|
||||
file "root.db";
|
||||
};
|
||||
|
||||
zone "example" {
|
||||
type primary;
|
||||
file "example.db";
|
||||
};
|
||||
|
||||
zone "0.53.10.in-addr.arpa." {
|
||||
type primary;
|
||||
file "0.53.10.in-addr.arpa.db";
|
||||
};
|
||||
|
||||
@@ -24,13 +24,14 @@ dig_with_opts() {
|
||||
"${DIG}" -p "${PORT}" "${@}"
|
||||
}
|
||||
|
||||
# TODO: check how to migrate those tests into python-based ones
|
||||
|
||||
n=$((n + 1))
|
||||
echo_i "PTR exists, dynptrr hook is not run ($n)"
|
||||
ret=0
|
||||
dig_with_opts ptr 10.53.0.1 @10.53.0.1 >dig.out.ns1.test$n || ret=1
|
||||
dig_with_opts -x 10.53.0.4 @10.53.0.1 >dig.out.ns1.test$n || ret=1
|
||||
grep "status: NOERROR" dig.out.ns1.test${n} >/dev/null || ret=1
|
||||
grep "ns.example" dig.out.ns1.test$n >/dev/null || ret=1
|
||||
grep "a.example" dig.out.ns1.test$n >/dev/null || ret=1
|
||||
grep "dynptrr nxdomain begin" ns1/named.run && ret=1
|
||||
if [ $ret != 0 ]; then echo_i "failed"; fi
|
||||
status=$((status + ret))
|
||||
|
||||
Reference in New Issue
Block a user