Portforwarding panels modified

This commit is contained in:
John Crisp 2025-06-13 16:49:27 +02:00
parent 2ccc3b18cc
commit ffe62c9951
3 changed files with 181 additions and 169 deletions

View File

@ -8,66 +8,82 @@
% my $cmmnt = $pf_datas->{cmmnt}; % my $cmmnt = $pf_datas->{cmmnt};
% my $allow = $pf_datas->{allow}; % my $allow = $pf_datas->{allow};
% if (config->{debug} == 1) { % if (config->{debug} == 0) {
<p> <pre>
%= dumper $c->current_route <%= dumper $c->current_route %>
%= dumper $c->stash("ret") <%= dumper $c->stash("ret") %>
%= dumper %$pf_datas <%= dumper %$pf_datas %>
</p> </pre>
% } % }
%= form_for '/portforwardinge' => (method => 'POST') => begin <form action="/smanager/portforwardinge" method="POST">
<br>
%= l "pf_SUMMARY_REMOVE_DESC"
</p><br>
<span class="">
%=l "pf_LABEL_PROTOCOL"
</span>
<span class="">
%=$proto
</span><br><br>
<span class="">
%=l "pf_LABEL_SOURCE_PORT"
</span>
<span class="">
%=$sport
</span>
<br><br>
<span class="">
%=l "pf_LABEL_DESTINATION_HOST"
</span>
<span class="">
%=$dport
</span>
<br><br>
<span class="">
%=l "pf_LABEL_DESTINATION_PORT"
</span>
<span class="">
%=$dhost
</span>
<br><br>
<span class="">
%=l "pf_RULE_COMMENT"
</span>
<span class="">
%=$cmmnt
</span>
<br><br>
<span class="">
%=l "pf_ALLOW_HOSTS"
</span>
<span class="">
%=$allow
</span>
<br><br>
%#}
%= hidden_field sport=>$sport
%= hidden_field proto=>$proto
<br>
%= submit_button "$btn", class => ""
</p>
%end <br>
<div>
<%= l 'pf_SUMMARY_REMOVE_DESC' %>
</div>
<table>
<tbody>
<tr>
<td>
<% l 'pf_LABEL_PROTOCOL' %>
</td>
<td>
<%= $proto %>
</td>
</tr>
<tr>
<td>
<% l 'pf_LABEL_SOURCE_PORT' %>
</td>
<td>
<%= $sport %>
</td>
<tr>
<tr>
<td>
<% l 'pf_LABEL_DESTINATION_HOST' %>
</td>
<td>
<%= $dport %>
</td>
</tr>
<tr>
<td>
<% l 'pf_LABEL_DESTINATION_PORT' %>
</td>
<td>
<%= $dhost %>
</td>
</tr>
<tr>
<td>
<% l 'pf_RULE_COMMENT' %>
</td>
<td>
<%= $cmmnt %>
</td>
</tr>
<tr>
<td>
<% l 'pf_ALLOW_HOSTS' %>
</td>
<td>
<%= $allow %>
</td>
</tr>
</tbody>
</table>
<%= hidden_field sport=>$sport %>
<%= hidden_field proto=>$proto %>
<div class="row g-3 align-items-center">
<div class="col-md-1">
<button type="submit" class="btn btn-primary"><%= $btn %></button>
</div>
</div>
</form>
</div> </div>

View File

@ -1,6 +1,10 @@
<div> <div>
% my $btn = l('pf_CREATE_RULE');
%= form_for '/portforwardinga' => (method => 'POST') => begin
<form action="/smanager/portforwardinga" method="POST">
<br>
% my $retref= $c->stash("ret"); % my $retref= $c->stash("ret");
% my %ret; % my %ret;
@ -19,60 +23,52 @@
% my $var6 = @vars[5]; % my $var6 = @vars[5];
% if ($ret{ret} eq "") { % if ($ret{ret} eq "") {
%= $c->render_to_string(inline => l('pf_FIRST_PAGE_DESCRIPTION')); <%= $c->render_to_string(inline => l('pf_FIRST_PAGE_DESCRIPTION')); %>
% } elsif (index($ret{ret},"SUCCESS") != -1) { % } elsif (index($ret{ret},"SUCCESS") != -1) {
<br> <br>
<div class=""> <div>
<!--<h2> Operation Status Report</h2>--> <h2> Operation Status Report</h2>
%= $c->l($ret{ret},$var1,$var2,$var3,$var4,$var5,$var6); <%= $c->l($ret{ret},$var1,$var2,$var3,$var4,$var5,$var6); %>
</div> </div>
% } else { % } else {
<br> <br>
<div class=""> <div class="text-danger">
<!--<h2> Operation Status Report - Error</h2>--> <h2> Operation Status Report - Error</h2>
%= $c->l($ret{ret},$var1,$var2,$var3,$var4,$var5,$var6); <%= $c->l($ret{ret},$var1,$var2,$var3,$var4,$var5,$var6); %>
</div> </div>
% } % }
<p>
<br> <br>
%= submit_button "$btn", class => ""
</p> % my $btn = l('pf_CREATE_RULE');
<div class="row g-3 align-items-center">
<div class="col-md-2">
<button type="submit" class="btn btn-primary"><%= $btn %></button>
</div>
</div>
</form>
% end
% if ($empty){ % if ($empty){
<br> <br>
%=l 'pf_NO_FORWARDS' <%= l 'pf_NO_FORWARDS' %>
% } else { % } else {
<br> <br>
%=l 'pf_SHOW_FORWARDS' <%= l 'pf_SHOW_FORWARDS' %>
<br><br /> <br><br>
<table class="table table-bordered"> <table class="table table-bordered">
<thead> <thead>
<tr> <tr>
<th class=""> <th><%= l 'pf_LABEL_PROTOCOL' %></th>
%=l 'pf_LABEL_PROTOCOL' <th><%= l 'pf_LABEL_SOURCE_PORT' %></th>
</th> <th><%= l 'pf_LABEL_DESTINATION_HOST' %></th>
<th class=""> <th><%= l 'pf_LABEL_DESTINATION_PORT' %></th>
%=l 'pf_LABEL_SOURCE_PORT' <th><%= l 'pf_ALLOW_HOSTS' %></th>
</th> <th><%= l 'pf_RULE_COMMENT' %></th>
<th class=""> <th class="text-center"><%= l 'ACTION' %></th>
%=l 'pf_LABEL_DESTINATION_HOST'
</th>
<th class="">
%=l 'pf_LABEL_DESTINATION_PORT'
</th>
<th class="">
%=l 'pf_ALLOW_HOSTS'
</th>
<th class="">
%=l 'pf_RULE_COMMENT'
</th>
<th class="" '>
%=l 'ACTION'
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -84,30 +80,29 @@
% if (@{ $forwards{$proto} }) { % if (@{ $forwards{$proto} }) {
% foreach my $entry (@{ $forwards{$proto} }) { % foreach my $entry (@{ $forwards{$proto} }) {
<tr> <tr class="align-middle">
% my $sport = $entry->key; % my $sport = $entry->key;
% my $dhost = $entry->prop('DestHost'); % my $dhost = $entry->prop('DestHost');
% my $dport = $entry->prop('DestPort') || ''; % my $dport = $entry->prop('DestPort') || '';
% my $cmmnt = $entry->prop('Comment') || ''; % my $cmmnt = $entry->prop('Comment') || '';
% my $allow = $entry->prop('AllowHosts') || ''; % my $allow = $entry->prop('AllowHosts') || '';
%= t td => (class => "") => $proto <td><%= $proto %></td>
%= t td => (class => "") => $sport <td><%= $sport %></td>
%= t td => (class => "") => $dhost <td><%= $dhost %></td>
%= t td => (class => "") => $dport <td><%= $dport %></td>
%= t td => (class => "") => $allow <td><%= $allow %></td>
%= t td => (class => "") => $cmmnt <td><%= $cmmnt %></td>
<td class="">
% my $remove_text = l('REMOVE'); # Localized text % my $remove_text = l('REMOVE'); # Localized text
% my $csrf_token = "TOKEN"; # CSRF token for security % my $csrf_token = "TOKEN"; # CSRF token for security
% my $actionRemove = qq{ % my $actionRemove = qq{
% <a href="portforwardingd?CsrfDef=$csrf_token&trt=DEL&sport=$sport&proto=$proto"> % <a href="portforwardingd?CsrfDef=$csrf_token&trt=DEL&sport=$sport&proto=$proto">
% <button type='button' class="" title='$remove_text' > % <button type='button' class="btn btn-primary" title='$remove_text' >
% $remove_text % $remove_text
% </button> % </button>
% </a> % </a>
% }; % };
<%= $c->render_to_string(inline => $actionRemove) %>
</td> <td class="text-center"><%= $c->render_to_string(inline => $actionRemove) %></td>
</tr> </tr>
% } % }
% } % }
@ -115,6 +110,6 @@
% } % }
</tbody> </tbody>
</table> </table>
%= hidden_field 'trt' => $pf_datas->{trt} <%= hidden_field 'trt' => $pf_datas->{trt} %>
</div> </div>

View File

@ -5,28 +5,29 @@
<div class="card-body"> <div class="card-body">
% if (config->{debug} == 1) { % if (config->{debug} == 1) {
<p> <pre>
%= dumper "<pf>".$c->current_route <%= dumper "<pf>".$c->current_route %>
%= dumper $c->stash("ret") <%= dumper $c->stash("ret") %>
%= dumper $c->stash("portforwarding") <%= dumper $c->stash("portforwarding") %>
% my $ref = $pf_datas->{portforwarding}; % my $ref = $pf_datas->{portforwarding}; %>
%= dumper $ref->{TCP}->[0]."</pf>" <%= dumper $ref->{TCP}->[0]."</pf>" %>
</p> </pre>
% } % }
<h1><%= $title%></h1> <h1><%= $title%></h1>
%= $modul %= $modul
% if ($pf_datas->{trt} eq 'ADD') { % if ($pf_datas->{trt} eq 'ADD') {
%= include 'partials/_pf_add' <%= include 'partials/_pf_add' %>
% } elsif ($pf_datas->{trt} eq 'ADD1') { % } elsif ($pf_datas->{trt} eq 'ADD1') {
%= include 'partials/_pf_add' <%= include 'partials/_pf_add' %>
% } elsif ($pf_datas->{trt} eq 'DEL') { % } elsif ($pf_datas->{trt} eq 'DEL') {
%= include 'partials/_pf_del' <%= include 'partials/_pf_del' %>
% } elsif ($pf_datas->{trt} eq 'DEL1'){ % } elsif ($pf_datas->{trt} eq 'DEL1'){
%= include 'partials/_pf_list' <%= include 'partials/_pf_list' %>
% } else { % } else {
%= include 'partials/_pf_list' <%= include 'partials/_pf_list' %>
%} %}
</div> </div>