Port forward translation

This commit is contained in:
Eduardo Silva
2025-04-16 11:31:08 -03:00
parent 3cb10b6ec4
commit 23c3dce14f
7 changed files with 301 additions and 110 deletions

View File

@@ -1,3 +1,4 @@
{% load i18n %}
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link {% if current_chain == "forward" %}active{% endif %}" href="/firewall/rule_list/?chain=forward" role="tab">Forward</a>
@@ -7,11 +8,11 @@
<a class="nav-link {% if current_chain == "postrouting" %}active{% endif %}" href="/firewall/rule_list/?chain=postrouting" role="tab">Post Routing</a>
</li>
<li class="nav-item">
<a class="nav-link {% if current_chain == "portforward" %}active{% endif %}" href="/firewall/port_forward/" role="tab">Port Forward</a>
<a class="nav-link {% if current_chain == "portforward" %}active{% endif %}" href="/firewall/port_forward/" role="tab">{% trans 'Port Forward' %}</a>
</li>
{% if current_chain == 'forward' %}
<li class="nav-item ml-auto">
<a class="nav-link" role="">Default Policy: <b>{{ firewall_settings.get_default_forward_policy_display }}</b></a>
<a class="nav-link" role="">{% trans 'Default Policy' %}: <b>{{ firewall_settings.get_default_forward_policy_display }}</b></a>
</li>
{% endif %}

View File

@@ -1,11 +1,12 @@
{% extends 'base.html' %}
{% load i18n %}
{% block content %}
<div class="container mt-3">
<div class="card card-primary card-outline">
<div class="card-header">
<h3 class="card-title">{{ form.instance.pk|yesno:"Edit User,Create New User" }}</h3>
<h3 class="card-title">{{ page_title }}</h3>
</div>
<div class="card-body">
<div class="row">
@@ -14,11 +15,11 @@
<form method="post">
{% csrf_token %}
<div class="form-group">
<label for="id_description">Description</label>
<input type="text" class="form-control" id="id_description" name="description" placeholder="Description" value="{{ form.description.value|default_if_none:'' }}">
<label for="id_description">{% trans 'Description' %}</label>
<input type="text" class="form-control" id="id_description" name="description" placeholder="{% trans 'Description' %}" value="{{ form.description.value|default_if_none:'' }}">
</div>
<div class="form-group">
<label for="id_protocol">Protocol</label>
<label for="id_protocol">{% trans 'Protocol' %} *</label>
<select class="form-control" id="id_protocol" name="protocol">
<option value="tcp" {% if form.protocol.value == "tcp" %}selected{% endif %}>TCP</option>
<option value="udp" {% if form.protocol.value == "udp" %}selected{% endif %}>UDP</option>
@@ -26,25 +27,25 @@
</div>
<div class="form-group">
<label for="id_port">Port</label>
<label for="id_port">{% trans 'Port' %} *</label>
<input type="number" class="form-control" id="id_port" name="port" value="{{ form.port.value|default_if_none:'' }}">
</div>
<div class="form-group">
<label for="id_port_forward">Destination Port</label>
<label for="id_port_forward">{% trans 'Destination Port' %}</label>
<input type="number" class="form-control" id="id_port_forward" name="port_forward" value="{{ form.port_forward.value|default_if_none:'' }}">
</div>
<div class="form-group">
<label for="destinationType">Destination Type</label>
<label for="destinationType">{% trans 'Destination Type' %} *</label>
<select class="form-control" name="destinationType" id="destinationType">
<option value="peer">Peer</option>
<option value="ipAddress" {% if instance.ip_address %}selected{% endif %}>IP Address</option>
<option value="peer">{% trans 'Peer' %}</option>
<option value="ipAddress" {% if instance.ip_address %}selected{% endif %}>{% trans 'IP Address' %}</option>
</select>
</div>
<div class="form-group">
<label for="id_peer">Peer</label>
<label for="id_peer">{% trans 'Peer' %} *</label>
<select class="form-control" id="id_peer" name="peer">
<option value="">---------</option>
{% for peer in form.fields.peer.queryset %}
@@ -53,7 +54,7 @@
</select>
</div>
<div class="form-group">
<label for="id_wireguard_instance">WireGuard Instance</label>
<label for="id_wireguard_instance">{% trans 'WireGuard Instance' %} *</label>
<select class="form-control" id="id_wireguard_instance" name="wireguard_instance">
{% comment %}<option value="">---------</option>{% endcomment %}
{% for instance in form.fields.wireguard_instance.queryset %}
@@ -62,45 +63,42 @@
</select>
</div>
<div class="form-group">
<label for="id_ip_address">IP Address</label>
<input type="text" class="form-control" id="id_ip_address" name="ip_address" placeholder="IP Address" value="{{ form.ip_address.value|default_if_none:'' }}">
<label for="id_ip_address">{% trans 'IP Address' %} *</label>
<input type="text" class="form-control" id="id_ip_address" name="ip_address" placeholder="{% trans 'IP Address' %}" value="{{ form.ip_address.value|default_if_none:'' }}">
</div>
<div class="form-group">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="id_add_forward_rule" name="add_forward_rule" {% if form.add_forward_rule.value %}checked{% endif %}>
<label class="form-check-label" for="id_add_forward_rule">Add Forward Rule (allow)</label>
<label class="form-check-label" for="id_add_forward_rule">{% trans 'Add Forward Rule (allow)' %}</label>
</div>
</div>
<div class="form-group">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="id_masquerade_source" name="masquerade_source" {% if form.masquerade_source.value %}checked{% endif %}>
<label class="form-check-label" for="id_masquerade_source">Masquerade Source</label>
<label class="form-check-label" for="id_masquerade_source">{% trans 'Masquerade Source' %}</label>
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
<a href="/firewall/port_forward/" class="btn btn-outline-secondary">Back</a>
{% if instance %}<a href='javascript:void(0)' class='btn btn-outline-danger' data-command='delete' onclick='openCommandDialog(this)'>Delete Rule</a>{% endif %}
<button type="submit" class="btn btn-primary">{% trans 'Save' %}</button>
<a href="/firewall/port_forward/" class="btn btn-outline-secondary">{% trans 'Back' %}</a>
{% if instance %}<a href='javascript:void(0)' class='btn btn-outline-danger' data-command='delete' onclick='openCommandDialog(this)'>{% trans 'Delete' %}</a>{% endif %}
</form>
</div>
<div class="col-md-8">
{% blocktrans %}
<h5>Default Ports</h5>
<p>The default <code>docker-compose.yml</code> file specifies the <b>TCP</b> port range <b>8080-8089</b>. If you wish to change the port forwarding to a different range, you must manually edit the <code>docker-compose.yml</code> file and rerun the Docker Compose step outlined in the <a href="https://github.com/eduardogsilva/wireguard_webadmin?tab=readme-ov-file#deployment">deployment instructions</a>.</p>
<h5>Destination Type: Peer</h5>
<p>Port redirection will prioritize the first Peer IP address assigned a priority of Zero.</p>
<h5>Destination Type: IP Address</h5>
<p>Port forwarding rules will redirect to the specified IP address. Remember to allocate the IP address or network to a Peer.</p>
<h5>Adding a Forward Rule</h5>
<p>Automatically generates a forwarding rule to accommodate stricter firewall settings.</p>
<h5>Masquerade Source</h5>
<p>This serves as a temporary solution when a peer does not use the VPN as its default gateway. It's important to note that this configuration is not recommended, as it alters the source address of all connections to match the IP address of the WireGuard instance.</p>
{% endblocktrans %}
</div>
</div>
</div>
@@ -141,7 +139,7 @@
<script>
function openCommandDialog(element) {
var command = element.getAttribute('data-command');
var confirmation = prompt("Please type '{{ instance.protocol }}{{ instance.port }}' to remove this rule.");
var confirmation = prompt("{% trans 'To delete this rule, please type:' %} '{{ instance.protocol }}{{ instance.port }}'");
if (confirmation) {
var url = "?uuid={{ instance.uuid }}&action=delete&confirmation=" + encodeURIComponent(confirmation);
window.location.href = url;

View File

@@ -1,5 +1,5 @@
{% extends 'base.html' %}
{% load i18n %}
{% block content %}
<div class="card card-primary card-outline">
<div class="card-body">
@@ -9,12 +9,12 @@
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Instance</th>
<th>Protocol</th>
<th>Port</th>
<th>Destination</th>
<th>Allow Forward</th>
<th>Masquerade Source</th>
<th>{% trans 'Instance' %}</th>
<th>{% trans 'Protocol' %}</th>
<th>{% trans 'Port' %}</th>
<th>{% trans 'Destination' %}</th>
<th>{% trans 'Allow Forward' %}</th>
<th>{% trans 'Masquerade Source' %}</th>
<th><i class="far fa-edit"></i></th>
</tr>
</thead>
@@ -43,7 +43,7 @@
<td>
{% if redirect_rule.masquerade_source %}
<i class="fas fa-check"></i>
<i class="fas fa-exclamation-triangle" title="This serves as a temporary solution when a peer does not use the VPN as its default gateway. It's important to note that this configuration is not recommended, as it alters the source address of all connections to match the IP address of the WireGuard instance."></i>
<i class="fas fa-exclamation-triangle" title="{% trans "This serves as a temporary solution when a peer does not use the VPN as its default gateway. It's important to note that this configuration is not recommended, as it alters the source address of all connections to match the IP address of the WireGuard instance." %}"></i>
{% else %}
<i class="fas fa-times"></i>
{% endif %}
@@ -55,8 +55,8 @@
{% endfor %}
</tbody>
</table>
<a href="/firewall/manage_port_forward_rule/" class='btn btn-primary'>Create Port forwarding Rule</a>
<a href="/firewall/firewall_settings/?chain=porforward" class='btn btn-outline-primary'>Firewall Settings</a>
<a href="/firewall/manage_port_forward_rule/" class='btn btn-primary'>{% trans 'Create Port forwarding Rule' %}</a>
<a href="/firewall/firewall_settings/?chain=porforward" class='btn btn-outline-primary'>{% trans 'Firewall Settings' %}</a>
</div>
</div>
</div>