From 542480f12aaef4ba6fe5efd2e301f5ee8b763510 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 30 May 2016 21:32:29 +0200 Subject: [PATCH] system_staticroutes_configure, remove dead code, add rc.newroutedns dependencies and make the optional alias use in static routes explicit with a typeahead --- src/etc/inc/system.inc | 60 +++++++--------------------------- src/etc/rc.newroutedns | 2 ++ src/www/system_routes_edit.php | 19 +++++++++++ 3 files changed, 33 insertions(+), 48 deletions(-) diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 58ded90dc..73f46ecc3 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -611,7 +611,7 @@ function system_routing_configure($interface = '') mwexecf('/sbin/route add -inet6 %s %s', array('default', $gatewayipv6)); } - system_staticroutes_configure($interface, false); + system_staticroutes_configure($interface); return 0; } @@ -660,7 +660,7 @@ function compare_hostname_to_dnscache($hostname) { } } -function system_staticroutes_configure($interface = '', $update_dns = false) +function system_staticroutes_configure($interface = '') { global $config, $aliastable; @@ -698,17 +698,6 @@ function system_staticroutes_configure($interface = '', $update_dns = false) continue; } - $dnscache = array(); - if ($update_dns === true) { - if (is_subnet($rtent['network'])) { - continue; - } - $dnscache = explode("\n", trim(compare_hostname_to_dnscache($rtent['network']))); - if (empty($dnscache)) { - continue; - } - } - if (is_subnet($rtent['network'])) { $ips = array($rtent['network']); } else { @@ -717,21 +706,6 @@ function system_staticroutes_configure($interface = '', $update_dns = false) } $ips = add_hostname_to_watch($rtent['network']); } - foreach ($dnscache as $ip) { - if (in_array($ip, $ips)) { - continue; - } - - if (!is_subnet($ip)) { - if (is_ipaddrv4($ip)) { - $ip .= "/32"; - } elseif (is_ipaddrv6($ip)) { - $ip .= "/128"; - } - } - $inet = (is_subnetv6($ip) ? "-inet6" : "-inet"); - mwexec("/sbin/route delete {$inet} " . escapeshellarg($ip)); - } if (isset($rtent['disabled'])) { foreach ($ips as $ip) { @@ -777,31 +751,21 @@ function system_staticroutes_configure($interface = '', $update_dns = false) } } } - unset($gateways_arr); } - unset($static_routes); - if ($update_dns === false) { - if (count($filterdns_list)) { - $interval = 60; - $hostnames = ""; - array_unique($filterdns_list); - foreach ($filterdns_list as $hostname) { - $hostnames .= "cmd {$hostname} '/usr/local/opnsense/service/configd_ctl.py routedns reload'\n"; - } - file_put_contents("/var/etc/filterdns-route.hosts", $hostnames); - unset($hostnames); - - if (isvalidpid('/var/run/filterdns-route.pid')) { - killbypid('/var/run/filterdns-route.pid', 'HUP'); - } else { - mwexec("/usr/local/sbin/filterdns -p /var/run/filterdns-route.pid -i {$interval} -c /var/etc/filterdns-route.hosts -d 1"); - } + if (count($filterdns_list)) { + $hostnames = ""; + array_unique($filterdns_list); + foreach ($filterdns_list as $hostname) { + $hostnames .= "cmd {$hostname} '/usr/local/opnsense/service/configd_ctl.py routedns reload'\n"; + } + file_put_contents("/var/etc/filterdns-route.hosts", $hostnames); + if (isvalidpid('/var/run/filterdns-route.pid')) { + killbypid('/var/run/filterdns-route.pid', 'HUP'); } else { - killbypid('/var/run/filterdns-route.pid'); + mwexec("/usr/local/sbin/filterdns -p /var/run/filterdns-route.pid -i 60 -c /var/etc/filterdns-route.hosts -d 1"); } } - unset($filterdns_list); return 0; } diff --git a/src/etc/rc.newroutedns b/src/etc/rc.newroutedns index e4b5f5bca..aed10edb7 100755 --- a/src/etc/rc.newroutedns +++ b/src/etc/rc.newroutedns @@ -32,6 +32,8 @@ require_once("util.inc"); require_once("config.inc"); require_once("system.inc"); require_once("pfsense-utils.inc"); +require_once("interfaces.inc"); +require_once("gwlb.inc"); /* make sure to wait until the boot scripts have finished */ if (file_exists('/var/run/booting')) { diff --git a/src/www/system_routes_edit.php b/src/www/system_routes_edit.php index 13b887411..edba90487 100644 --- a/src/www/system_routes_edit.php +++ b/src/www/system_routes_edit.php @@ -231,9 +231,28 @@ include("head.inc"); $( document ).ready(function() { // hook in, ipv4/ipv6 selector events hook_ipv4v6('ipv4v6net', 'network-id'); + // collect aliases + var all_aliases = []; + $("#aliases > option").each(function(){ + all_aliases.push($(this).val()) + }); + $("#network").typeahead({ source: all_aliases}); }); + +