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