Commit 542480f1 authored by Ad Schellevis's avatar Ad Schellevis

system_staticroutes_configure, remove dead code, add rc.newroutedns...

system_staticroutes_configure, remove dead code, add rc.newroutedns dependencies and make the optional alias use in static routes explicit with a typeahead
parent 26fbbb0f
......@@ -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;
}
......
......@@ -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')) {
......
......@@ -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});
});
</script>
<?php include("fbegin.inc"); ?>
<!-- push all available aliases in a hidden select box -->
<select class="hidden" id="aliases">
<?php
if (!empty($config['aliases']['alias'])):
foreach ($config['aliases']['alias'] as $alias):
if ($alias['type'] == 'network' || $alias['type'] == 'host'):?>
<option value="<?=$alias['name'];?>"></option>
<?php
endif;
endforeach;
endif;
?>
</select>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment