mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
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:
parent
643a06c7cd
commit
7e7e7a6ccf
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user