wireguard: Fix showing default route setting in server edit form

- The default route is not decided by the subnet on the IP address assigned. It
is to be decided using the list of allowed peers in the wireguard settings.

Tests:

- Set the default route setting to 'on' while creating the connection. In the
edit server page, the value is shown correctly. Repeat with 'off' value.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2026-02-26 22:34:20 -08:00 committed by James Valleroy
parent 643a06c7cd
commit 7e7e7a6ccf
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -40,7 +40,6 @@ def get_nm_info():
info['listen_port'] = settings.get_listen_port()
info['fwmark'] = settings.get_fwmark()
info['mtu'] = settings.get_mtu()
info['default_route'] = settings.get_ip4_auto_default_route()
info['peers'] = {}
for peer_index in range(settings.get_peers_len()):
peer = settings.get_peer(peer_index)
@ -57,6 +56,13 @@ def get_nm_info():
info['peers'][peer_info['public_key']] = peer_info
# This is default route when all IPs are in allowed IPs list.
info['default_route'] = False
for peer_info in info['peers'].values():
if ('0.0.0.0/0' in peer_info['allowed_ips']
and '::/0' in peer_info['allowed_ips']):
info['default_route'] = True
settings_ipv4 = connection.get_setting_ip4_config()
if settings_ipv4 and settings_ipv4.get_num_addresses():
info['ip_address'] = settings_ipv4.get_address(0).get_address()