mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
The current Rust workspace isn't as consistent as it could be. To make navigation a bit easier, we move a few crates around. Generally, we follow the idea that entry-points should be at the top-level. `rust/` now looks like this (directories only): ``` . ├── cli # Firezone CLI ├── client-ffi # Entry point for Apple & Android ├── gateway # Gateway ├── gui-client # GUI client ├── headless-client # Headless client ├── libs # Library crates ├── relay # Relay ├── target # Compile artifacts ├── tests # Crates for testing └── tools # Local tools ``` To further enforce this structure, we also drop the `firezone-` prefix from all crates that are not top-level binary crates.
55 lines
1.5 KiB
Rust
55 lines
1.5 KiB
Rust
//! An abstraction over well-known dirs like AppData/Local on Windows and $HOME/.config on Linux
|
|
//!
|
|
//! On Linux it uses `dirs` which is a convenience wrapper for getting XDG environment vars
|
|
//!
|
|
//! On Windows it uses `known_folders` which calls into Windows for forwards-compatibility
|
|
//! We can't use `dirs` on Windows because we need to match connlib for when it opens wintun.dll.
|
|
//!
|
|
//! I wanted the ProgramData folder on Windows, which `dirs` alone doesn't provide.
|
|
|
|
use anyhow::{Context as _, Result};
|
|
use std::path::PathBuf;
|
|
|
|
pub use platform::{logs, runtime, session, settings, tunnel_service_config, tunnel_service_logs};
|
|
|
|
#[cfg(target_os = "linux")]
|
|
#[path = "known_dirs/linux.rs"]
|
|
pub mod platform;
|
|
|
|
#[cfg(target_os = "macos")]
|
|
#[path = "known_dirs/macos.rs"]
|
|
pub mod platform;
|
|
|
|
#[cfg(target_os = "windows")]
|
|
#[path = "known_dirs/windows.rs"]
|
|
pub mod platform;
|
|
|
|
pub fn tunnel_log_filter() -> Result<PathBuf> {
|
|
Ok(tunnel_service_config()
|
|
.context("Failed to compute `tunnel_service_config` directory")?
|
|
.join("log-filter"))
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn smoke() {
|
|
for dir in [
|
|
tunnel_service_config(),
|
|
tunnel_service_logs(),
|
|
logs(),
|
|
runtime(),
|
|
session(),
|
|
settings(),
|
|
] {
|
|
let dir = dir.expect("should have gotten Some(path)");
|
|
assert!(
|
|
dir.components()
|
|
.any(|x| x == std::path::Component::Normal("dev.firezone.client".as_ref()))
|
|
);
|
|
}
|
|
}
|
|
}
|