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

[FEATURE] Configurable peer status visibility #144

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ function wg_do_settings_post($post) {

$pconfig['hide_secrets'] = empty($post['hide_secrets']) ? 'no' : $post['hide_secrets'];

$pconfig['hide_peers'] = empty($post['hide_peers']) ? 'no' : $post['hide_peers'];

$input_errors = wg_validate_settings_post($pconfig);

if (empty($input_errors)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,24 @@ function wg_secret_input_type() {
return $type;
}

// Returns bool indicating if peers should be hidden on status page on load
function wg_status_peers_hidden() {
global $wgg;

wg_globals();

$hidden = true;

if (isset($wgg['config']['hide_peers'])) {

$hidden = $wgg['config']['hide_peers'] == 'yes';

}

return $hidden;

}

function wg_tunnel_status_class($tunnel = null) {
global $wgg;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ function wg_defaults_install() {
$wgg['config']['interface_group'] = isset($wgg['config']['interface_group']) ? $wgg['config']['interface_group'] : 'all';

$wgg['config']['hide_secrets'] = isset($wgg['config']['hide_secrets']) ? $wgg['config']['hide_secrets'] : 'yes';

$wgg['config']['hide_peers'] = isset($wgg['config']['hide_peers']) ? $wgg['config']['hide_peers'] : 'yes';

wg_write_config('Applied package default settings as necessary.', false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@

?>

<?php if (wg_status_peers_hidden()) { ?>
<style> tr.peer-entries { display: none; } </style>
<?php } ?>

<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title"><?=gettext('WireGuard Status')?></h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@
))->setHelp("{$s(gettext('Configures which WireGuard tunnels are members of the WireGuard interface group.'))}<br />
<span class=\"text-danger\">{$s(gettext('Note:'))} </span> {$s(sprintf(gettext("Group firewall rules are evaluated before interface firewall rules. Default is '%s.'"), $interface_group_list['all']))}");

$section->addInput(new Form_Checkbox(
'hide_peers',
gettext('Hide Peers'),
gettext('Enable'),
$pconfig['hide_peers'] == 'yes'
))->setHelp("<span class=\"text-danger\">{$s(gettext('Note:'))} </span>
{$s(gettext("With 'Hide Peers' enabled (default), all peers for all tunnels will be hidden on Status page load."))}");

$form->add($section);

$section = new Form_Section(gettext('User Interface Settings'));
Expand Down