mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-03-22 04:42:03 +00:00
Currently, the platform-specific code for controlling DNS resolution on a system sits in `firezone-headless-client`. This code is also used by the GUI client. This creates a weird compile-time dependency from the GUI client to the headless client. For other components that have platform-specific implementations, we use the `firezone-bin-shared` crate. As a first step of resolving the compile-time dependency, we move the `dns_control` module to `firezone-bin-shared`.
18 lines
560 B
Rust
18 lines
560 B
Rust
use std::{io, net::SocketAddr};
|
|
|
|
use crate::FIREZONE_MARK;
|
|
use nix::sys::socket::{setsockopt, sockopt};
|
|
use socket_factory::{TcpSocket, UdpSocket};
|
|
|
|
pub fn tcp_socket_factory(socket_addr: &SocketAddr) -> io::Result<TcpSocket> {
|
|
let socket = socket_factory::tcp(socket_addr)?;
|
|
setsockopt(&socket, sockopt::Mark, &FIREZONE_MARK)?;
|
|
Ok(socket)
|
|
}
|
|
|
|
pub fn udp_socket_factory(socket_addr: &SocketAddr) -> io::Result<UdpSocket> {
|
|
let socket = socket_factory::udp(socket_addr)?;
|
|
setsockopt(&socket, sockopt::Mark, &FIREZONE_MARK)?;
|
|
Ok(socket)
|
|
}
|