All host or domain names are either names relative to the current domain
with no dots inside or absolute names (in this case, NSC automatically
-ensures that the trailing dot is present in the resource records). Relative
-names with dots are not supported, but they are rare and you can always write
-them as absolute anyway.
+ensures that the trailing dot is present in the resource records). If you
+really need a relative name with dots, escape all dots as "\.".
Your menu:
define(nsc_revIPa, `ifelse($#, 1, `$1', `nsc_revIPa(shift($@)).$1')')
define(nsc_revaddr, `nsc_revIPa(translit($1, `.', `,'))')
-# Fix up dots in a name: if the name is not simple (i.e., it contains at least one dot),
-# ensure that it ends with a dot.
+# Fix up dots in a name: If the name is not simple (i.e., it contains at least one unescaped
+# dot), ensure that it ends with a dot. Then unescape all escaped dots (\.).
-define(nsc_corr_dot, `ifelse(substr($1,decr(len($1))),.,$1,$1`'ifelse(index($1,.),-1,,.))')
+define(nsc_name, `nsc_unescape_name(ifelse(substr($1,decr(len($1))),.,$1,$1`'ifelse(regexp($1,`[^\\]\.'),-1,,.)))')
+define(nsc_unescape_name,`patsubst(`$1',\\\.,.)')
# Normalize IPv6 address
# Record names
-define(nsc_set_name, `define(`CURRENT_NAME', nsc_corr_dot($1))define(`PRINT_NAME', CURRENT_NAME)')
+define(nsc_set_name, `define(`CURRENT_NAME', nsc_name($1))define(`PRINT_NAME', CURRENT_NAME)')
define(nsc_emit_name, `ifdef(`PRINT_NAME', `PRINT_NAME`'undefine(`PRINT_NAME')', `')')
-define(nsc_abs_name, `ifelse(CURRENT_NAME, translit(CURRENT_NAME,.,:), CURRENT_NAME.CURRENT_DOMAIN, CURRENT_NAME)')
+define(nsc_abs_name, `ifelse(regexp(CURRENT_NAME,\.$),-1,CURRENT_NAME.CURRENT_DOMAIN,CURRENT_NAME)')
define(nsc_abs_name_nodot, `define(`nsc_tmp', nsc_abs_name)substr(nsc_tmp,0,decr(len(nsc_tmp)))')
# SOA record
define(nsc_SOA, `
ifelse(CURRENT_DOMAIN,@,`',$ORIGIN CURRENT_DOMAIN)
$TTL MINTTL
-nsc_emit_name `SOA' nsc_corr_dot(NSNAME) MAINTNAME (
+nsc_emit_name `SOA' nsc_name(NSNAME) MAINTNAME (
VERSION REFRESH RETRY EXPIRE MINTTL )')
define(SOA, `ifdef(`CURRENT_DOMAIN',`ifdef(`REVERSE_MODE',,`nsc_fatal_error(`SOA record defined twice')')')dnl
define(`CURRENT_DOMAIN',ifelse($1,@,@,$1.))dnl
# NS record
-define(nsc_NS, `nsc_emit_name `NS' nsc_corr_dot($1)
+define(nsc_NS, `nsc_emit_name `NS' nsc_name($1)
')
define(NS, `nsc_iterate(`nsc_NS', $@)dnl')
# MX record
-define(nsc_MX, `nsc_emit_name `MX' nsc_corr_dot($1)
+define(nsc_MX, `nsc_emit_name `MX' nsc_name($1)
')
define(MX, `nsc_iterate(`nsc_MX', $@)dnl')
# RP (responsible person) records
-define(RP, `nsc_emit_name `RP' nsc_corr_dot($1) nsc_corr_dot($2)')
+define(RP, `nsc_emit_name `RP' nsc_name($1) nsc_name($2)')
# SRV records
-define(SRV, `_`'$1`'._`'$2`'.CURRENT_NAME `SRV' $3 $4 $5 nsc_corr_dot($6)`'nsc_set_name(CURRENT_NAME)')
+define(SRV, `_`'$1`'._`'$2`'.CURRENT_NAME `SRV' $3 $4 $5 nsc_name($6)`'nsc_set_name(CURRENT_NAME)')
# CNAME records
-define(CNAME, `$1 `CNAME' nsc_corr_dot($2)')
+define(CNAME, `$1 `CNAME' nsc_name($2)')
# Explicit PTR records
-define(PTR, `$1 `PTR' nsc_corr_dot($2)')
+define(PTR, `$1 `PTR' nsc_name($2)')
# DS records (DNSSEC keys for subdomains)