From 90b413bae3c32a5aff5ea2f45bcd0e01a16b7197 Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 10 Nov 2010 16:02:03 -0500 Subject: Detect if we have an IP or a hostname in an MX record and set the field appropriately. --- config/tinydns/tinydns.inc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/tinydns/tinydns.inc b/config/tinydns/tinydns.inc index 9de8da9d..dbfbd2a8 100644 --- a/config/tinydns/tinydns.inc +++ b/config/tinydns/tinydns.inc @@ -715,9 +715,17 @@ function tinydns_get_rowline_data($recordip, $recordtype, $ttl, $hostname, $rdns break; case "MX": // @fqdn:ip:x:dist:ttl:timestamp:lo + // ^- This is a hostname if(!$dist) $dist = "10"; // default to 10 if no preference has been defined. 0 is ugly. - $record_data = "@{$hostname}::{$recordip}:{$dist}{$ttl_string}"; + + // Check if we were given an IP, if so, put it in the ip field and leave the x field blank. + // Otherwise leave the IP blank and put in the hostname. + if (is_ipaddr($recordip)) + $record_string = "{$recordip}:"; + else + $record_string = ":{$recordip}"; + $record_data = "@{$hostname}:{$record_string}:{$dist}{$ttl_string}"; break; case "PTR": /* "^" creates "PTR" record only to allow reverse DNS */ -- cgit v1.2.3