Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbound: add WPAD #2097

Merged
merged 7 commits into from
Jul 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/etc/inc/plugins.inc.d/unbound.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/*
* Copyright (C) 2018 Fabian Franz
* Copyright (C) 2015-2018 Franco Fichtner <franco@opnsense.org>
* Copyright (C) 2015 Manuel Faux <mfaux@conf.at>
* Copyright (C) 2014 Warren Baker <warren@decoy.co.za>
Expand Down Expand Up @@ -567,6 +568,28 @@ function unbound_add_host_entries()
}
}
}
if (isset($config['unbound']['enable_wpad'])) {
$webui_protocol = !empty($config['system']['webgui']['protocol']) ? $config['system']['webgui']['protocol'] : 'https';
$webui_port = !empty($config['system']['webgui']['port']) ? $config['system']['webgui']['port'] : 443;
// default domain
$system_host_fqdn = $config['system']['hostname'];
if (isset($config['system']['domain'])) {
$system_host_fqdn .= '.' . $config['system']['domain'];
}
$unbound_entries .= "local-data: \"wpad.{$domain} IN CNAME {$system_host_fqdn}\"\n";
$unbound_entries .= "local-data: \"wpad IN CNAME {$system_host_fqdn}\"\n";
$unbound_entries .= "local-data: '{$domain} IN TXT \"service: wpad:{$webui_protocol}://{$system_host_fqdn}:{$webui_port}/wpad.dat\"'\n";
// DHCP domains
$tmp_known_domains = array($domain);
foreach ($config['dhcpd'] as $dhcp_interface) {
if (isset($dhcp_interface['domain']) && !empty($dhcp_interface['domain']) && !in_array($dhcp_interface['domain'], $tmp_known_domains)) {
$unbound_entries .= "local-data: \"wpad.{$dhcp_interface['domain']} IN CNAME {$system_host_fqdn}\"\n";
$unbound_entries .= "local-data: '{$dhcp_interface['domain']} IN TXT \"service: wpad:{$webui_protocol}://{$system_host_fqdn}:{$webui_port}/wpad.dat\"'\n";
$tmp_known_domains[] = $dhcp_interface['domain'];
}
}
unset($tmp_known_domains); // remove temporary variable
}

/* Static Host entries */

Expand Down
13 changes: 13 additions & 0 deletions src/www/services_unbound.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/*
Copyright (C) 2818 Fabian Franz
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2014 Warren Baker <warren@decoy.co.za>
All rights reserved.
Expand Down Expand Up @@ -38,6 +39,7 @@
$pconfig = array();
// boolean values
$pconfig['enable'] = isset($a_unboundcfg['enable']);
$pconfig['enable_wpad'] = isset($a_unboundcfg['enable_wpad']);
$pconfig['dnssec'] = isset($a_unboundcfg['dnssec']);
$pconfig['forwarding'] = isset($a_unboundcfg['forwarding']);
$pconfig['reglladdr6'] = empty($a_unboundcfg['noreglladdr6']);
Expand Down Expand Up @@ -108,6 +110,7 @@

// boolean values
$a_unboundcfg['enable'] = !empty($pconfig['enable']);
$a_unboundcfg['enable_wpad'] = !empty($pconfig['enable_wpad']);
$a_unboundcfg['dnssec'] = !empty($pconfig['dnssec']);
$a_unboundcfg['forwarding'] = !empty($pconfig['forwarding']);
$a_unboundcfg['noreglladdr6'] = empty($pconfig['reglladdr6']);
Expand Down Expand Up @@ -292,6 +295,16 @@
</div>
</td>
</tr>
<tr>
<td><a id="help_for_enable_wpad" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("WPAD Records");?></td>
<td>
<input name="enable_wpad" type="checkbox" value="yes" <?=!empty($pconfig['enable_wpad']) ? "checked=\"checked\"" : "";?> />
<div class="hidden" for="help_for_enable_wpad">
<?=gettext("If this option is set, CNAME records for the WPAD host of all configured domains will be automatically added as well as overrides for TXT records for domains. " .
"This allows automatic proxy configuration in your network but you should not enable it if you are not using WPAD or if you want to configure it by yourself.");?><br />
</div>
</td>
</tr>
<tr>
<td><i class="fa fa-info-circle text-muted"></i> <?=gettext("Advanced");?></td>
<td>
Expand Down