add validation for custom routes in routing template and update UI to display routing template information

This commit is contained in:
Eduardo Silva
2026-01-22 16:31:38 -03:00
parent 4373e0a9d2
commit 687240f422
2 changed files with 15 additions and 0 deletions

View File

@@ -121,6 +121,18 @@
</div> </div>
</div> </div>
{% if current_peer.routing_template %}
<div class="d-flex justify-content-between align-items-center">
<p>
<a href="/peer/apply_route_template/?peer={{ current_peer.uuid }}">
<i class="fas fa-route"></i> {{ current_peer.routing_template.name }}
</a>
</p>
<p class="d-flex flex-column text-right small">
{% trans 'Routing Template' %}
</p>
</div>
{% else %}
<div class="d-flex justify-content-between align-items-center border-bottom mb-3"> <div class="d-flex justify-content-between align-items-center border-bottom mb-3">
<p> <p>
<a href="#" <a href="#"
@@ -140,6 +152,7 @@
{% trans 'default route' %} {% trans 'default route' %}
</p> </p>
</div> </div>
{% endif %}
{% for ip_address in peer_client_ip_list %} {% for ip_address in peer_client_ip_list %}

View File

@@ -62,6 +62,8 @@ class PeerAllowedIPForm(forms.ModelForm):
if ipaddress.ip_address(allowed_ip) in wireguard_network: 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': elif self.config_file == 'client':
if self.current_peer.routing_template and not self.current_peer.routing_template.allow_peer_custom_routes:
raise forms.ValidationError(_("The peer's routing template does not allow custom routes."))
if priority < 1: 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: else: