NMClient.IP4Config get_addresses() not always populated when signal 'notify::ip4-config' is fired
- From: Sylvain Garaud <garaud gmail com>
- To: networkmanager-list gnome org
- Subject: NMClient.IP4Config get_addresses() not always populated when signal 'notify::ip4-config' is fired
- Date: Sun, 15 Mar 2015 12:46:20 +0100
Hello,
I am writing a small _javascript_ for gnome to grab the ip addresses of my network interfaces using imports.gi.NMClient;
Basically I get the devices and connect each device to the notify::ip4-config signal to be able to update the ip address value when it changes
this.client = NMC.Client.new();
this.devices = this.client.get_devices();
for each (let device in this.devices) {
device.connect('notify::ip4-config',Lang.bind(this,this._update));
}
It works fine for the wifi connection but there is a problem with the ethernet connection.
After turning my ethernet connection up, the signal 'notify::ip4-config' is fired, the device state is ACTIVATED, so I try to get the ip4 config.
with ipcfg = device.get_ip4_config();
I get a not null ipcfg object, unfortunately ipcfg.get_addresses() is not defined yet.
I see in my journalctl log few seconds later, some dhcp network manager message.
_update: function(device) {
let ipcfg = device.get_ip4_config();
if (ipcfg != null) {
for each(let addr in ipcfg.get_addresses()){
let num = addr.get_address();
}
}
},
How to be sure ipcfg.get_addresses() will return something ?
Could someone tell me which signal to use for being sure the ip address is set when calling ipcfg.get_addresses()? I tried using the 'notify::dhcp4-config' signal instead 'notify::ip4-config' without much success.
Thank you very much for your help,
Sylvain
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]