Commit 7681a291 authored by velati's avatar velati Committed by Franco Fichtner

interfaces: Host-Uniq field in PPPoE connection; closes #1730

PR: https://forum.opnsense.org/index.php?topic=5307.0
parent 36f0ff51
......@@ -1582,6 +1582,9 @@ EOD;
$provider = isset($ppp['provider']) ? $ppp['provider'] : "";
$mpdconf_arr[] = "set pppoe service \"{$provider}\"";
$mpdconf_arr[] = "set pppoe iface {$port}";
if (!empty($ppp['hostuniq'])) {
$mpdconf_arr[] = "set host-uniq \"{$ppp['hostuniq']}\"";
}
} elseif ($ppp['type'] == "pptp" || $ppp['type'] == "l2tp") {
$mpdconf_arr[] = "set {$ppp['type']} self {$localips[$pid]}";
$mpdconf_arr[] = "set {$ppp['type']} peer {$gateways[$pid]}";
......
......@@ -408,7 +408,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
}
$std_ppp_copy_fieldnames = array("ptpid", "ports", "username", "phone", "apn", "provider", "idletimeout", "localip");
$std_ppp_copy_fieldnames = array("ptpid", "ports", "username", "phone", "apn", "provider", "idletimeout", "localip", 'hostuniq');
foreach ($std_ppp_copy_fieldnames as $fieldname) {
$pconfig[$fieldname] = isset($a_ppps[$pppid][$fieldname]) ? $a_ppps[$pppid][$fieldname] : null;
}
......@@ -417,7 +417,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['pppoe_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
$pconfig['pptp_dialondemand'] = isset($a_ppps[$pppid]['ondemand']);
$pconfig['pppoe_password'] = $pconfig['password']; // pppoe password field
$pconfig["pppoe_username"] = $pconfig['username'];
$pconfig['pppoe_username'] = $pconfig['username'];
$pconfig['pppoe_hostuniq'] = $pconfig['hostuniq'];
$pconfig['pppoe_idletimeout'] = $pconfig['idletimeout'];
$pconfig['pptp_username'] = $pconfig['username'];
......@@ -1014,6 +1015,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (!empty($pconfig['provider'])) {
$new_ppp_config['provider'] = $pconfig['provider'];
}
if (!empty($pconfig['pppoe_hostuniq'])) {
$new_ppp_config['hostuniq'] = $pconfig['pppoe_hostuniq'];
}
$new_ppp_config['ondemand'] = !empty($pconfig['pppoe_dialondemand']);
if (!empty($pconfig['pppoe_idletimeout'])) {
$new_ppp_config['idletimeout'] = $pconfig['pppoe_idletimeout'];
......@@ -2194,6 +2198,15 @@ include("head.inc");
</div>
</td>
</tr>
<tr>
<td><a id="help_for_pppoe_hostuniq" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?= gettext("Host-Uniq"); ?></td>
<td>
<input name="pppoe_hostuniq" type="text" id="pppoe_hostuniq" value="<?=$pconfig['pppoe_hostuniq'];?>" />
<div class="hidden" for="help_for_pppoe_hostuniq">
<?= gettext('This field can usually be left empty unless specified by the provider.') ?>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_pppoe_dialondemand" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Dial on demand"); ?></td>
<td>
......
......@@ -49,7 +49,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
// plain 1-on-1 copy
$copy_fields = array('ptpid', 'type', 'username', 'idletimeout', 'uptime', 'descr', 'simpin', 'pin-wait',
'apn', 'apnum', 'phone', 'connect-timeout', 'provider');
'apn', 'apnum', 'phone', 'connect-timeout', 'provider', 'hostuniq');
foreach ($copy_fields as $fieldname) {
if (isset($a_ppps[$id][$fieldname])) {
$pconfig[$fieldname] = $a_ppps[$id][$fieldname];
......@@ -213,6 +213,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} else {
$ppp['provider'] = !empty($pconfig['null_service']);
}
if (!empty($pconfig['hostuniq'])) {
$ppp['hostuniq'] = $pconfig['hostuniq'];
}
break;
case "pptp":
case "l2tp":
......@@ -266,7 +269,7 @@ include("head.inc");
$(document).ready(function() {
// change type
$("#type").change(function(){
$('#ppp,#ppp_adv,#pppoe,#ppp_provider,#phone_num,#apn_').hide();
$('#ppp,#ppp_adv,#pppoe,#hostuniqopt,#ppp_provider,#phone_num,#apn_').hide();
$('#ports > [data-type="serial"]').hide();
$('#ports > [data-type="serial"]').prop('disabled', true);
$('#ports > [data-type="interface"]').hide();
......@@ -294,6 +297,7 @@ include("head.inc");
break;
case "pppoe":
$('#pppoe').show();
$('#hostuniqopt').show();
// fall through to show interface items
default:
$('#ports > [data-type="interface"]').show();
......@@ -547,6 +551,15 @@ include("head.inc");
</div>
</td>
</tr>
<tr style="display:none" name="hostuniqopt" id="hostuniqopt">
<td><a id="help_for_hostuniq" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?= gettext("Host-Uniq"); ?></td>
<td>
<input name="hostuniq" type="text" id="hostuniq" value="<?=$pconfig['hostuniq'];?>" />
<div class="hidden" for="help_for_hostuniq">
<?= gettext('This field can usually be left empty unless specified by the provider.') ?>
</div>
</td>
</tr>
</tbody>
</table>
<table class="table table-striped" id="interface_details" style="display:none">
......
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