net-route
net-route copied to clipboard
The `Handle::add` returns an error on macOs when setting the route to `0.0.0.0/0`
The way of setting routes to make all traffic reach the specified tun interface is suggested to be:
let if_name = CString::new("utun6")?;
let tun_ifindex = unsafe{
libc::if_nametoindex(if_name.as_ptr())
};
let handle = Handle::new()?;
let route = Route::new("0.0.0.0".parse().unwrap(), 0).with_ifindex(tun_ifindex);
handle.add(&route).await // #1
However, #1
just returns an error Err(Custom { kind: AlreadyExists, error: "rtm_errno 17" })
. If set the routing with Route::new("20.0.0.0".parse().unwrap(), 24).with_ifindex(tun_ifindex);
then it's OK.
In both case, there is a panic at
.cargo/registry/src/index.crates.io-6f17d22bba15001f/net-route-0.2.11/src/platform_impl/macos/macos.rs:254:25:
index out of bounds: the len is 12 but the index is 12
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace