Manage AllowedIPs for client config file

This commit is contained in:
Eduardo Silva 2024-03-09 16:02:48 -03:00
parent 7561156235
commit 32931dfd16
11 changed files with 188 additions and 106 deletions

View file

@ -9,7 +9,6 @@
<br>
<h3>Upcoming Enhancements</h3>
<ul>
<li>Implementing AllowedIPs in the client configuration.</li>
<li>Improving "Pending changes" notification and separation (WireGuard from Firewall)</li>
</ul>

View file

@ -47,30 +47,91 @@
</div>
<div class="col-lg-6">
<label>IP Addresses</label>
{% for ip_address in peer_ip_list %}
<div class="d-flex justify-content-between align-items-center border-bottom mb-3">
<p>
<div class="row">
<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
</label>
<a class="btn btn-outline-primary btn-xs" href="/peer/manage_ip_address/?peer={{ current_peer.uuid }}&config=server" >Add IP Address</a>
</div>
{% for ip_address in peer_ip_list %}
<div class="d-flex justify-content-between align-items-center border-bottom mb-3">
<p>
<a href="/peer/manage_ip_address/?ip={{ ip_address.uuid }}">
<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
{% else %}
Priority: {{ ip_address.priority }}
{% endif %}
</p>
</div>
{% endfor %}
</div>
</div>
<div class="row">
<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 client configuration file"></i>
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>
</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.');"
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.');"
{% endif %}
>
<i class="fas fa-network-wired"></i>
0.0.0.0/0, ::/0
</a>
</p>
<p class="d-flex flex-column text-right small">
default route
</p>
</div>
{% for ip_address in peer_client_ip_list %}
<div class="d-flex justify-content-between align-items-center border-bottom mb-3">
<p>
<a href="/peer/manage_ip_address/?ip={{ ip_address.uuid }}">
<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
{% else %}
Priority: {{ ip_address.priority }}
{% endif %}
</p>
</div>
{% endfor %}
</div>
</div>
{% if ip_address.missing_from_wireguard %}
<a href='/peer/manage_ip_address/?ip={{ ip_address.uuid }}' class='bg-warning' title="This address does not appear in the wg show command output, likely indicating that another peer has an IP overlapping this network or that the configuration file is outdated.">
<i class="fas fa-network-wired"></i>
{{ ip_address}}
</a>
{% else %}
<a href="/peer/manage_ip_address/?ip={{ ip_address.uuid }}">
<i class="fas fa-network-wired"></i>
{{ ip_address}}
</a>
{% endif %}
</p>
<p class="d-flex flex-column text-right small">
Priority: {{ ip_address.priority }}
</p>
</div>
{% endfor %}
</div>

View file

@ -39,43 +39,14 @@
<b>Latest Handshake:</b> <span id="peer-latest-handshake-{{ peer.public_key }}"></span> <span style="display: none;" id="peer-stored-latest-handshake-{{ peer.public_key }}">{% if peer.peerstatus.last_handshake %}{{ peer.peerstatus.last_handshake|date:"U" }}{% else %}0{% endif %}</span><br>
<b>Endpoints:</b> <span id="peer-endpoints-{{ peer.public_key }}"></span><br>
<b>Allowed IPs: </b><span id="peer-allowed-ips-{{ peer.public_key }}">
{% for address in peer.peerallowedip_set.all %}{% if address.priority == 0 %}
{% if address.missing_from_wireguard %}
<a href='#' class='bg-warning' title="This address does not appear in the wg show command output, likely indicating that another peer has an IP overlapping this network or that the configuration file is outdated.">{{ address }}</a>
{% else %}
{{ address }}
{% endif %}
{% endif %}{% endfor %}
{% for address in peer.peerallowedip_set.all %}{% if address.priority >= 1 %}
{% if address.missing_from_wireguard %}
<a href='#' class='bg-warning' title="This address does not appear in the wg show command output, likely indicating that another peer has an IP overlapping this network or that the configuration file is outdated.">{{ address }}</a>
{% else %}
{{ address }}
{% endif %}
{% endif %}{% endfor %}
{% for address in peer.peerallowedip_set.all %}
{% if address.priority == 0 and address.config_file == 'server' %}{{ address }}{% endif %}
{% endfor %}
{% for address in peer.peerallowedip_set.all %}
{% if address.priority >= 1 and address.config_file == 'server' %}{{ address }}{% endif %}
{% endfor %}
</span>
</p>
{% comment %}
<p>{% for address in peer.peerallowedip_set.all %}{% if address.priority == 0 %}
{% if address.missing_from_wireguard %}
<a href='#' class='bg-warning' title="This address does not appear in the wg show command output, likely indicating that another peer has an IP overlapping this network or that the configuration file is outdated.">{{ address }}</a>
{% else %}
{{ address }}
{% endif %}
{% endif %}{% endfor %}
{% for address in peer.peerallowedip_set.all %}{% if address.priority >= 1 %}
{% if address.missing_from_wireguard %}
<a href='#' class='bg-warning' title="This address does not appear in the wg show command output, likely indicating that another peer has an IP overlapping this network or that the configuration file is outdated.">{{ address }}</a>
{% else %}
{{ address }}
{% endif %}
{% endif %}{% endfor %}
</p>
{% endcomment %}
</div>