qBittorrent has a way to select an interface to route all the traffic, how do I achieve this for my rust program?
Do this by binding the socket to an IP address on the interface before connecting. Querying interfaces is OS-specific, but there are many published crates available for it.
The standard library doesn’t seem to have a bind
method for TCP. There is the socket2
crate for sync sockets, and tokio
has it available for async sockets.
See: How to bind() on TCP client side in rust/tokio? - Stack Overflow
1 Like