Peer management translation

This commit is contained in:
Eduardo Silva 2025-04-15 14:22:40 -03:00
parent 52e0f19708
commit 036dcc75da
7 changed files with 334 additions and 105 deletions

Binary file not shown.

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-04-15 13:18-0300\n"
"POT-Creation-Date: 2025-04-15 14:21-0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -58,15 +58,17 @@ msgstr "Destino inválido"
msgid "Enhanced filter is enabled. This command is not available."
msgstr "Filtro aprimorado está habilitado. Este comando não está disponível."
#: dns/forms.py:22 wireguard/forms.py:19
#: dns/forms.py:22 wireguard/forms.py:22
msgid "Primary DNS"
msgstr "DNS Primário"
#: dns/forms.py:23 wireguard/forms.py:20
#: dns/forms.py:23 wireguard/forms.py:23
msgid "Secondary DNS"
msgstr "DNS Secundário"
#: dns/forms.py:25 dns/forms.py:67 dns/forms.py:109
#: templates/wireguard/wireguard_manage_ip.html:42
#: templates/wireguard/wireguard_manage_peer.html:170
#: templates/wireguard/wireguard_peer_list.html:166 user_manager/forms.py:49
#: user_manager/forms.py:180
msgid "Back"
@ -77,6 +79,8 @@ msgid "Resolver Settings"
msgstr "Resolução de DNS"
#: dns/forms.py:37 dns/forms.py:83 dns/forms.py:134
#: templates/wireguard/wireguard_manage_ip.html:41
#: templates/wireguard/wireguard_manage_peer.html:168
#: templates/wireguard/wireguard_manage_server.html:130
#: user_manager/forms.py:98 user_manager/forms.py:205
msgid "Save"
@ -92,6 +96,7 @@ msgid "IP Address"
msgstr "Endereço IP"
#: dns/forms.py:68 dns/forms.py:110
#: templates/wireguard/wireguard_manage_ip.html:43
#: templates/wireguard/wireguard_peer_list.html:185 user_manager/forms.py:48
#: user_manager/forms.py:181
msgid "Delete"
@ -103,6 +108,7 @@ msgstr "DNS Estático"
#: dns/forms.py:111 templates/dns/static_host_list.html:68
#: templates/user_manager/peer_group_list.html:8 user_manager/forms.py:177
#: wireguard_peer/forms.py:10
msgid "Name"
msgstr "Nome"
@ -400,6 +406,132 @@ msgstr "Instância do WireGuard"
msgid "Users"
msgstr "Usuários"
#: templates/wireguard/wireguard_manage_ip.html:18
msgid "Enter Allowed IP"
msgstr "Inserir IP Permitido"
#: templates/wireguard/wireguard_manage_ip.html:34
#: templates/wireguard/wireguard_manage_peer.html:103
#: templates/wireguard/wireguard_manage_peer.html:153
#: wireguard_peer/forms.py:31
msgid "Priority"
msgstr "Prioridade"
#: templates/wireguard/wireguard_manage_ip.html:58
msgid "Please type \\\"delete\\\" to remove this IP address."
msgstr "Por favor, digite \\\"delete\\\" para remover este endereço IP."
#: templates/wireguard/wireguard_manage_peer.html:8
msgid "Peer Configuration"
msgstr "Configuração do Peer"
#: templates/wireguard/wireguard_manage_peer.html:17
msgid "Enter Name"
msgstr "Digite um Nome"
#: templates/wireguard/wireguard_manage_peer.html:23 wireguard_peer/forms.py:14
msgid "Persistent Keepalive"
msgstr "Conexão Persistente"
#: templates/wireguard/wireguard_manage_peer.html:29 wireguard/forms.py:14
#: wireguard_peer/forms.py:11
msgid "Public Key"
msgstr "Chave Pública"
#: templates/wireguard/wireguard_manage_peer.html:36 wireguard/forms.py:13
#: wireguard_peer/forms.py:12
msgid "Private Key"
msgstr "Chave Privada"
#: templates/wireguard/wireguard_manage_peer.html:46 wireguard_peer/forms.py:13
msgid "Pre-Shared Key"
msgstr "Chave Pré-Compartilhada"
#: templates/wireguard/wireguard_manage_peer.html:57
#: templates/wireguard/wireguard_peer_list.html:136
msgid "Peer Traffic"
msgstr "Tráfego do Peer"
#: templates/wireguard/wireguard_manage_peer.html:73
#: templates/wireguard/wireguard_peer_list.html:151
msgid "No traffic history, please wait a few minutes"
msgstr "Sem histórico de tráfego, por favor aguarde alguns minutos"
#: templates/wireguard/wireguard_manage_peer.html:85
msgid "AllowedIPs at Peer section of wg"
msgstr "AllowedIPs na seção Peer do wg"
#: templates/wireguard/wireguard_manage_peer.html:86
msgid "Peer IP Addresses and networks"
msgstr "Endereços IP e redes do Peer"
#: templates/wireguard/wireguard_manage_peer.html:88
#: templates/wireguard/wireguard_manage_peer.html:169
msgid "Add IP Address"
msgstr "Adicionar IP"
#: templates/wireguard/wireguard_manage_peer.html:101
#: templates/wireguard/wireguard_manage_peer.html:151
msgid "Main ip address"
msgstr "Endereço IP principal"
#: templates/wireguard/wireguard_manage_peer.html:116
msgid "Client Routing Configuration"
msgstr "Configuração de rotas do Cliente"
#: templates/wireguard/wireguard_manage_peer.html:118
msgid "Add Client route"
msgstr "Adicionar rota"
#: templates/wireguard/wireguard_manage_peer.html:124
msgid ""
"The client is not configured to use the VPN as the default gateway."
"\\n\\nOnly the specific networks listed below are routed through the VPN."
"\\n\\nNote: These routes are not automatically pushed to the client. You "
"will need to manually update the client configuration file to reflect these "
"settings."
msgstr ""
"O cliente não está configurado para usar a VPN como gateway padrão."
"\\n\\nSomente as redes específicas listadas abaixo são roteadas através da "
"VPN.\\n\\nObservação: Essas rotas não são enviadas automaticamente para o "
"cliente. Você precisará atualizar manualmente o arquivo de configuração do "
"cliente para refletir essas configurações."
#: templates/wireguard/wireguard_manage_peer.html:127
msgid ""
"The client is configured to use the VPN as the default gateway. \\n\\nThis "
"setting routes all client internet traffic through the VPN, enhancing "
"privacy and security across all connections."
msgstr ""
"O cliente está configurado para usar a VPN como gateway padrão. \\n\\nEsta "
"configuração direciona todo o tráfego de internet do cliente através da VPN, "
"aprimorando a privacidade e a segurança em todas as conexões."
#: templates/wireguard/wireguard_manage_peer.html:136
msgid "default route"
msgstr "rota padrão"
#: templates/wireguard/wireguard_manage_peer.html:171
msgid "Delete Peer"
msgstr "Excluir Peer"
#: templates/wireguard/wireguard_manage_peer.html:188
msgid "Action Required!"
msgstr "Ação Necessária!"
#: templates/wireguard/wireguard_manage_peer.html:189
msgid ""
"When manually updating the \"Public Key\", \"Pre-Shared Key\", or \"Private "
"Key\", please ensure the configuration is correct."
msgstr ""
"Ao atualizar manualmente a \"Chave Pública\", \"Chave Pré-compartilhada\" ou "
"\"Chave Privada\", por favor, certifique-se de que a configuração esteja "
"correta."
#: templates/wireguard/wireguard_manage_peer.html:209
msgid "Please type \\\"delete\\\" to remove peer configuration."
msgstr "Por favor, digite \\\"delete\\\" para remover a configuração do peer."
#: templates/wireguard/wireguard_manage_server.html:18
msgid "Create Instance"
msgstr "Criar Instância"
@ -447,14 +579,6 @@ msgstr "Criar Peer"
msgid "Show extras"
msgstr "Exibir extras"
#: templates/wireguard/wireguard_peer_list.html:136
msgid "Peer Traffic"
msgstr "Tráfego do Peer"
#: templates/wireguard/wireguard_peer_list.html:151
msgid "No traffic history, please wait a few minutes"
msgstr "Sem histórico de tráfego, por favor aguarde alguns minutos"
#: templates/wireguard/wireguard_peer_list.html:158
msgid "Close QR Code"
msgstr "Fechar QR Code"
@ -463,6 +587,10 @@ msgstr "Fechar QR Code"
msgid "VPN Invite Details"
msgstr "Detalhes do Convite para VPN"
#: templates/wireguard/wireguard_peer_list.html:174
msgid "Expires on"
msgstr "Expira em"
#: templates/wireguard/wireguard_peer_list.html:178
msgid "Enter Email or WhatsApp Number"
msgstr "Digite o Email ou Número do WhatsApp"
@ -611,7 +739,7 @@ msgstr "Recarregar o serviço Wireguard"
msgid "Instance Traffic"
msgstr "Tráfego da Instância"
#: templates/wireguard/wireguard_status.html:46 wireguard/forms.py:12
#: templates/wireguard/wireguard_status.html:46 wireguard/forms.py:15
msgid "Public Address"
msgstr "Endereço Público"
@ -827,55 +955,48 @@ msgstr ""
msgid "Please type the username to proceed."
msgstr "Por favor, digite o nome de usuário para prosseguir."
#: wireguard/forms.py:8
#: wireguard/forms.py:11
msgid "Display Name"
msgstr "Nome de Exibição"
#: wireguard/forms.py:9
#: wireguard/forms.py:12
msgid "Instance ID"
msgstr "Instância"
#: wireguard/forms.py:10
msgid "Private Key"
msgstr "Chave Privada"
#: wireguard/forms.py:11
msgid "Public Key"
msgstr "Chave Pública"
#: wireguard/forms.py:13
#: wireguard/forms.py:16
msgid "Listen Port"
msgstr "Porta"
#: wireguard/forms.py:14
#: wireguard/forms.py:17
msgid "Internal IP Address"
msgstr "Endereço IP Interno"
#: wireguard/forms.py:15
#: wireguard/forms.py:18 wireguard_peer/forms.py:30
msgid "Netmask"
msgstr "Máscara de Rede"
#: wireguard/forms.py:16
#: wireguard/forms.py:19
msgid "Post Up"
msgstr "Post Up"
#: wireguard/forms.py:17
#: wireguard/forms.py:20
msgid "Post Down"
msgstr "Post Down"
#: wireguard/forms.py:18
#: wireguard/forms.py:21
msgid "Web Refresh Interval"
msgstr "Intervalo de Atualização Web"
#: wireguard/forms.py:39
msgid "Peer List Refresh Interval must be at least 5 seconds"
msgstr "Intervalo de Atualização da Lista de Peers deve ser de pelo menos 5 segundos"
#: wireguard/forms.py:42
msgid "Peer List Refresh Interval must be at least 5 seconds"
msgstr ""
"Intervalo de Atualização da Lista de Peers deve ser de pelo menos 5 segundos"
#: wireguard/forms.py:45
msgid "Invalid hostname or IP Address"
msgstr "Endereço ou IP inválido"
#: wireguard/forms.py:51
#: wireguard/forms.py:54
msgid "The selected network range overlaps with another instance."
msgstr "A faixa de rede selecionada se sobrepõe a outra instância."
@ -921,10 +1042,118 @@ msgstr "Adicionar uma nova Instância do WireGuard"
msgid "New WireGuard Instance"
msgstr "Nova Instância do WireGuard"
#: wireguard_peer/forms.py:29
msgid "Allowed IP or Network"
msgstr "Endereço IP ou Rede Permitida"
#: wireguard_peer/forms.py:39
msgid "Please provide a valid IP address."
msgstr "Por favor, forneça um endereço IP válido."
#: wireguard_peer/forms.py:48
msgid "A peer can have only one IP with priority zero."
msgstr "Um peer pode ter apenas um IP com prioridade zero."
#: wireguard_peer/forms.py:54
msgid "This IP is already in use by another peer."
msgstr "Este IP já está em uso por outro peer."
#: wireguard_peer/forms.py:56
msgid ""
"The IP address does not belong to the Peer's WireGuard instance network "
"range. Please check the IP address or change the priority."
msgstr ""
"O endereço IP não pertence à faixa de rede da instância WireGuard do Peer. "
"Por favor, verifique o endereço IP ou altere a prioridade."
#: wireguard_peer/forms.py:58
msgid "The netmask for priority 0 IP must be 32."
msgstr "A máscara de rede para IP de prioridade 0 deve ser 32."
#: wireguard_peer/forms.py:60
msgid "The IP address is the same as the Peer's WireGuard instance address."
msgstr "O endereço IP é o mesmo que o endereço da instância WireGuard do Peer."
#: wireguard_peer/forms.py:63
msgid ""
"The IP address belongs to the Peer's WireGuard instance network range. "
"Please check the IP address or change use priority 0 instead."
msgstr ""
"O endereço IP pertence à faixa de rede da instância WireGuard do Peer. Por "
"favor, verifique o endereço IP ou use a prioridade 0 em vez disso."
#: wireguard_peer/forms.py:66
msgid "Priority must be greater than or equal to 1"
msgstr "Prioridade deve ser maior ou igual a 1"
#: wireguard_peer/forms.py:68
msgid "Invalid config file"
msgstr "Arquivo de configuração inválido"
#: wireguard_peer/views.py:50
msgid "WireGuard Peer List"
msgstr "Lista de Peers do WireGuard"
#: wireguard_peer/views.py:129
msgid "Create a new Peer for instance wg"
msgstr "Criar um novo Peer para a instância wg"
#: wireguard_peer/views.py:148
msgid "Peer created|Peer created successfully."
msgstr "Peer adicionado|Peer adicionado com sucesso."
#: wireguard_peer/views.py:153
msgid "Error creating peer|No available IP address found for peer creation."
msgstr ""
"Erro ao criar peer|Nenhum endereço IP disponível encontrado para alocação. "
#: wireguard_peer/views.py:166
msgid "Peer deleted|Peer deleted successfully."
msgstr "Peer excluído|Peer excluído com sucesso."
#: wireguard_peer/views.py:169
msgid ""
"Error deleting peer|Invalid confirmation message. Type \"delete\" to confirm."
msgstr ""
"Erro ao excluir peer|Mensagem de confirmação inválida. Digite \"delete\" "
"para confirmar."
#: wireguard_peer/views.py:171
msgid "Update Peer: "
msgstr "Atualizar Peer: "
#: wireguard_peer/views.py:182
msgid "Peer updated|Peer updated successfully."
msgstr "Peer atualizado|Peer atualizado com sucesso."
#: wireguard_peer/views.py:220
msgid "IP address deleted|IP address deleted successfully."
msgstr "Endereço IP excluído|Endereço IP excluído com sucesso."
#: wireguard_peer/views.py:225
msgid ""
"Error deleting IP address|Invalid confirmation message. Type \"delete\" to "
"confirm."
msgstr ""
"Erro ao excluir endereço IP|Mensagem de confirmação inválida. Digite "
"\"delete\" para confirmar."
#: wireguard_peer/views.py:230
msgid "Manage client route"
msgstr "Gerenciar rota do cliente"
#: wireguard_peer/views.py:232
msgid "Manage IP address or Network"
msgstr "Gerenciar Endereço IP ou Rede"
#: wireguard_peer/views.py:245
msgid "IP address updated|IP address updated successfully."
msgstr "Endereço IP atualizado|Endereço IP atualizado com sucesso."
#: wireguard_peer/views.py:247
msgid "IP address added|IP address added successfully."
msgstr "Endereço IP adicionado|Endereço IP adicionado com sucesso."
#: wireguard_tools/views.py:160
msgid ""
"Export successful!|WireGuard configuration files have been exported to /etc/"

View file

@ -1,5 +1,5 @@
{% extends "base.html" %}
{% load i18n %}
{% block content %}
<div class='row'>
@ -15,7 +15,7 @@
<!-- Allowed IP -->
<div class="form-group">
<label for="{{ form.allowed_ip.id_for_label }}">{{ form.allowed_ip.label }}</label>
<input type="text" class="form-control" id="{{ form.allowed_ip.id_for_label }}" name="{{ form.allowed_ip.html_name }}" placeholder="Enter Allowed IP" value="{{ form.allowed_ip.value|default_if_none:'' }}" required>
<input type="text" class="form-control" id="{{ form.allowed_ip.id_for_label }}" name="{{ form.allowed_ip.html_name }}" placeholder="{% trans 'Enter Allowed IP' %}" value="{{ form.allowed_ip.value|default_if_none:'' }}" required>
</div>
<!-- Netmask -->
@ -31,16 +31,16 @@
<!-- Priority -->
<div class="form-group">
<label for="{{ form.priority.id_for_label }}">{{ form.priority.label }}</label>
<input type="number" class="form-control" id="{{ form.priority.id_for_label }}" name="{{ form.priority.html_name }}" placeholder="Priority" value="{{ form.priority.value|default_if_none:'' }}" required>
<input type="number" class="form-control" id="{{ form.priority.id_for_label }}" name="{{ form.priority.html_name }}" placeholder="{% trans 'Priority' %}" value="{{ form.priority.value|default_if_none:'' }}" required>
</div>
</div>
</div>
<div class="card-footer">
<button type="submit" class="btn btn-primary">Submit</button>
<a class="btn btn-outline-secondary" href="/peer/manage/?peer={{ current_peer.uuid }}">Back</a>
{% if current_ip %}<a href='javascript:void(0)' class='btn btn-outline-danger' data-command='delete' onclick='openCommandDialog(this)'>Delete IP</a>{% endif %}
<button type="submit" class="btn btn-primary">{% trans 'Save' %}</button>
<a class="btn btn-outline-secondary" href="/peer/manage/?peer={{ current_peer.uuid }}">{% trans 'Back' %}</a>
{% if current_ip %}<a href='javascript:void(0)' class='btn btn-outline-danger' data-command='delete' onclick='openCommandDialog(this)'>{% trans 'Delete' %}</a>{% endif %}
</div>
</form>
</div>
@ -55,7 +55,7 @@
<script>
function openCommandDialog(element) {
var command = element.getAttribute('data-command');
var confirmation = prompt("Please type 'delete' to remove this IP address.");
var confirmation = prompt("{% trans 'Please type \"delete\" to remove this IP address.' %}");
if (confirmation) {
var url = "?ip={{ current_ip.uuid }}&action=delete&confirmation=" + encodeURIComponent(confirmation);
window.location.href = url;

View file

@ -1,10 +1,11 @@
{% extends "base.html" %}
{% load i18n %}
{% block content %}
<div class="card card-primary card-outline">
<div class="card-header">
<h3 class="card-title">Configure Peer</h3>
<h3 class="card-title">{% trans 'Peer Configuration' %}</h3>
</div>
<form method="post">
{% csrf_token %}
@ -13,26 +14,26 @@
<!-- Name -->
<div class="form-group">
<label for="{{ form.name.id_for_label }}">{{ form.name.label }}</label>
<input type="text" class="form-control" id="{{ form.name.id_for_label }}" name="{{ form.name.html_name }}" placeholder="Enter Name" value="{{ form.name.value|default_if_none:'' }}">
<input type="text" class="form-control" id="{{ form.name.id_for_label }}" name="{{ form.name.html_name }}" placeholder="{% trans 'Enter Name' %}" value="{{ form.name.value|default_if_none:'' }}">
</div>
<!-- Persistent Keepalive -->
<div class="form-group">
<label for="{{ form.persistent_keepalive.id_for_label }}">{{ form.persistent_keepalive.label }}</label>
<input type="number" class="form-control" id="{{ form.persistent_keepalive.id_for_label }}" name="{{ form.persistent_keepalive.html_name }}" placeholder="Persistent Keepalive" value="{{ form.persistent_keepalive.value|default_if_none:'' }}" required>
<input type="number" class="form-control" id="{{ form.persistent_keepalive.id_for_label }}" name="{{ form.persistent_keepalive.html_name }}" placeholder="{% trans 'Persistent Keepalive' %}" value="{{ form.persistent_keepalive.value|default_if_none:'' }}" required>
</div>
<!-- Public Key -->
<div class="form-group">
<label for="{{ form.public_key.id_for_label }}">{{ form.public_key.label }}</label>
<input type="text" class="form-control" id="{{ form.public_key.id_for_label }}" name="{{ form.public_key.html_name }}" placeholder="Public Key" value="{{ form.public_key.value|default_if_none:'' }}" required>
<input type="text" class="form-control" id="{{ form.public_key.id_for_label }}" name="{{ form.public_key.html_name }}" placeholder="{% trans 'Public Key' %}" value="{{ form.public_key.value|default_if_none:'' }}" required>
</div>
<!-- Private Key -->
<div class="form-group">
<label for="{{ form.private_key.id_for_label }}">{{ form.private_key.label }}</label>
<div class="input-group">
<input type="password" class="form-control" id="{{ form.private_key.id_for_label }}" name="{{ form.private_key.html_name }}" placeholder="Private Key" value="{{ form.private_key.value|default_if_none:'' }}" required>
<input type="password" class="form-control" id="{{ form.private_key.id_for_label }}" name="{{ form.private_key.html_name }}" placeholder="{% trans 'Private Key' %}" value="{{ form.private_key.value|default_if_none:'' }}" required>
<div class="input-group-append">
<button class="btn btn-outline-secondary toggle-password" type="button"><i class="fas fa-eye"></i></button>
</div>
@ -42,7 +43,7 @@
<!-- Pre-Shared Key -->
<div class="form-group">
<label for="{{ form.pre_shared_key.id_for_label }}">{{ form.pre_shared_key.label }}</label>
<input type="text" class="form-control" id="{{ form.pre_shared_key.id_for_label }}" name="{{ form.pre_shared_key.html_name }}" placeholder="Pre-Shared Key" value="{{ form.pre_shared_key.value|default_if_none:'' }}" required>
<input type="text" class="form-control" id="{{ form.pre_shared_key.id_for_label }}" name="{{ form.pre_shared_key.html_name }}" placeholder="{% trans 'Pre-Shared Key' %}" value="{{ form.pre_shared_key.value|default_if_none:'' }}" required>
</div>
</div>
@ -53,7 +54,7 @@
<div class="d-flex justify-content-between align-items-center ">
<label>
<i class="fas fa-chart-area"></i>
Peer Traffic
{% trans 'Peer Traffic' %}
</label>
<div class="btn-group" role="group" aria-label="Graph interval">
<a href="#" data-period="1h" class="btn btn-outline-primary btn-xs">1h</a>
@ -69,7 +70,7 @@
</div>
<center>
<img id="graphImg" src="/rrd/graph/?peer={{ current_peer.uuid }}{% if request.GET.period %}&period={{ request.GET.period }}{% endif %}" class="img-fluid" alt="No traffic history, please wait a few minutes" onerror="this.onerror=null; this.style.display='none'; this.insertAdjacentHTML('afterend', this.alt);">
<img id="graphImg" src="/rrd/graph/?peer={{ current_peer.uuid }}{% if request.GET.period %}&period={{ request.GET.period }}{% endif %}" class="img-fluid" alt="{% trans 'No traffic history, please wait a few minutes' %}" onerror="this.onerror=null; this.style.display='none'; this.insertAdjacentHTML('afterend', this.alt);">
</center>
<div class="d-flex justify-content-between align-items-center border-bottom mb-3" style="padding-top: 16px;"></div>
@ -81,10 +82,10 @@
<div class="col-md-12">
<div class="d-flex justify-content-between align-items-center">
<label>
<i class="fas fa-info-circle" title="AllowedIPs at Peer section of wg{{ current_peer.wireguard_instance.instance_id }}.conf"></i>
Peer IP Addresses and networks
<i class="fas fa-info-circle" title="{% trans 'AllowedIPs at Peer section of wg' %}{{ current_peer.wireguard_instance.instance_id }}.conf"></i>
{% trans 'Peer IP Addresses and networks' %}
</label>
<a class="btn btn-outline-primary btn-xs" href="/peer/manage_ip_address/?peer={{ current_peer.uuid }}&config=server" >Add IP Address</a>
<a class="btn btn-outline-primary btn-xs" href="/peer/manage_ip_address/?peer={{ current_peer.uuid }}&config=server" >{% trans 'Add IP Address' %}</a>
</div>
{% for ip_address in peer_ip_list %}
@ -94,15 +95,12 @@
<i class="fas fa-network-wired"></i>
{{ ip_address}}
</a>
</p>
<p class="d-flex flex-column text-right small">
{% if ip_address.priority == 0 %}
Main ip address
{% trans 'Main ip address' %}
{% else %}
Priority: {{ ip_address.priority }}
{% trans 'Priority' %}: {{ ip_address.priority }}
{% endif %}
</p>
</div>
@ -115,18 +113,18 @@
<div class="d-flex justify-content-between align-items-center">
<label>
<i class="fas fa-info-circle" title="AllowedIPs at client configuration file"></i>
Client Routing Configuration
{% trans 'Client Routing Configuration' %}
</label>
<a class="btn btn-outline-primary btn-xs" href="/peer/manage_ip_address/?peer={{ current_peer.uuid }}&config=client" >Add Client route</a>
<a class="btn btn-outline-primary btn-xs" href="/peer/manage_ip_address/?peer={{ current_peer.uuid }}&config=client" >{% trans 'Add Client route' %}</a>
</div>
<div class="d-flex justify-content-between align-items-center border-bottom mb-3">
<p>
<a href="#"
{% if peer_client_ip_list %}
onclick="alert('The client is not configured to use the VPN as the default gateway.\n\nOnly the specific networks listed below are routed through the VPN.\n\nNote: These routes are not automatically pushed to the client. You will need to manually update the client configuration file to reflect these settings.');"
onclick="alert('{% trans 'The client is not configured to use the VPN as the default gateway.\n\nOnly the specific networks listed below are routed through the VPN.\n\nNote: These routes are not automatically pushed to the client. You will need to manually update the client configuration file to reflect these settings.' %}');"
style="text-decoration: line-through;"
{% else %}
onclick="alert('The client is configured to use the VPN as the default gateway. \n\nThis setting routes all client internet traffic through the VPN, enhancing privacy and security across all connections.');"
onclick="alert('{% trans 'The client is configured to use the VPN as the default gateway. \n\nThis setting routes all client internet traffic through the VPN, enhancing privacy and security across all connections.' %}');"
{% endif %}
>
@ -135,7 +133,7 @@
</a>
</p>
<p class="d-flex flex-column text-right small">
default route
{% trans 'default route' %}
</p>
</div>
@ -150,9 +148,9 @@
</p>
<p class="d-flex flex-column text-right small">
{% if ip_address.priority == 0 %}
Main ip address
{% trans 'Main ip address' %}
{% else %}
Priority: {{ ip_address.priority }}
{% trans 'Priority' %}: {{ ip_address.priority }}
{% endif %}
</p>
</div>
@ -167,10 +165,10 @@
</div>
</div>
<div class="card-footer">
<button type="submit" class="btn btn-primary">Submit</button>
<a href="/peer/manage_ip_address/?peer={{ current_peer.uuid }}" class="btn btn-outline-primary">Add IP Address</a>
<a class="btn btn-outline-secondary" href="/peer/list/?uuid={{ current_peer.wireguard_instance.uuid }}#peer-{{ current_peer.public_key }}">Back</a>
<a href='javascript:void(0)' class='btn btn-outline-danger' data-command='delete' onclick='openCommandDialog(this)'>Delete Peer</a>
<button type="submit" class="btn btn-primary">{% trans 'Save' %}</button>
<a href="/peer/manage_ip_address/?peer={{ current_peer.uuid }}" class="btn btn-outline-primary">{% trans 'Add IP Address' %}</a>
<a class="btn btn-outline-secondary" href="/peer/list/?uuid={{ current_peer.wireguard_instance.uuid }}#peer-{{ current_peer.public_key }}">{% trans 'Back' %}</a>
<a href='javascript:void(0)' class='btn btn-outline-danger' data-command='delete' onclick='openCommandDialog(this)'>{% trans 'Delete Peer' %}</a>
</div>
</form>
@ -187,9 +185,8 @@
if (!alertShown) {
$(document).Toasts('create', {
class: 'bg-warning',
title: 'Action Required!',
body: 'When manually updating the "Public Key", "Pre-Shared Key", or "Private Key", please ensure the configuration is correct.',
title: '{% trans 'Action Required!' %}',
body: '{% trans 'When manually updating the "Public Key", "Pre-Shared Key", or "Private Key", please ensure the configuration is correct.' %}',
});
alertShown = true;
}
@ -209,7 +206,7 @@
<script>
function openCommandDialog(element) {
var command = element.getAttribute('data-command');
var confirmation = prompt("Please type 'delete' to remove peer configuration.");
var confirmation = prompt("{% trans 'Please type \"delete\" to remove peer configuration.' %}");
if (confirmation) {
var url = "?peer={{ current_peer.uuid }}&action=delete&confirmation=" + encodeURIComponent(confirmation);
window.location.href = url;

View file

@ -170,7 +170,7 @@
</div>
<p id="invitePassword"></p>
<p>
Expires on: <span id="inviteExpiration"></span>
{% trans 'Expires on' %}: <span id="inviteExpiration"></span>
<i class="fas fa-sync-alt" id="refreshInviteButton" style="cursor: pointer;" title="Refresh Invite"></i>
</p>
<div class="form-group">

View file

@ -1,14 +1,17 @@
from django import forms
from wireguard.models import Peer, PeerAllowedIP, NETMASK_CHOICES
import ipaddress
from django import forms
from django.utils.translation import gettext_lazy as _
from wireguard.models import NETMASK_CHOICES, Peer, PeerAllowedIP
class PeerForm(forms.ModelForm):
name = forms.CharField(label='Name', required=False)
public_key = forms.CharField(label='Public Key', required=True)
private_key = forms.CharField(label='Private Key', required=False)
pre_shared_key = forms.CharField(label='Pre-Shared Key', required=True)
persistent_keepalive = forms.IntegerField(label='Persistent Keepalive', required=True)
name = forms.CharField(label=_('Name'), required=False)
public_key = forms.CharField(label=_('Public Key'), required=True)
private_key = forms.CharField(label=_('Private Key'), required=False)
pre_shared_key = forms.CharField(label=_('Pre-Shared Key'), required=True)
persistent_keepalive = forms.IntegerField(label=_('Persistent Keepalive'), required=True)
class Meta:
model = Peer
@ -23,9 +26,9 @@ class PeerAllowedIPForm(forms.ModelForm):
self.current_peer = current_peer
self.config_file = config_file
allowed_ip = forms.GenericIPAddressField(label='Allowed IP or Network', required=True)
netmask = forms.ChoiceField(choices=NETMASK_CHOICES, label='Netmask', initial=24, required=True)
priority = forms.IntegerField(label='Priority', required=True, initial=1)
allowed_ip = forms.GenericIPAddressField(label=_('Allowed IP or Network'), required=True)
netmask = forms.ChoiceField(choices=NETMASK_CHOICES, label=_('Netmask'), initial=24, required=True)
priority = forms.IntegerField(label=_('Priority'), required=True, initial=1)
def clean(self):
cleaned_data = super().clean()
@ -33,7 +36,7 @@ class PeerAllowedIPForm(forms.ModelForm):
allowed_ip = cleaned_data.get('allowed_ip')
netmask = cleaned_data.get('netmask')
if allowed_ip is None:
raise forms.ValidationError("Please provide a valid IP address.")
raise forms.ValidationError(_("Please provide a valid IP address."))
if self.config_file == 'server':
wireguard_network = ipaddress.ip_network(f"{self.current_peer.wireguard_instance.address}/{self.current_peer.wireguard_instance.netmask}", strict=False)
@ -42,27 +45,27 @@ class PeerAllowedIPForm(forms.ModelForm):
if self.instance:
zero_priority_ips_query = zero_priority_ips_query.exclude(uuid=self.instance.uuid)
if zero_priority_ips_query.exists():
raise forms.ValidationError("A peer can have only one IP with priority zero.")
raise forms.ValidationError(_("A peer can have only one IP with priority zero."))
duplicated_ip = PeerAllowedIP.objects.filter(config_file='server', allowed_ip=allowed_ip)
if self.instance:
duplicated_ip = duplicated_ip.exclude(uuid=self.instance.uuid)
if duplicated_ip.exists():
raise forms.ValidationError("This IP is already in use by another peer.")
raise forms.ValidationError(_("This IP is already in use by another peer."))
if ipaddress.ip_address(allowed_ip) not in wireguard_network:
raise forms.ValidationError("The IP address does not belong to the Peer's WireGuard instance network range. Please check the IP address or change the priority.")
raise forms.ValidationError(_("The IP address does not belong to the Peer's WireGuard instance network range. Please check the IP address or change the priority."))
if str(netmask) != str(32):
raise forms.ValidationError("The netmask for priority 0 IP must be 32.")
raise forms.ValidationError(_("The netmask for priority 0 IP must be 32."))
if self.current_peer.wireguard_instance.address == allowed_ip:
raise forms.ValidationError("The IP address is the same as the Peer's WireGuard instance address.")
raise forms.ValidationError(_("The IP address is the same as the Peer's WireGuard instance address."))
else:
if ipaddress.ip_address(allowed_ip) in wireguard_network:
raise forms.ValidationError("The IP address belongs to the Peer's WireGuard instance network range. Please check the IP address or change use priority 0 instead.")
raise forms.ValidationError(_("The IP address belongs to the Peer's WireGuard instance network range. Please check the IP address or change use priority 0 instead."))
elif self.config_file == 'client':
if priority < 1:
raise forms.ValidationError("Priority must be greater than or equal to 1")
raise forms.ValidationError(_("Priority must be greater than or equal to 1"))
else:
raise forms.ValidationError('Invalid config file')
raise forms.ValidationError(_('Invalid config file'))
class Meta:
model = PeerAllowedIP

View file

@ -126,7 +126,7 @@ def view_wireguard_peer_manage(request):
if not user_has_access_to_instance(user_acl, current_instance):
raise Http404
current_peer = None
page_title = 'Create a new Peer for instance wg' + str(current_instance.instance_id)
page_title = _('Create a new Peer for instance wg') + str(current_instance.instance_id)
new_peer_data = generate_peer_default(current_instance)
if new_peer_data['allowed_ip']:
@ -145,12 +145,12 @@ def view_wireguard_peer_manage(request):
priority=0,
netmask=32,
)
messages.success(request, 'Peer created|Peer for instance wg' + str(current_instance.instance_id) + ' created successfully with IP ' + new_peer_data['allowed_ip'] + '/32.')
messages.success(request, _('Peer created|Peer created successfully.'))
new_peer.wireguard_instance.pending_changes = True
new_peer.wireguard_instance.save()
return redirect('/peer/manage/?peer=' + str(new_peer.uuid))
else:
messages.warning(request, 'Error creating peer|No available IP address found for peer creation.')
messages.warning(request, _('Error creating peer|No available IP address found for peer creation.'))
return redirect('/peer/list/')
elif request.GET.get('peer'):
@ -163,12 +163,12 @@ def view_wireguard_peer_manage(request):
current_peer.wireguard_instance.pending_changes = True
current_peer.wireguard_instance.save()
current_peer.delete()
messages.success(request, 'Peer deleted|Peer deleted successfully.')
messages.success(request, _('Peer deleted|Peer deleted successfully.'))
return redirect('/peer/list/?uuid=' + str(current_instance.uuid))
else:
messages.warning(request, 'Error deleting peer|Invalid confirmation message. Type "delete" to confirm.')
messages.warning(request, _('Error deleting peer|Invalid confirmation message. Type "delete" to confirm.'))
return redirect('/peer/manage/?peer=' + str(current_peer.uuid))
page_title = 'Update Peer '
page_title = _('Update Peer: ')
peer_ip_list = current_peer.peerallowedip_set.filter(config_file='server').order_by('priority')
peer_client_ip_list = current_peer.peerallowedip_set.filter(config_file='client').order_by('priority')
if current_peer.name:
@ -179,7 +179,7 @@ def view_wireguard_peer_manage(request):
form = PeerForm(request.POST, instance=current_peer)
if form.is_valid():
form.save()
messages.success(request, 'Peer updated|Peer updated successfully.')
messages.success(request, _('Peer updated|Peer updated successfully.'))
current_peer.wireguard_instance.pending_changes = True
current_peer.wireguard_instance.save()
return redirect('/peer/list/?uuid=' + str(current_peer.wireguard_instance.uuid))
@ -217,19 +217,19 @@ def view_manage_ip_address(request):
if request.GET.get('action') == 'delete':
if request.GET.get('confirmation') == 'delete':
current_ip.delete()
messages.success(request, 'IP address deleted|IP address deleted successfully.')
messages.success(request, _('IP address deleted|IP address deleted successfully.'))
current_peer.wireguard_instance.pending_changes = True
current_peer.wireguard_instance.save()
return redirect('/peer/manage/?peer=' + str(current_peer.uuid))
else:
messages.warning(request, 'Error deleting IP address|Invalid confirmation message. Type "delete" to confirm.')
return redirect('/peer/ip/?ip=' + str(current_ip.uuid))
messages.warning(request, _('Error deleting IP address|Invalid confirmation message. Type "delete" to confirm.'))
return redirect('/peer/manage_ip_address/?ip=' + str(current_ip.uuid))
if config_file not in ['client', 'server']:
config_file = 'server'
if config_file == 'client':
page_title = 'Manage client route'
page_title = _('Manage client route')
else:
page_title = 'Manage IP address or Network'
page_title = _('Manage IP address or Network')
if request.method == 'POST':
form = PeerAllowedIPForm(request.POST or None, instance=current_ip, current_peer=current_peer, config_file=config_file)
@ -242,9 +242,9 @@ def view_manage_ip_address(request):
current_peer.wireguard_instance.pending_changes = True
current_peer.wireguard_instance.save()
if current_ip:
messages.success(request, 'IP address updated|IP address updated successfully.')
messages.success(request, _('IP address updated|IP address updated successfully.'))
else:
messages.success(request, 'IP address added|IP address added successfully.')
messages.success(request, _('IP address added|IP address added successfully.'))
return redirect('/peer/manage/?peer=' + str(current_peer.uuid))
else:
form = PeerAllowedIPForm(instance=current_ip, current_peer=current_peer)