3 Commits

Author SHA1 Message Date
a2c3f3cdb4 * Fri Oct 03 2025 Brian Read <brianr@koozali.org> 1.0-28.sme
- Add in UTF8 to ConfigDB open [SME: 13209]
2025-10-03 15:33:04 +01:00
367e4da9e8 * Fri Oct 03 2025 Brian Read <brianr@koozali.org> 1.0-27.sme
- Remove smanager-refresh from spec file [SME: 13212]
2025-10-03 13:10:43 +01:00
5858500b80 * Fri Sep 26 2025 Brian Read <brianr@koozali.org> 1.0-26.sme
- Fix remove logic, add in user name to rem panel re-format templates,  add space to list panel [SME: 13168]
2025-09-26 11:16:13 +01:00
6 changed files with 250 additions and 226 deletions

View File

@@ -18,7 +18,7 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw( theme_list init_session is_normal_password );
use esmith::ConfigDB;
use esmith::ConfigDB::UTF8;
use Net::IP;
my $adb;
my $cdb;
@@ -29,10 +29,10 @@ sub main {
my $c = shift;
$c->app->log->info($c->log_req);
my %wrg_datas = ();
$wdb = esmith::ConfigDB->open('wireguard') || esmith::ConfigDB->create('wireguard');
$wdb = esmith::ConfigDB::UTF8->open('wireguard') || esmith::ConfigDB::UTF8->create('wireguard');
my $title = $c->l('wrg_FORM_TITLE');
$wrg_datas{'trt'} = 'LST';
$cdb = esmith::ConfigDB->open() || die "Couldn't open config DB\n";
$cdb = esmith::ConfigDB::UTF8->open() || die "Couldn't open config DB\n";
my $wg = $cdb->get('wg-quick@wg0');
$wrg_datas{'wgpub'} = $wg->prop('public');
$wrg_datas{'wgip'} = $wg->prop('ip');
@@ -61,8 +61,8 @@ sub do_display {
my $title = $c->l('wrg_FORM_TITLE');
my $modul = '';
$adb = esmith::AccountsDB->open() || die "Couldn't open accounts DB\ndb";
$cdb = esmith::ConfigDB->open() || die "Couldn't open config DB\n";
$wdb = esmith::ConfigDB->open('wireguard') || esmith::ConfigDB->create('wireguard');
$cdb = esmith::ConfigDB::UTF8->open() || die "Couldn't open config DB\n";
$wdb = esmith::ConfigDB::UTF8->open('wireguard') || esmith::ConfigDB::UTF8->create('wireguard');
#$ndb = esmith::NetworksDB->open_ro || die "Error opening networks DB\n";
$wrg_datas{'trt'} = $trt;
@@ -125,8 +125,8 @@ sub do_action {
my $result = '';
my $res = '';
$adb = esmith::AccountsDB->open() || die "Couldn't open accounts DB\ndb";
$cdb = esmith::ConfigDB->open() || die "Couldn't open config DB\n";
$wdb = esmith::ConfigDB->open('wireguard') || esmith::ConfigDB->create('wireguard');
$cdb = esmith::ConfigDB::UTF8->open() || die "Couldn't open config DB\n";
$wdb = esmith::ConfigDB::UTF8->open('wireguard') || esmith::ConfigDB::UTF8->create('wireguard');
$ndb = esmith::NetworksDB->open_ro || die "Error opening networks DB\n";
if ($trt eq 'QRC') {
@@ -216,7 +216,7 @@ sub do_action {
}
#force reload as successfull (for Main)
$wdb = esmith::ConfigDB->open('wireguard');
$wdb = esmith::ConfigDB::UTF8->open('wireguard');
my $message = "'Wireguard' update ($trt) DONE";
$c->app->log->info($message);
$c->flash(success => $result);

View File

@@ -46,10 +46,10 @@
'wrg_ERROR_WRONG_ACCT_TYPE' => 'The associated account shoult be a user or admin account.',
'wrg_ERROR_OCCURED' => 'An error occured',
'wrg_CLIENTS_ALREADY_CONFIGURED' => 'You can not alter the server ip, mask, private and public key as there are already some clients configured.',
'wrg_NO_CONF' => 'No configured client',
'wrg_NO_CONF' => 'No configured clients',
'wrg_INTERFACE' => 'Interface',
'wrg_CANCELLED' => 'Operation cancelled',
'wrg_SUCCESSFULLY_MODIFIED_CONF' => 'Client configuration successfully modified',
'wrg_SUCCESSFULLY_REMOVED_CONF' => 'Client successfully removed',
'wrg_SUCCESSFULLY_ADDED_CONF' => 'New client successfully added',
'wrg_SUCCESSFULLY_UPDATED_CONF' => 'Server configuration successfully modified',
'wrg_SUCCESSFULLY_UPDATED_CONF' => 'Server configuration successfully modified',

View File

@@ -1,73 +1,74 @@
<div id='wrg_list'>
<p><%=l 'wrg_DESC_MAIN_PAGE'%><br></p>
<p><%= l 'wrg_DESC_MAIN_PAGE' %><br></p>
%= form_for 'wireguard' => (method => 'POST') => begin
%= hidden_field 'trt' => 'UPD'
<p><%=l 'wrg_LABEL_CONFIG'%><br><br></p>
%= submit_button l('wrg_EDIT_CONFIG'), class => 'action'
% end
%= form_for 'wireguard' => (method => 'POST') => begin
%= hidden_field 'trt' => 'UPD'
<p><%= l 'wrg_LABEL_CONFIG' %><br><br></p>
%= submit_button l('wrg_EDIT_CONFIG'), class => 'action'
% end
<p><span class=label>
%=l 'wrg_INTERFACE'
</span> wg0<br></p>
<p><span class=label>
%= l 'wrg_INTERFACE'
</span> wg0<br></p>
<p><span class=label>
%=l 'wrg_LABEL_STATUS'
</span>
%= $wrg_datas->{sstatus}
<br></p>
<p><span class=label>
%= l 'wrg_LABEL_STATUS'
</span>
%= $wrg_datas->{sstatus}
<br></p>
<p><span class=label>
%=l 'wrg_PUBLIC_KEY'
</span>
%= $wrg_datas->{wgpub}
<br></p>
<p><span class=label>
%= l 'wrg_PUBLIC_KEY'
</span>
%= $wrg_datas->{wgpub}
<br></p>
<p><span class=label>
%=l 'wrg_IP'
</span>
%= $wrg_datas->{wgip}.'/'.$wrg_datas->{wgmask}
<br></p>
<p><span class=label>
%= l 'wrg_IP'
</span>
%= $wrg_datas->{wgip}.'/'.$wrg_datas->{wgmask}
<br></p>
<p><span class=label>
%=l 'wrg_PORT'
</span>
%= $wrg_datas->{wgport}
<br></p>
<p><span class=label>
%= l 'wrg_PORT'
</span>
%= $wrg_datas->{wgport}
<br></p>
<br />
<table class="sme-border"><tbody>
<tr>
<th class='sme-border'>
%=l 'wrg_PUBLIC_KEY'
</th><th class='sme-border'>
%=l 'wrg_INFO'
</th><th class='sme-border'>
%=l 'wrg_ENDPOINT'
</th><th class='sme-border'>
%=l 'wrg_VPN_IP'
</th><th class='sme-border'>
%=l 'wrg_LATEST_HANDSHAKE'
</th><th class='sme-border'>
%=l 'wrg_RECEIVED'
</th><th class='sme-border'>
%=l 'wrg_SENT'
</th><th class='sme-border'>
%=l 'wrg_KEEPALIVE'
</th>
</tr>
<table class="sme-border"><tbody>
<tr>
<th class='sme-border'>
%= l 'wrg_PUBLIC_KEY'
</th><th class='sme-border'>
%= l 'wrg_INFO'
</th><th class='sme-border'>
%= l 'wrg_ENDPOINT'
</th><th class='sme-border'>
%= l 'wrg_VPN_IP'
</th><th class='sme-border'>
%= l 'wrg_LATEST_HANDSHAKE'
</th><th class='sme-border'>
%= l 'wrg_RECEIVED'
</th><th class='sme-border'>
%= l 'wrg_SENT'
</th><th class='sme-border'>
%= l 'wrg_KEEPALIVE'
</th>
</tr>
% if (scalar @$wgstatus > 0) {
% foreach my $list (@$wgstatus) {
% #public-key | private-key | listen-port |persistent-keepalive
% my @line = split(' ',$list);
% next if $line[1] eq $wrg_datas->{wgpub};
% my ($ginfo, $user);
% $ginfo = $c->get_wgs_info('info', "$line[3]");
% $user = $c->get_wgs_info('user', "$line[3]");
% use POSIX qw( strftime );
% my $dateR= ($line[4] ) ? strftime("%Y-%m-%d %H:%M:%S", localtime($line[4])) : " ";
<tr>
% if (scalar @$wgstatus > 0) {
% foreach my $list (@$wgstatus) {
% #public-key | private-key | listen-port |persistent-keepalive
% my @line = split(' ',$list);
% next if $line[1] eq $wrg_datas->{wgpub};
% my ($ginfo, $user);
% $ginfo = $c->get_wgs_info('info', "$line[3]");
% $user = $c->get_wgs_info('user', "$line[3]");
% use POSIX qw( strftime );
% my $dateR= ($line[4] ) ? strftime("%Y-%m-%d %H:%M:%S", localtime($line[4])) : " ";
<tr>
%= t td => (class => 'sme-border') => $line[0]
%= t td => (class => 'sme-border') => "$user : $ginfo"
%= t td => (class => 'sme-border') => $line[2]
@@ -76,55 +77,56 @@
%= t td => (class => 'sme-border') => $line[5]
%= t td => (class => 'sme-border') => $line[6]
%= t td => (class => 'sme-border') => $line[7]
</tr>
% }
% }
</tbody></table>
</tr>
% }
% }
</tbody></table>
%= form_for 'wireguard' => (method => 'POST') => begin
<hr class='sectionbar'/>
<p><%=l 'wrg_LABEL_CLIENTS'%><br><br></p>
%= hidden_field 'trt' => 'NEW'
%= submit_button l('wrg_ADD_CLIENT'), class => 'action'
% end
% if ( scalar @$wgconf == 0 ) {
%=l 'wrg_NO_CONF'
% } else {
<table class="sme-border"><tbody>
<tr>
<th class='sme-border'>
%=l 'wrg_CONF_NAME'
</th><th class='sme-border'>
%=l 'wrg_USER'
</th><th class='sme-border'>
%=l 'wrg_INFO'
</th><th class='sme-border'>
%=l 'wrg_LABEL_STATUS'
</th><th class='sme-border' colspan='3'>
%=l 'ACTION'
</th>
</tr>
% foreach my $conf (@$wgconf) {
% my $status = $c->l(uc($conf->prop('status') || 'enabled'));
<tr>
%= t td => (class => 'sme-border') => $conf->key
%= t td => (class => 'sme-border') => $conf->prop('user') || ''
%= t td => (class => 'sme-border') => $conf->prop('info') || ''
%= t td => (class => 'sme-border') => $status
% my $action =
% "<a href='wireguard2?CsrfDef=TOKEN&trt=QRC&Wgconf=" . $conf->key . "'>" . l('wrg_QRCODE') . "</a>";
<td class='sme-border'><%= $c->render_to_string(inline => $action) %></td>
% $action =
% "<a href='wireguard2?CsrfDef=TOKEN&trt=MOD&Wgconf=" . $conf->key . "'>" . l('MODIFY') . "</a>";
<td class='sme-border'><%= $c->render_to_string(inline => $action) %></td>
% $action =
% "<a href='wireguard2?CsrfDef=TOKEN&trt=REM&Wgconf=" . $conf->key . "'>" . l('REMOVE') . "</a>";
<td class='sme-border'><%= $c->render_to_string(inline => $action) %></td>
</tr>
% }
</tbody>
</table>
%}
%= form_for 'wireguard' => (method => 'POST') => begin
<hr class='sectionbar'/>
</div>
<p><%= l 'wrg_LABEL_CLIENTS' %><br><br></p>
%= hidden_field 'trt' => 'NEW'
%= submit_button l('wrg_ADD_CLIENT'), class => 'action'
% end
% if ( scalar @$wgconf == 0 ) {
%= l 'wrg_NO_CONF'
% } else {
<br />
<table class="sme-border"><tbody>
<tr>
<th class='sme-border'>
%= l 'wrg_CONF_NAME'
</th><th class='sme-border'>
%= l 'wrg_USER'
</th><th class='sme-border'>
%= l 'wrg_INFO'
</th><th class='sme-border'>
%= l 'wrg_LABEL_STATUS'
</th><th class='sme-border' colspan='3'>
%= l 'ACTION'
</th>
</tr>
% foreach my $conf (@$wgconf) {
% my $status = $c->l(uc($conf->prop('status') || 'enabled'));
<tr>
%= t td => (class => 'sme-border') => $conf->key
%= t td => (class => 'sme-border') => $conf->prop('user') || ''
%= t td => (class => 'sme-border') => $conf->prop('info') || ''
%= t td => (class => 'sme-border') => $status
% my $action =
% "<a href='wireguard2?CsrfDef=TOKEN&trt=QRC&Wgconf=" . $conf->key . "'>" . l('wrg_QRCODE') . "</a>";
<td class='sme-border'><%= $c->render_to_string(inline => $action) %></td>
% $action =
% "<a href='wireguard2?CsrfDef=TOKEN&trt=MOD&Wgconf=" . $conf->key . "'>" . l('MODIFY') . "</a>";
<td class='sme-border'><%= $c->render_to_string(inline => $action) %></td>
% $action =
% "<a href='wireguard2?CsrfDef=TOKEN&trt=REM&Wgconf=" . $conf->key . "'>" . l('REMOVE') . "</a>";
<td class='sme-border'><%= $c->render_to_string(inline => $action) %></td>
</tr>
% }
</tbody>
</table>
% }
<hr class='sectionbar'/>
</div>

View File

@@ -1,94 +1,103 @@
Mojolicious Template Code Formatter vmojofmt 0.1.9
Input data:
Upload a file:
(none)
Remove empty lines from output
Formatted Output:
Output Syntax:
<div id='wrg_mod'>
%= form_for '/wireguard2' => (method => 'POST') => begin
<p>
%=l 'wrg_DESC_MODIFY_CLIENT_PAGE'
</p>
<hr class='sectionbar'/>
%= form_for '/wireguard2' => (method => 'POST') => begin
<p>
%= l 'wrg_DESC_MODIFY_CLIENT_PAGE'
</p>
<hr class='sectionbar'/>
<p>
%=l 'wrg_DESC_CONF_NAME'
</p>
<p>
%= l 'wrg_DESC_CONF_NAME'
</p>
<p><span class=label>
%=l 'wrg_CONF_NAME'
</span>
%= $wrg_datas->{wgconf}
<br></p>
<p><span class=label>
%= l 'wrg_CONF_NAME'
</span>
%= $wrg_datas->{wgconf}
<br></p>
<p>
%=l 'wrg_DESC_SELECT_ACCOUNT'
</p>
<p>
%= l 'wrg_DESC_SELECT_ACCOUNT'
</p>
<p><span class=label>
%=l 'wrg_SELECT_ACCOUNT'
</span><span class=data>
% param 'Account' => $wrg_datas->{account} unless param 'Account';
%= select_field 'Account' => $c->get_existing_accounts(), class => 'input'
<br></span></p>
<p><span class=label>
%= l 'wrg_SELECT_ACCOUNT'
</span><span class=data>
% param 'Account' => $wrg_datas->{account} unless param 'Account';
%= select_field 'Account' => $c->get_existing_accounts(), class => 'input'
<br></span></p>
<p>
%=l 'wrg_DESC_INFO_ACC_WIREGUARD'
</p>
<p>
%= l 'wrg_DESC_INFO_ACC_WIREGUARD'
</p>
<p><span class=label>
%=l 'wrg_INFO_ACC_WIREGUARD'
</span><span class=data>
% param 'Info' => $wrg_datas->{info} unless param 'Info';
%=text_field 'Info' => size => '45', class => 'input'
<br></span></p>
<p>
%=l 'wrg_DESC_PRIVATE'
</p>
<p><span class=label>
%= l 'wrg_INFO_ACC_WIREGUARD'
</span><span class=data>
% param 'Info' => $wrg_datas->{info} unless param 'Info';
%= text_field 'Info' => size => '45', class => 'input'
<br></span></p>
<p><span class=label>
%=l 'wrg_LABEL_PRIVATE'
</span><span class=data>
% param 'Private' => $wrg_datas->{private} unless param 'Private';
%=text_field 'Private' => size => '45', class => 'input'
<br></span></p>
<p>
%=l 'wrg_DESC_PUBLIC'
</p>
<p>
%= l 'wrg_DESC_PRIVATE'
</p>
<p><span class=label>
%=l 'wrg_LABEL_PUBLIC'
</span><span class=data>
% param 'Public' => $wrg_datas->{public} unless param 'Public';
%=text_field 'Public' => size => '45', class => 'input'
<br></span></p>
<p>
%=l 'wrg_DESC_STATUS'
</p>
<p><span class=label>
%= l 'wrg_LABEL_PRIVATE'
</span><span class=data>
% param 'Private' => $wrg_datas->{private} unless param 'Private';
%= text_field 'Private' => size => '45', class => 'input'
<br></span></p>
<p><span class=label>
%=l 'wrg_LABEL_STATUS'
</span><span class=data>
% param 'Status' => $wrg_datas->{status} unless param 'Status';
%= select_field 'Status' => [[ (l 'DISABLED') => 'disabled'], [ (l 'ENABLED') => 'enabled']], class => 'input'
<br></span></p>
<p>
%= l 'wrg_DESC_PUBLIC'
</p>
<p>
%=l 'wrg_DESC_ALLOWEDIPS'
</p>
<p><span class=label>
%= l 'wrg_LABEL_PUBLIC'
</span><span class=data>
% param 'Public' => $wrg_datas->{public} unless param 'Public';
%= text_field 'Public' => size => '45', class => 'input'
<br></span></p>
<p><span class=label>
%=l 'wrg_LABEL_ALLOWEDIPS'
</span><span class=data>
% param 'Allowedips' => $wrg_datas->{allowedips} unless param 'Allowedips';
%=text_field 'Allowedips' => size => '45', class => 'input'
<br></span></p>
<div class='center'>
%= submit_button l('MODIFY'), name => 'modify', class => 'action'
</div>
<p>
%= l 'wrg_DESC_STATUS'
</p>
%= hidden_field 'trt' => $wrg_datas->{trt}
%= hidden_field 'Wgconf' => $wrg_datas->{wgconf}
% end
<p><span class=label>
%= l 'wrg_LABEL_STATUS'
</span><span class=data>
% param 'Status' => $wrg_datas->{status} unless param 'Status';
%= select_field 'Status' => [[ (l 'DISABLED') => 'disabled'], [ (l 'ENABLED') => 'enabled']], class => 'input'
<br></span></p>
</div>
<p>
%= l 'wrg_DESC_ALLOWEDIPS'
</p>
<p><span class=label>
%= l 'wrg_LABEL_ALLOWEDIPS'
</span><span class=data>
% param 'Allowedips' => $wrg_datas->{allowedips} unless param 'Allowedips';
%= text_field 'Allowedips' => size => '45', class => 'input'
<br></span></p>
<div class='center'>
%= submit_button l('MODIFY'), name => 'modify', class => 'action'
</div>
%= hidden_field 'trt' => $wrg_datas->{trt}
%= hidden_field 'Wgconf' => $wrg_datas->{wgconf}
% end
</div>

View File

@@ -1,30 +1,38 @@
<div id='wrg_rem'>
%= form_for '/wireguard2' => (method => 'POST') => begin
<p>
%=l 'wrg_DESC_REMOVE_CLIENT'
</p>
%= form_for '/wireguard2' => (method => 'POST') => begin
<p>
%= l 'wrg_DESC_REMOVE_CLIENT'
</p>
<p><br><span class=label>
%=l 'wrg_CONF_NAME'
</span>
%= $wrg_datas->{account}
<br></p>
<p><span class=label>
%= l 'wrg_USER'
</span><span class=data>
%= $wrg_datas->{account}
</p>
<p><span class=label>
%=l 'COMMENT'
</span>
%= $wrg_datas->{wgcomment}
<br></p>
<p><span class=label>
%= l 'wrg_CONF_NAME'
</span><span class=data>
%= $wrg_datas->{wgconf}
</span>
</p>
<div class="center">
%= submit_button l('REMOVE'), name => 'remove', class => 'action left-btn'
%= submit_button l('CANCEL'), name => 'cancel', class => 'action center-btn'
</div>
<p><span class=label>
%= l 'COMMENT'
</span><span class=data>
%= $wrg_datas->{wgcomment}
</span>
</p>
<div class="center">
%= submit_button l('REMOVE'), name => 'remove', class => 'action left-btn'
%= submit_button l('CANCEL'), name => 'cancel', class => 'action center-btn'
</div>
%= hidden_field 'trt' => $wrg_datas->{trt}
%= hidden_field 'Wgconf' => $wrg_datas->{wgconf}
%= hidden_field 'trt' => $wrg_datas->{trt}
%= hidden_field 'Wgconf' => $wrg_datas->{account}
% end
</div>
</div>

View File

@@ -1,4 +1,4 @@
%define release 25
%define release 28
%define version 1.0
%define debug_package %{nil}
@@ -54,13 +54,18 @@ cat %{name}-%{version}-filelist
#%doc COPYING
%post
if (systemctl list-unit-files |grep smanager) then
echo "Smanager restart in spec file"
/sbin/e-smith/signal-event smanager-refresh;
fi
%changelog
* Fri Oct 03 2025 Brian Read <brianr@koozali.org> 1.0-28.sme
- Add in UTF8 to ConfigDB open [SME: 13209]
* Fri Oct 03 2025 Brian Read <brianr@koozali.org> 1.0-27.sme
- Remove smanager-refresh from spec file [SME: 13212]
* Fri Sep 26 2025 Brian Read <brianr@koozali.org> 1.0-26.sme
- Fix remove logic, add in user name to rem panel re-format templates, add space to list panel [SME: 13168]
* Thu Sep 25 2025 Brian Read <brianr@koozali.org> 1.0-25.sme
- Sort outy Remove panel placement and operation of buttons [SME: 13168]