mildsunrise / node_netlink

⚒ Use Netlink from Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

help me to use node_netlink to set and get wireguard config

Sirherobrine23 opened this issue · comments

hi, I'm starting a module to manage Wireguard interfaces through node, I never got close to netlink and even close to interacting with the kernel, I'm relying entirely on wireguard-tools, wgctrl-go and pyroute2.

I'm modifying the wireguard-tools in the netlink part to know how it interacts, I'm using an pull request in my repository to store what I get,
I was wondering if anyone could help me with the netlink part.

hi! I'm currently not up for that, but if you have specific questions or issues that's welcome :)

ok thanks, but I have one, I'm using the generic request to filter the families but I'm a little confused, I need to get the interfaces but I'm not able to filter the interfaces. when using the Wireguard family, in the request, I create function to filter, so not works.

I don't understand what you're doing... you're issuing a WG_CMD_SET_DEVICE command with a hardcoded message (FAAAAAMAAgA+zNBiMHUAAAAAAAA=) to check each interface?
I've never used the API, but shouldn't you put the ifindex / ifname to operate on in the message?
Also, since the function is called getDevices, shouldn't you use WG_CMD_GET_DEVICE instead?
Also, remember to not hardcode the family ID in the code, since it depends upon boot. You should set it to the result of getFamily(), not 2.

I can't make any sense of the message you hardcoded there.
Since it's a relatively small API, I'll add types for it...

I'm going to test some things, I will still be testing.

Being able to filter wireguard's network interfaces by getLinks() -> attrs -> linkinfo -> toString() (here it says it's a wireguard interface), the function is here. Now I'm going to see how to create a Wireguard interface without having to run ip link add dev {INTERFACE NAME} type wireguard.

I'm much more optimistic now that I can get the interfaces, I created a TODO in the pull request, I still have a lot to do.

the contents of linkinfo are currently set as data, which likely indicates that the types for its contents are missing. if you want to help make node-netlink better, you can investigate what it's supposed to hold and create types for it. This is also what I'm going to do for the wireguard API.

took me longer than expected but I've mapped the types and API, see 59dbc1e.

I probably won't release it until it gets some testing, though

ok, I'll take a look later, I'm using the embeddable-wg-library module to implement Wireguard.

I'm going to port some resources I'm writing to your module.