johnyburd / net-route

Rust crate providing a cross platform interface for interacting with the routing table
https://docs.rs/net-route/
21 stars 14 forks source link

fix: fix ENOBUFS problem on macos, add retry mechanism #26

Closed hsqStephenZhang closed 6 months ago

hsqStephenZhang commented 7 months ago

I use a vpn with tun device on my macos, and when I tested the example code, the OutofMemory error constantly repeated, and it was caused by sysctl of getting the messages on MacOs. After digging into golang's network library, I found that it's a common issue, and can be solved by retry.

See: https://github.com/golang/net/blob/ec05fdcd71141c885f3fb84c41d1c692f094ccbe/route/route.go#L126

johnyburd commented 6 months ago

looks good, thanks for the PR!