Shouqun / node-dbus

dbus module for node
MIT License
150 stars 70 forks source link

Unable to write Struct dbus data type #237

Open muneale opened 2 years ago

muneale commented 2 years ago

I need to write the Addresses field on org.freedesktop.NetworkManager.IP6Config interface, which is Array of Struct (more precisely is a(ayuay)). However, when I try to edit my configuration, the following error messagge appears: ipv6.addresses: can't set property of type 'a(ayuay)' from value of type 'av'

This is a piece of my code:

...

newConf['ipv6'] = {
  method: "manual",
  addresses: [
      [...ip.toBuffer(config.ipv6['address']).swap64()],
      config.ipv6['prefix'],
      config.ipv6['gateway'] ? [...ip.toBuffer(config.ipv6['gateway']).swap64()] : [...Buffer.alloc(16)]
  ]
};

...

await new Promise((resolve, reject) => {
  nm.dbus().getInterface('org.freedesktop.NetworkManager', connection['objectPath'], 'org.freedesktop.NetworkManager.Settings.Connection', (error, conn) => {
    if (error) return reject(error);
    conn.Update(newConfig, (error) => {
      if (error) return reject(error);
      return resolve(null);
    });
  });
});

I had understood that I'm currently writing an array of variants, however I don't have any clue about how to solve it since it seems impossible to pass the dbus data type as argument. Am I missing something? Or is there any workaround?

Thank you