diff --git a/plinth/modules/networks/networks.py b/plinth/modules/networks/networks.py index 93b1d6753..668e852c7 100644 --- a/plinth/modules/networks/networks.py +++ b/plinth/modules/networks/networks.py @@ -142,19 +142,22 @@ def edit(request, uuid): if settings_connection.get_connection_type() != 'pppoe': settings_ipv4 = connection.get_setting_ip4_config() form_data['ipv4_method'] = settings_ipv4.get_method() - address, netmask = network.get_first_ip_address_from_connection( - connection) + if settings_ipv4.get_num_addresses(): + address = settings_ipv4.get_address(0) + form_data['ipv4_address'] = address.get_address() + prefix = address.get_prefix() + netmask = network.nm.utils_ip4_prefix_to_netmask(prefix) + form_data['ipv4_netmask'] = network.ipv4_int_to_string(netmask) + gateway = settings_ipv4.get_gateway() dns = settings_ipv4.get_dns(0) second_dns = settings_ipv4.get_dns(1) - if address: - form_data['ipv4_address'] = address - if netmask: - form_data['ipv4_netmask'] = netmask if gateway: form_data['ipv4_gateway'] = gateway + if dns: form_data['ipv4_dns'] = dns + if second_dns: form_data['ipv4_second_dns'] = second_dns diff --git a/plinth/network.py b/plinth/network.py index cbb4581bf..b1b4560d8 100644 --- a/plinth/network.py +++ b/plinth/network.py @@ -197,24 +197,6 @@ def _get_wifi_channel_from_frequency(frequency): return str(frequency / 1000) + 'GHz' -def get_first_ip_address_from_connection(connection): - """Return the first IP address of a connection setting. - - XXX: Work around a bug in NetworkManager/Python GI. Remove after - the bug if fixed. - https://bugzilla.gnome.org/show_bug.cgi?id=756380. - """ - devicename=connection.get_interface_name() - ip="0.0.0.0" - device=nm.Client.new(None).get_device_by_iface(devicename) - ip4_config=device.get_ip4_config() - if ip4_config: - addresses=ip4_config.get_addresses() - if addresses: - ip_address=addresses.__getitem__(0).get_address() - netmask=addresses.__getitem__(0).get_prefix() - return ip_address,ipv4_int_to_string(netmask) - def get_connection_list(): """Get a list of active and available connections.""" active_uuids = []