[Networkmanager] Implementing a NetworkManager VPN Plugin in Rust

Thomas Haller thaller at redhat.com
Tue Dec 5 18:17:44 UTC 2023


On Tue, 2023-12-05 at 23:56 +0700, amidamaru rookie wrote:
> Thanks for your advice. I will play some code first based on
> your suggestion and check networkmanager code for adding new type
> before submitting a MR.
> 
> Cheers,

to have a working VPN plugin, you need at least a file

  /usr/lib/NetworkManager/VPN/*.name

and a executable 

  [VPN Connection]
  program=/usr/libexec/nm-*-service

And that executable is spawned by NetworkManager, and is expected to
service the D-Bus interface for VPN plugins.

Also, there is a client library that can provide meta-data (information
about the plugin) to client applications (nmcli, nm-connection-editor).
Those are

  [libnm]
  plugin=libnm-*.so

These provide a nm_vpn_editor_plugin_factory() function, to load a
NMVpnEditorPlugin. That API is in libnm (and implemented by the
plugin).

There is also a helper tool for requesting secrets

  [GNOME]
  auth-dialog=/usr/libexec/nm-openvpn-auth-dialog

which again implements some API (being forked by nm-applet, and
communicating via stdin/stdout).


The legacy library you can ignore. It's no longer relevant:

  [GNOME]
  properties=libnm-*


You at least need the first part.

All these pieces can be implemented in any language. However, since all
existing plugins are in C+glib, it's much easier to look at
NetworkManager-openvpn and just duplicate that. If you need to
implement that all in a new language, it's much more work.


Good luck,
Thomas


> 
> Vào Th 3, 5 thg 12, 2023 vào lúc 23:38 Frédéric Martinsons
> <frederic.martinsons at gmail.com> đã viết:
> > I don't think it is possible without patching the networkmanager
> > code itself. You should look at how these kind of type are defined
> > in nmcli/libnm code base and possibly submit a merge request to add
> > a new rosenpass one. 
> > 
> > Le mar. 5 déc. 2023, 17:33, amidamaru rookie <ardtimeit at gmail.com>
> > a écrit :
> > > Thanks for your reference links, I will check them out.
> > > For nmcli integration, the only thing I have no idea is the value
> > > of type must be known. 
> > > So as my example above:
> > > nmcli con import type rosenpass file /data/rp.conf
> > > the value of type is "rosenpass". 
> > > Is there any way to add this new value ? 
> > > 
> > > Thank you,
> > > 
> > > Vào Th 3, 5 thg 12, 2023 vào lúc 23:16 Frédéric Martinsons
> > > <frederic.martinsons at gmail.com> đã viết:
> > > > Maybe you can take a look
> > > > at https://crates.io/crates/networkmanager which uses nm dbus
> > > > api.
> > > > 
> > > > You may also want to look at gtk-rs project
> > > > (https://gtk-rs.org/) to find inspiration.
> > > > 
> > > > 
> > > > 
> > > > On Tue, 5 Dec 2023 at 17:12, amidamaru rookie
> > > > <ardtimeit at gmail.com> wrote:
> > > > > Hi team,
> > > > > 
> > > > > Currently I'm implementing a Rosenpass NM Plugin in Rust.
> > > > > I cannot find much information about this except the VPN
> > > > > support page - but most of the projects there were written in
> > > > > C.
> > > > > The only reference I can find is this repository. 
> > > > > But after all these years, the NetworkManager codebase won't
> > > > > have this shared directory anymore.
> > > > > So now, my question is where can I collect these files from
> > > > > the current NM codebase? Also, 
> > > > > Besides the GUI (editor dialog) part, I want to integrate
> > > > > Rosenpass into nmcli also.
> > > > > For example, after integration, I can do something like this:
> > > > > nmcli con import type rosenpass file /data/rp.conf
> > > > > 
> > > > > Could you please give some advice on this?
> > > > > 
> > > > > Thank you,
> > > > > -- 
> > > > > Đinh Thảo_PTIT's student - ardtimeit at gmail.com
> > > 
> > > 
> > > -- 
> > > Đinh Thảo_PTIT's student - ardtimeit at gmail.com
> 
> 
> -- 
> Đinh Thảo_PTIT's student - ardtimeit at gmail.com



More information about the Networkmanager mailing list