wgctrl-go icon indicating copy to clipboard operation
wgctrl-go copied to clipboard

internal/wglinux: multicast group listener

Open elwhite321 opened this issue 3 years ago • 4 comments

I have a use case where the user program using wgctrl-go needs control over the WireGuard kernel devices. If the wg, ip or similar CLIs are used to change a device, the user program will be out of sync.

What are the thoughts around implementing a multicast group client to update the devices as they change? Does this feature / enhancement justify the discontinuity between the user land device(s)?

I'd be happy to look into this if it makes sense.

elwhite321 avatar Mar 24 '22 21:03 elwhite321

As of today, wireguard genetlink does not expose any multicast groups:

$ uname -a
Linux matt-3 5.13.0-37-generic #42-Ubuntu SMP Tue Mar 15 14:34:06 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
$ genl ctrl get name wireguard

Name: wireguard
        ID: 0x22  Version: 0x1  header size: 0  max attribs: 8 
        commands supported: 
                #1:  ID-0x0 
                #2:  ID-0x1 

And listening for device changes made by iproute2 would be an rtnetlink operation, which is out of scope for this library.

I don't think there is anything that can be done here today. But maybe notifying on device configuration changes is something that @zx2c4 could consider for the WireGuard kernel module.

mdlayher avatar Mar 24 '22 22:03 mdlayher

Thank you for correcting the title.

I have seen this patch but am unsure of the status. Maybe something for the future.

I was going to open another issue for adding and removing devices. This would also require rtnetlink, and thus I assume out of the scope too?

elwhite321 avatar Mar 24 '22 23:03 elwhite321

Thanks for the patch link.

That's correct: adding and removing devices is out of scope for this library since it ultimately relies on an entirely separate set of APIs.

mdlayher avatar Mar 24 '22 23:03 mdlayher

I've implemented a package which watches interfaces using wgctrl and allows you to register callbacks for various events:

https://github.com/stv0g/wice/tree/master/pkg/watcher

stv0g avatar Aug 16 '22 17:08 stv0g