Switch to filterdns new and shiny for taking care of dns in CP.

This commit is contained in:
Ermal 2011-01-26 18:40:22 +00:00
parent c3c7fc0627
commit 422b8b4ef0

View File

@ -1072,16 +1072,20 @@ function captiveportal_allowedip_configure_entry($ipent) {
*/
function setup_dnsfilter_entries() {
global $g, $config;
$cp_filterdns_filename = "{$g['varetc_path']}/filterdns-captiveportal.conf";
$fd = fopen($cp_filterdns_filename, "w");
if (is_array($config['captiveportal']['allowedhostname']))
foreach ($config['captiveportal']['allowedhostname'] as $hostnameent)
fwrite($fd, $hostnameent['hostname'] . "\n");
fclose($fd);
$cp_filterdns_conf = "";
if (is_array($config['captiveportal']['allowedhostname'])) {
foreach ($config['captiveportal']['allowedhostname'] as $hostnameent) {
$cp_filterdns_conf .= "ipfw $hostnameent 3 /etc/rc.captiveportal_configure\n";
$cp_filterdns_conf .= "ipfw $hostnameent 4 /etc/rc.captiveportal_configure\n";
$cp_filterdns_conf .= "ipfw $hostnameent 7 /etc/rc.captiveportal_configure\n";
$cp_filterdns_conf .= "ipfw $hostnameent 8 /etc/rc.captiveportal_configure\n";
}
}
file_put_contents($cp_filterdns_filename, $cp_filterdns_conf);
killbypid("{$g['tmp_path']}/dnswatch-cpah.pid");
// For some reason the killbypid() is not working. Brute force if needed.
exec("/bin/ps awux | grep -v /usr/bin/grep | grep dnswatch-cpah.pid | /usr/bin/awk '{ print \$2 }' | /usr/bin/xargs kill");
mwexec("/usr/local/sbin/dnswatch {$g['tmp_path']}/dnswatch-cpah.pid 300 /etc/rc.captiveportal_configure {$cp_filterdns_filename}");
mwexec("/usr/local/sbin/filterdns -p {$g['tmp_path']}/dnswatch-cpah.pid -i 300 -c {$cp_filterdns_filename} -d 1");
}
function captiveportal_allowedhostname_configure() {
@ -1511,4 +1515,4 @@ function portal_ip_from_client_ip($cliip) {
return false;
}
?>
?>