Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(firezone-tunnel): move routes and DNS control out of connlib and up to the Client #5111

Merged
merged 84 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
c6caf88
work towards enabling the debug IPC service on Linux
ReactorScram May 21, 2024
78d08fc
Linux has the debug IPC service now
ReactorScram May 21, 2024
2f324ed
refactor
ReactorScram May 21, 2024
979d645
refactor
ReactorScram May 21, 2024
3d2cdf0
fix Windows build
ReactorScram May 21, 2024
8d9e1d5
move almost everything out of windows module
ReactorScram May 21, 2024
ba1a713
Fix Linux build
ReactorScram May 21, 2024
46a9146
fix Windows clippy
ReactorScram May 21, 2024
b605b46
hide this comment from the CLI output
ReactorScram May 21, 2024
86092b9
fix Windows service
ReactorScram May 22, 2024
a13c3f3
Merge branch 'refactor/debug-ipc-service' of github.com:firezone/fire…
ReactorScram May 22, 2024
52ea524
checkpoint
ReactorScram May 22, 2024
dbafcba
extract almost all stuff to the platform-independent module
ReactorScram May 22, 2024
92dfb05
de-dupe
ReactorScram May 22, 2024
99bbe9e
Merge remote-tracking branch 'origin/main' into refactor/debug-ipc-se…
ReactorScram May 22, 2024
8565d65
this only needs to be a type alias, not a wrapper struct
ReactorScram May 22, 2024
9aa92c9
Merge branch 'refactor/debug-ipc-service' into refactor/dedupe-ipc-cl…
ReactorScram May 22, 2024
7ad59ac
it works but much cleanup is needed
ReactorScram May 23, 2024
2e6c1e3
clippy
ReactorScram May 23, 2024
c9dd823
remove unused dep
ReactorScram May 23, 2024
6874798
checkpoint
ReactorScram May 23, 2024
ee99ed9
Merge remote-tracking branch 'origin/refactor/dedupe-ipc-clients' int…
ReactorScram May 23, 2024
2bedd3e
checkpoint
ReactorScram May 23, 2024
8f7b0a9
extract module
ReactorScram May 23, 2024
5271b15
refactor
ReactorScram May 23, 2024
5c36285
fmt
ReactorScram May 23, 2024
bfc6ac6
Merge remote-tracking branch 'origin/main' into refactor/debug-ipc-se…
ReactorScram May 24, 2024
f881898
use `PathBuf` here instead of `String`
ReactorScram May 24, 2024
2a71eff
remove outdated comment
ReactorScram May 24, 2024
24b9944
remove unused CLI args
ReactorScram May 24, 2024
43fac19
use `futures::future::select` to simplify the signal polling
ReactorScram May 24, 2024
f55f3d1
Merge remote-tracking branch 'origin/main' into refactor/debug-ipc-se…
ReactorScram May 24, 2024
7d21d27
doesn't compile, checkpoint
ReactorScram May 24, 2024
e89707f
fix Windows build
ReactorScram May 24, 2024
bd86707
fix incorrect SIGHUP behavior
ReactorScram May 24, 2024
c1e7014
fix Linux
ReactorScram May 24, 2024
a82f163
I forgot to commit this
ReactorScram May 24, 2024
f61d543
Merge remote-tracking branch 'origin/refactor/debug-ipc-service' into…
ReactorScram May 24, 2024
c6b4bba
fmt
ReactorScram May 24, 2024
e85bed6
clippy
ReactorScram May 24, 2024
63d2c86
move Windows DNS control out of `tun_windows.rs` too
ReactorScram May 24, 2024
4ee20d7
fix IPC service
ReactorScram May 24, 2024
644e97c
fix OnTunnelReady
ReactorScram May 24, 2024
595bed1
move this log to the right place
ReactorScram May 24, 2024
3f7b8b6
Merge remote-tracking branch 'origin/refactor/debug-ipc-service' into…
ReactorScram May 24, 2024
a245ff0
improve error messages
ReactorScram May 24, 2024
6818f39
fix Windows
ReactorScram May 24, 2024
a6c1b90
Merge remote-tracking branch 'origin/refactor/dedupe-ipc-clients' int…
ReactorScram May 24, 2024
d93b55f
not sure why routes aren't being claimed
ReactorScram May 24, 2024
0ebfcbe
clippy
ReactorScram May 24, 2024
f1a9342
fix the headless Client
ReactorScram May 24, 2024
8ff1dea
Merge commit '6b570a6da' into refactor/move-linux-dns-control
ReactorScram May 28, 2024
f6e7ef9
Merge remote-tracking branch 'origin/main' into refactor/move-linux-d…
ReactorScram May 28, 2024
ea8f417
try to fix the Gateway
ReactorScram May 28, 2024
c726689
fix Linux. Gateway still busted
ReactorScram May 28, 2024
d9686ef
hide InterfaceManager from other platforms
ReactorScram May 28, 2024
882e8a2
set routes for gateway
ReactorScram May 29, 2024
e5a3eea
fmt
ReactorScram May 29, 2024
f45ae11
clippy
ReactorScram May 29, 2024
dd6421c
move `sd_notify` call up
ReactorScram May 29, 2024
5352791
Merge remote-tracking branch 'origin/main' into refactor/move-linux-d…
ReactorScram May 29, 2024
5bcf8cb
update comments
ReactorScram May 29, 2024
ae0da14
let `dns_control` be fallible instead of panicking
ReactorScram May 29, 2024
8879d2f
simplify this
ReactorScram May 29, 2024
86029c4
clean these up and make them fallible
ReactorScram May 29, 2024
a331709
clean up a couple TODOs
ReactorScram May 29, 2024
c4d5a5f
remove completed TODO
ReactorScram May 29, 2024
3af1e04
Merge remote-tracking branch 'origin/main' into refactor/move-linux-d…
ReactorScram May 31, 2024
c420a34
derive `Debug`
ReactorScram May 31, 2024
dbacef3
apply feedback from reviews
ReactorScram May 31, 2024
bdc266a
rename functions that are no longer implementing `Callbacks`
ReactorScram May 31, 2024
696c094
actually the `Session` already has an `Arc<Adapter>`
ReactorScram May 31, 2024
d823af1
de-dupe consts
ReactorScram May 31, 2024
3391154
try to fix Linux
ReactorScram May 31, 2024
c51ab94
try to fix Linux
ReactorScram May 31, 2024
bd4b57b
Merge remote-tracking branch 'origin/main' into refactor/move-linux-d…
ReactorScram May 31, 2024
3a51a58
remove unused `Option`
ReactorScram May 31, 2024
cc7764a
rename
ReactorScram May 31, 2024
8d0c659
Merge remote-tracking branch 'origin/main' into refactor/move-linux-d…
ReactorScram May 31, 2024
6f50f9a
refactor and move a bunch of stuff from connlib_shared to headless-cl…
ReactorScram May 31, 2024
2555d63
fix Windows build
ReactorScram May 31, 2024
b9894e1
remove unused dep
ReactorScram May 31, 2024
78ac55c
forgot to get Cargo.lock
ReactorScram May 31, 2024
43752d9
fix dep only used on Linux
ReactorScram Jun 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions rust/connlib/shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ ip_network = { version = "0.4", default-features = false, features = ["serde"] }
os_info = { version = "3", default-features = false }
rand = { version = "0.8", default-features = false, features = ["std"] }
rand_core = { version = "0.6.4", default-features = false, features = ["std"] }
resolv-conf = "0.7.0"
serde = { version = "1.0", default-features = false, features = ["derive", "std"] }
serde_json = { version = "1.0", default-features = false, features = ["std"] }
thiserror = { version = "1.0", default-features = false }
Expand All @@ -41,9 +40,7 @@ hickory-proto = { workspace = true, optional = true }
log = "0.4"

[dev-dependencies]
tempfile = "3.10.1"
itertools = "0.12"
mutants = "0.0.3" # Needed to mark functions as exempt from `cargo-mutants` testing
tokio = { version = "1.36", features = ["macros", "rt"] }

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
Expand All @@ -52,11 +49,9 @@ swift-bridge = { workspace = true }
[target.'cfg(target_os = "android")'.dependencies]
tracing-android = "0.2"

[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]
# Needed to safely backup `/etc/resolv.conf` and write the device ID on behalf of `gui-client`
atomicwrites = "0.4.3"

[target.'cfg(target_os = "linux")'.dependencies]
netlink-packet-route = { version = "0.19", default-features = false }
netlink-packet-core = { version = "0.7", default-features = false }
rtnetlink = { workspace = true }

# Windows tunnel dependencies
Expand Down
16 changes: 16 additions & 0 deletions rust/connlib/shared/src/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ impl From<Ipv6Network> for Cidrv6 {
}
}

impl From<Cidrv4> for IpNetwork {
fn from(x: Cidrv4) -> Self {
Ipv4Network::new(x.address, x.prefix)
.expect("A Cidrv4 should always translate to a valid Ipv4Network")
.into()
}
}

impl From<Cidrv6> for IpNetwork {
fn from(x: Cidrv6) -> Self {
Ipv6Network::new(x.address, x.prefix)
.expect("A Cidrv6 should always translate to a valid Ipv6Network")
.into()
}
}

#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Status {
Unknown,
Expand Down
25 changes: 3 additions & 22 deletions rust/connlib/shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@
pub mod callbacks;
pub mod error;
pub mod messages;

/// Module to generate and store a persistent device ID on disk
///
/// Only properly implemented on Linux and Windows (platforms with Tauri and headless client)
#[cfg(any(target_os = "linux", target_os = "windows"))]
pub mod device_id;

#[cfg(target_os = "linux")]
pub mod linux;
pub mod tun_device_manager;

#[cfg(target_os = "windows")]
pub mod windows;
Expand Down Expand Up @@ -48,22 +40,11 @@ pub type DomainName = domain::base::Name<Vec<u8>>;
/// <https://learn.microsoft.com/en-us/windows/configuration/find-the-application-user-model-id-of-an-installed-app>
pub const BUNDLE_ID: &str = "dev.firezone.client";

pub const DEFAULT_MTU: u32 = 1280;

const VERSION: &str = env!("CARGO_PKG_VERSION");
const LIB_NAME: &str = "connlib";

/// Deactivates DNS control on Windows
#[cfg(target_os = "windows")]
pub fn deactivate_dns_control() -> anyhow::Result<()> {
windows::dns::deactivate()
}

/// Deactivates DNS control on other platforms (does nothing)
#[cfg(not(target_os = "windows"))]
#[allow(clippy::unnecessary_wraps)]
pub fn deactivate_dns_control() -> anyhow::Result<()> {
Ok(())
}

pub fn keypair() -> (StaticSecret, PublicKey) {
let private_key = StaticSecret::random_from_rng(OsRng);
let public_key = PublicKey::from(&private_key);
Expand Down
30 changes: 0 additions & 30 deletions rust/connlib/shared/src/linux.rs

This file was deleted.

14 changes: 14 additions & 0 deletions rust/connlib/shared/src/tun_device_manager.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! DNS and route control for the virtual network interface in `firezone-tunnel`

#[cfg(target_os = "linux")]
pub mod linux;
#[cfg(target_os = "linux")]
pub use linux as platform;

#[cfg(target_os = "windows")]
pub mod windows;
#[cfg(target_os = "windows")]
pub use windows as platform;

#[cfg(any(target_os = "linux", target_os = "windows"))]
pub use platform::TunDeviceManager;
Loading
Loading