mildsunrise / node_netlink

⚒ Use Netlink from Node.js
MIT License
22 stars 2 forks source link

help me to use node_netlink to set and get wireguard config #18

Closed Sirherobrine23 closed 1 year ago

Sirherobrine23 commented 1 year ago

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.

mildsunrise commented 1 year ago

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

Sirherobrine23 commented 1 year ago

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.

mildsunrise commented 1 year ago

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.

mildsunrise commented 1 year ago

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...

Sirherobrine23 commented 1 year ago

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

Sirherobrine23 commented 1 year ago

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.

mildsunrise commented 1 year ago

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.

mildsunrise commented 1 year ago

took me longer than expected but I've mapped the types and API, see https://github.com/mildsunrise/node_netlink/commit/59dbc1edb72ad54c951d5a3123b56616b20d4875.

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

Sirherobrine23 commented 1 year ago

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

Sirherobrine23 commented 1 year ago

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