From 66b7fe74d00aa545abeaa1c048917c85ffd9a4f9 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Wed, 23 Jan 2013 20:56:59 +0000 Subject: [PATCH] zoneconf.in (local-addresses-p): Set fake addresses in env var. It's useful to be able to test configurations away from the production environment, but the `local-addresses-p' check causes the results to be different. To allow this kind of testing, set the environment variable `ZONECONF_LOCAL_ADDRESSES' to a `:'-separated list of IP addresses, in dotted-quad format: then these addresses and no others will be considered local. --- zoneconf.in | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/zoneconf.in b/zoneconf.in index 43892db..d16e74a 100755 --- a/zoneconf.in +++ b/zoneconf.in @@ -942,12 +942,21 @@ proc host-canonify {host} { proc local-address-p {addr} { ## Answer whether the ADDR is one of the host's addresses. + global env - if {[catch { set sk [socket -server {} -myaddr $addr 0] }]} { - return false + if {[info exists env(ZONECONF_LOCAL_ADDRESSES)]} { + if {[string match "*:$addr:*" ":$env(ZONECONF_LOCAL_ADDRESSES):"]} { + return true + } else { + return false + } } else { - close $sk - return true + if {[catch { set sk [socket -server {} -myaddr $addr 0] }]} { + return false + } else { + close $sk + return true + } } } -- 2.11.0