From 08769cb1ee9c5e257b65f33583b55383bcbb03fe Mon Sep 17 00:00:00 2001 From: luckman212 Date: Mon, 21 May 2018 15:35:17 -0400 Subject: [PATCH] Test patch to allow FQDNs/multiple IPs for URL Aliases This patch modifies /etc/inc/pfsense-utils.inc Tested on a couple of systems - but could use more testing! --- src/etc/inc/pfsense-utils.inc | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc index 1e65ae618e2..38c3ac29791 100644 --- a/src/etc/inc/pfsense-utils.inc +++ b/src/etc/inc/pfsense-utils.inc @@ -2337,13 +2337,36 @@ function parse_aliases_file($filename, $type = "url", $max_items = -1, $kflc = f if (!empty($tmp_str)) { $tmp = $tmp_str; } - $valid = (($type == "url" || $type == "urltable") && (is_ipaddr($tmp) || is_subnet($tmp))) || - (($type == "url_ports" || $type == "urltable_ports") && is_port_or_range($tmp)); - if ($valid) { - $items[] = $tmp; - if (count($items) == $max_items) { + switch ($type) { + case "url": + case "urltable": + if (is_ipaddr($tmp) || is_subnet($tmp)) { + $items[] = $tmp; + break; + } + if (is_fqdn($tmp)) { + exec("/usr/local/bin/dig " . ${tmp} . " A " . ${tmp} . " AAAA +short", $results, $retval); + if ($retval == 0) { + foreach ($results as $ip) { + if (is_ipaddr($ip)) { + $items[] = $ip; + } + } + } + } + break; + case "url_ports": + case "urltable_ports": + if (is_port_or_range($tmp)) { + $items[] = $tmp; + } + break; + default: + /* unknown type */ break; } + if (count($items) == $max_items) { + break; } } }