From: Mark Wooding Date: Tue, 13 Mar 2012 16:17:28 +0000 (+0000) Subject: zoneconf: Awful kludge in `primary': masters never considered local. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/zoneconf/commitdiff_plain/e4ce9d1ee876952c2c339a84ad658caff954a95e zoneconf: Awful kludge in `primary': masters never considered local. A master address containing `!' is never considered to be local: the address to the left is used by remote hosts; the address to the right is used by local ones. --- diff --git a/zoneconf.in b/zoneconf.in index 7af2845..4a6713f 100755 --- a/zoneconf.in +++ b/zoneconf.in @@ -1022,6 +1022,12 @@ define-configuration-space zone ZONECFG { } define primary {map} { + ## There's a grim hack here: a primary-address entry may have the form + ## REAL!FAKE. If the REAL address is not a local address then this + ## is used as the master address; otherwise the FAKE address is used. + ## This is useful for inter-view updates of dynamic zones on the same + ## host. I suggest abusing 127.0.0.0/8 addresses for this kind of + ## chicanery. if {[llength $map] % 2} { error "master map must have an even number of items" } @@ -1141,13 +1147,24 @@ proc compute-zone-properties {view config} { if {[info exists zone(mapped-view)]} { foreach {outview hosts} $zone(master-map) { if {[string match $outview $zone(mapped-view)]} { - set zone(masters) $hosts + set masters {} set zone(config-type) slave foreach host $hosts { - if {[local-address-p $host]} { + set bang [string first "!" $host] + if {$bang >= 0} { + set before [string range $host 0 [expr {$bang - 1}]] + set after [string range $host [expr {$bang + 1}] end] + if {[local-address-p $before]} { + set host $after + } else { + set host $before + } + } elseif {[local-address-p $host]} { set zone(config-type) master } + lappend masters $host } + set zone(masters) $masters break } }