fengyc / natpmp

NAT-PMP library in rust
MIT License
30 stars 7 forks source link

Replace the C `get_default_gateway` implementation with netdev #6

Closed sgued closed 1 week ago

sgued commented 6 months ago

https://crates.io/crates/netdev is a crate that can allow you to get the default gateway and is widely used (it was previously named default-net with almost 70k downloads/montth

It has a bit of unsafe but does not link against C code. I find it preferable to using the embeded C code that never got updated.

If compile adding dependencies are an issue, i could also be possible to make the C implementation of get_default_gateway optional.

That would allow my project to get rid of the unupdated c dependency I don't like.

quietvoid commented 2 months ago

@sgued Seeing this issue as I was about to fork your natpmp-ng. For my usecase I don't need get_default_gateway, so if you made it optional in your fork I could use it.

I'm just going to remove it for now.

sgued commented 2 months ago

Feel free to open a PR on natpmp-ng that makes this optional. I will merge it. https://gitlab.com/sgued/natpmp-ng/-/merge_requests

quietvoid commented 2 months ago

I'm not sure how complicated it would be to make optional, though. I'll have to look into it.

fengyc commented 1 week ago

Sounds good, the C FFI is removed. It is a surprise that this repo created 6-7 years ago, still have active users. As far as I known, natpmp has been deprecated in many routers, so I was unable to test the features since 3 years ago as I don't have a such a router.

quietvoid commented 1 week ago

Thanks! I'm using the crate to interact with ProtonVPN for automatic port forwarding renewal, they use natpmp requests.

sgued commented 1 week ago

Same, I'm using it for ProtonVPN. I built a GTK utility for that: https://ten-forward.sgued.fr/