Commit 498a6a71 authored by Daniel Salzman's avatar Daniel Salzman

conf: enable identity/version/nsid by default

parent fdc1d18a
......@@ -21,7 +21,7 @@ folowing meaning:
- *INT* - Integer
- *STR* - Textual string
- *HEXSTR* - Hexadecimal string (with ``0x`` prefix)
- *BOOL* - Boolean value (``on`` or ``off``)
- *BOOL* - Boolean value (``on``, ``off``, ``true`` or ``false``)
- *TIME* - Number of seconds, integer with possible time mutliplier suffix
(``s`` ~ 1, ``m`` ~ 60, ``h`` ~ 3600 or ``d`` ~ 24 * 3600)
- *SIZE* - Number of bytes, integer with possible size multiplier suffix
......@@ -106,9 +106,9 @@ identity
An identity of the server returned in the response for the query for TXT
record ``id.server.`` or ``hostname.bind.`` in the CHAOS class (see RFC 4892).
If empty, FQDN hostname is used.
Set empty value to disable.
Default: disabled
Default: FQDN hostname
.. _server_version:
......@@ -117,18 +117,18 @@ version
A version of the server software returned in the response for the query
for TXT record ``version.server.`` or ``version.bind.`` in the CHAOS
class (see RFC 4892). If empty, automatic version is used.
class (see RFC 4892). Set empty value to disable.
Default: disabled
Default: server version
.. _server_nsid:
nsid
----
A DNS name server identifier (see RFC 5001). If empty, FQDN hostname is used.
A DNS name server identifier (see RFC 5001). Set empty value to disable.
Default: disabled
Default: FQDN hostname
.. _server_rundir:
......
......@@ -45,7 +45,7 @@ folowing meaning:
.IP \(bu 2
\fIHEXSTR\fP \- Hexadecimal string (with \fB0x\fP prefix)
.IP \(bu 2
\fIBOOL\fP \- Boolean value (\fBon\fP or \fBoff\fP)
\fIBOOL\fP \- Boolean value (\fBon\fP, \fBoff\fP, \fBtrue\fP or \fBfalse\fP)
.IP \(bu 2
\fITIME\fP \- Number of seconds, integer with possible time mutliplier suffix
(\fBs\fP ~ 1, \fBm\fP ~ 60, \fBh\fP ~ 3600 or \fBd\fP ~ 24 * 3600)
......@@ -135,21 +135,21 @@ server:
.sp
An identity of the server returned in the response for the query for TXT
record \fBid.server.\fP or \fBhostname.bind.\fP in the CHAOS class (see RFC 4892).
If empty, FQDN hostname is used.
Set empty value to disable.
.sp
Default: disabled
Default: FQDN hostname
.SS version
.sp
A version of the server software returned in the response for the query
for TXT record \fBversion.server.\fP or \fBversion.bind.\fP in the CHAOS
class (see RFC 4892). If empty, automatic version is used.
class (see RFC 4892). Set empty value to disable.
.sp
Default: disabled
Default: server version
.SS nsid
.sp
A DNS name server identifier (see RFC 5001). If empty, FQDN hostname is used.
A DNS name server identifier (see RFC 5001). Set empty value to disable.
.sp
Default: disabled
Default: FQDN hostname
.SS rundir
.sp
A path for storing run\-time data (PID file, unix sockets, etc.).
......
......@@ -35,8 +35,8 @@ static const char *get_txt_response_string(const knot_dname_t *qname)
strcasecmp("hostname.bind.", qname_str) == 0) {
conf_val_t val = conf_get(conf(), C_SRV, C_IDENT);
response = conf_str(&val);
/* Empty string data (including '\0') means auto. */
if (val.code == KNOT_EOK && val.len <= 1) {
/* No item means auto. */
if (val.code != KNOT_EOK) {
response = conf()->hostname;
}
/* Allow both version version.{server, bind}. for compatibility. */
......@@ -44,8 +44,8 @@ static const char *get_txt_response_string(const knot_dname_t *qname)
strcasecmp("version.bind.", qname_str) == 0) {
conf_val_t val = conf_get(conf(), C_SRV, C_VERSION);
response = conf_str(&val);
/* Empty string data (including '\0') means auto. */
if (val.code == KNOT_EOK && val.len <= 1) {
/* No item means auto. */
if (val.code != KNOT_EOK) {
response = "Knot DNS " PACKAGE_VERSION;
}
}
......
......@@ -239,24 +239,28 @@ static int answer_edns_init(const knot_pkt_t *query, knot_pkt_t *resp,
/* Append NSID if requested and available. */
val = conf_get(conf(), C_SRV, C_NSID);
if (knot_edns_has_nsid(query->opt_rr) && val.code == KNOT_EOK) {
if (knot_edns_has_nsid(query->opt_rr)) {
conf_data(&val);
const uint8_t *data = val.data;
uint16_t len = val.len;
/* Empty data means automatic value. */
if (val.len == 0) {
data = (uint8_t *)conf()->hostname;
len = strlen(conf()->hostname);
if (val.code != KNOT_EOK) {
ret = knot_edns_add_option(&qdata->opt_rr,
KNOT_EDNS_OPTION_NSID,
strlen(conf()->hostname),
(uint8_t *)conf()->hostname,
qdata->mm);
if (ret != KNOT_EOK) {
return ret;
}
} else if (val.len > 0) {
ret = knot_edns_add_option(&qdata->opt_rr,
KNOT_EDNS_OPTION_NSID, len, data,
KNOT_EDNS_OPTION_NSID,
val.len,
val.data,
qdata->mm);
if (ret != KNOT_EOK) {
return ret;
}
}
}
return answer_edns_reserve(resp, qdata);
}
......
......@@ -205,7 +205,7 @@ static void f_str(void *scanner, int run, const char *name, const char *val)
static void f_auto_str(void *scanner, int run, const char *name, long val)
{
if (val != 0) {
if (val == 0) {
f_name(scanner, run, name, false);
f_val(scanner, run, true, "");
f_val(scanner, run, false, "\n");
......
......@@ -149,7 +149,7 @@ static void f_str(void *scanner, int run, const char *name, const char *val)
static void f_auto_str(void *scanner, int run, const char *name, long val)
{
if (val != 0) {
if (val == 0) {
f_name(scanner, run, name, false);
f_val(scanner, run, true, "");
f_val(scanner, run, false, "\n");
......
......@@ -8,9 +8,8 @@ t = Test()
name = "Knot DNS server name"
server1 = t.server("knot", ident=name)
server2 = t.server("knot", ident=True)
server2 = t.server("knot")
server3 = t.server("knot", ident=False)
server4 = t.server("knot")
t.start()
......@@ -22,16 +21,12 @@ resp.check('"' + name + '"')
resp = server1.dig("hostname.bind", "TXT", "CH")
resp.check('"' + name + '"')
# 2) FQDN hostname.
# 2) Default FQDN hostname.
resp = server2.dig("id.server", "TXT", "CH")
resp.check(t.hostname)
# 3) Explicitly disabled.
# 3) Disabled.
resp = server3.dig("id.server", "TXT", "CH")
resp.check(rcode="REFUSED")
# 4) Disabled.
resp = server4.dig("id.server", "TXT", "CH")
resp.check(rcode="REFUSED")
t.end()
......@@ -8,9 +8,8 @@ t = Test()
ver = "ver. 1.3.1-p3"
server1 = t.server("knot", version=ver)
server2 = t.server("knot", version=True)
server2 = t.server("knot")
server3 = t.server("knot", version=False)
server4 = t.server("knot")
t.start()
......@@ -22,16 +21,12 @@ resp.check('"' + ver + '"')
resp = server1.dig("version.bind", "TXT", "CH")
resp.check('"' + ver + '"')
# 2) Automatic version string (can't be tested).
# 2) Default version string.
resp = server2.dig("version.server", "TXT", "CH")
resp.check(rcode="NOERROR")
# 3) Explicitly disabled.
# 3) Disabled.
resp = server3.dig("version.server", "TXT", "CH")
resp.check(rcode="REFUSED")
# 4) Disabled.
resp = server4.dig("version.server", "TXT", "CH")
resp.check(rcode="REFUSED")
t.end()
......@@ -9,17 +9,15 @@ t = Test()
name = "Knot DNS server"
hex_name = "0x01020304"
server1 = t.server("knot", nsid=name)
server2 = t.server("knot", nsid=True)
server3 = t.server("knot", nsid=False)
server4 = t.server("knot")
server5 = t.server("knot", nsid=hex_name)
server2 = t.server("knot", nsid=False)
server3 = t.server("knot")
server4 = t.server("knot", nsid=hex_name)
zone = t.zone("example.com.")
t.link(zone, server1)
t.link(zone, server2)
t.link(zone, server3)
t.link(zone, server4)
t.link(zone, server5)
t.start()
......@@ -27,20 +25,16 @@ t.start()
resp = server1.dig("example.com", "SOA", nsid=True)
resp.check_edns(nsid=name)
# 2) FQDN hostname.
# 2) Disabled.
resp = server2.dig("example.com", "SOA", nsid=True)
resp.check_edns(nsid=t.hostname)
resp.check_edns()
# 3) Explicitly disabled.
# 3) FQDN hostname.
resp = server3.dig("example.com", "SOA", nsid=True)
resp.check_edns()
resp.check_edns(nsid=t.hostname)
# 4) Disabled.
# 4) Hex string.
resp = server4.dig("example.com", "SOA", nsid=True)
resp.check_edns()
# 5) Hex string.
resp = server5.dig("example.com", "SOA", nsid=True)
resp.check_edns(nsid=hex_name)
t.end()
......@@ -788,9 +788,9 @@ class Knot(Server):
def _on_str_hex(self, conf, name, value):
if value == True:
conf.item_str(name, "")
elif value == False:
return
elif value == False:
conf.item_str(name, "")
elif value:
conf.item_str(name, value)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment