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

chore(headless-client): add a placeholder IPC server for Windows #4940

Closed
wants to merge 54 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
e742f80
proof of concept for installing a system service with WiX
ReactorScram May 7, 2024
c83174f
this one gets the service to run, but it doesn't respond, so Windows …
ReactorScram May 7, 2024
6d36d31
Merge remote-tracking branch 'origin/main' into chore/windows-service…
ReactorScram May 7, 2024
abc9953
fmt
ReactorScram May 7, 2024
e615f93
this one starts and stops properly
ReactorScram May 7, 2024
b8a8670
fix Linux build
ReactorScram May 7, 2024
4011ca3
Merge remote-tracking branch 'origin/main' into chore/windows-service…
ReactorScram May 7, 2024
618c941
refactor(gui-client): move `known_dirs` module into `headless-client`
ReactorScram May 7, 2024
442e01c
fix Linux build
ReactorScram May 7, 2024
7e17b56
Merge branch 'refactor/move-known-dirs' into chore/windows-service-poc
ReactorScram May 8, 2024
8585e2d
Merge branch 'chore/windows-service-poc' of github.com:firezone/firez…
ReactorScram May 8, 2024
679a9da
DRY log dirs
ReactorScram May 8, 2024
606469f
typo
ReactorScram May 8, 2024
12edbc1
fix logging
ReactorScram May 8, 2024
0c77e34
fix stopping, remove debug file
ReactorScram May 8, 2024
9bc5d5c
opt in to receive shutdown signals
ReactorScram May 8, 2024
6083819
do a test install of the MSI
ReactorScram May 8, 2024
83f807d
fix(windows-client): clear Firezone-specific DNS rules at startup
ReactorScram May 8, 2024
0a35424
/passive wasn't working in CI
ReactorScram May 8, 2024
d5f58a6
try to fix CI
ReactorScram May 8, 2024
900737b
you gotta escape those deadly forward slashes
ReactorScram May 8, 2024
0f9de54
fix test checklist
ReactorScram May 8, 2024
c654e35
Merge branch 'chore/windows-service-poc' into fix/windows-dns-4899
ReactorScram May 8, 2024
8e7266e
refactor(headless-client): remove auto token detection
ReactorScram May 8, 2024
613f3b5
Merge remote-tracking branch 'origin/main' into refactor/remove-auto-ipc
ReactorScram May 8, 2024
8d44601
fix Linux build
ReactorScram May 8, 2024
2cd8e57
see if we can get rid of linux-client. If not I have a backup plan
ReactorScram May 8, 2024
470eb1c
Merge remote-tracking branch 'origin/main' into chore/windows-service…
ReactorScram May 9, 2024
ed5ee6a
Merge branch 'chore/windows-service-poc' into fix/windows-dns-4899
ReactorScram May 9, 2024
2c62195
refactor(headless-client): remove "linux-client" alias
ReactorScram May 9, 2024
c2a272b
Merge remote-tracking branch 'origin/fix/windows-dns-4899' into refac…
ReactorScram May 9, 2024
d8de2f8
Merge branch 'refactor/remove-linux-client' into refactor/remove-auto…
ReactorScram May 9, 2024
2ebc816
revert removing linux-client, that'll be another PR independent of this
ReactorScram May 9, 2024
97bb877
minimize pub
ReactorScram May 9, 2024
940f5b7
revert a bunch of stuff
ReactorScram May 9, 2024
5f9d7fe
minimize public interfaces
ReactorScram May 9, 2024
6f4b09a
Merge branch 'refactor/remove-auto-ipc' of github.com:firezone/firezo…
ReactorScram May 9, 2024
2907263
fix systemd file
ReactorScram May 9, 2024
1d8c391
try to fix docker
ReactorScram May 9, 2024
0f5d2c2
accidentally copied this thought from the other PR
ReactorScram May 9, 2024
a4a3ecc
chore(headless-client): add a placeholder IPC server in Windows
ReactorScram May 9, 2024
c8d1945
improve error messages
ReactorScram May 9, 2024
c8f9d27
Merge remote-tracking branch 'origin/refactor/remove-auto-ipc' into c…
ReactorScram May 9, 2024
e96969a
try to detangle the entry points a bit
ReactorScram May 9, 2024
91b2c10
Merge branch 'main' into chore/windows-service-poc
ReactorScram May 9, 2024
dc9eb42
Merge branch 'chore/windows-service-poc' into fix/windows-dns-4899
ReactorScram May 9, 2024
4e7f52e
Merge branch 'fix/windows-dns-4899' into refactor/remove-auto-ipc
ReactorScram May 9, 2024
0a7e678
remove unimplemented fn
ReactorScram May 10, 2024
9be70e2
feedback from review
ReactorScram May 10, 2024
c5ce31f
Merge remote-tracking branch 'origin/refactor/remove-auto-ipc' into c…
ReactorScram May 10, 2024
733afa0
Merge branch 'main' into chore/windows-service-poc
ReactorScram May 10, 2024
19a03c2
Merge branch 'chore/windows-service-poc' into fix/windows-dns-4899
ReactorScram May 10, 2024
988beed
Merge branch 'fix/windows-dns-4899' into refactor/remove-auto-ipc
ReactorScram May 10, 2024
a72ef20
Merge branch 'refactor/remove-auto-ipc' into chore/windows-ipc-service
ReactorScram May 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ services:
PACKAGE: firezone-headless-client
# Add "standalone" to the command here once PR $4604 merges
image: ${CLIENT_IMAGE:-us-east1-docker.pkg.dev/firezone-staging/firezone/dev/client}:${CLIENT_TAG:-main}
command: ["firezone-linux-client", "standalone"]
cap_add:
- NET_ADMIN
sysctls:
Expand Down
15 changes: 15 additions & 0 deletions rust/Cargo.lock

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

2 changes: 1 addition & 1 deletion rust/gui-client/docs/intended_behavior.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Best performed on a clean VM
1. Export the logs
1. Expect the zip file to start with "firezone_logs_"
1. Expect `zipinfo` to show a single directory in the root of the zip, to prevent zip bombing
1. Expect two subdirectories in the zip, "connlib", and "app", each with 3 files, totalling 6 files
1. Expect two subdirectories in the zip, "connlib", and "app", with 3 and 2 files respectively, totalling 5 files

## Settings tab

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Environment="LOG_DIR=/var/log/dev.firezone.client"
Environment="RUST_LOG=info"
EnvironmentFile="/etc/default/firezone-client-ipc"

ExecStart=firezone-client-ipc
ExecStart=firezone-client-ipc ipc-service
Type=notify
# Unfortunately we may need root to control DNS
User=root
Expand Down
2 changes: 1 addition & 1 deletion rust/gui-client/src-tauri/src/client/debug_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn run(cmd: Cmd) -> Result<()> {
}

fn check_for_updates() -> Result<()> {
client::logging::debug_command_setup()?;
firezone_headless_client::debug_command_setup()?;

let rt = tokio::runtime::Runtime::new().unwrap();
let version = rt.block_on(client::updates::check())?;
Expand Down
37 changes: 10 additions & 27 deletions rust/gui-client/src-tauri/src/client/deep_link/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Server {
let mut server_options = named_pipe::ServerOptions::new();
server_options.first_pipe_instance(true);

// This will allow non-admin clients to connect to us even if we're running as admin
// This will allow non-admin clients to connect to us even if we're running as admin. TODO: Remove after process separation is done
let mut sd = WinSec::SECURITY_DESCRIPTOR::default();
let psd = WinSec::PSECURITY_DESCRIPTOR(&mut sd as *mut _ as *mut c_void);
// SAFETY: Unsafe needed to call Win32 API. There shouldn't be any threading
Expand All @@ -58,15 +58,13 @@ impl Server {
bInheritHandle: false.into(),
};

// TODO: On the IPC branch I found that this will cause prefix issues
// with other named pipes. Change it.
let path = named_pipe_path(BUNDLE_ID);
let sa_ptr = &mut sa as *mut _ as *mut c_void;
// SAFETY: Unsafe needed to call Win32 API. There shouldn't be any threading
// or lifetime problems because we only pass pointers to our local vars to
// Win32, and Win32 shouldn't save them anywhere.
let server = unsafe { server_options.create_with_security_attributes_raw(path, sa_ptr) }
.map_err(|_| super::Error::CantListen)?;
let server =
unsafe { server_options.create_with_security_attributes_raw(pipe_path(), sa_ptr) }
.map_err(|_| super::Error::CantListen)?;

tracing::debug!("server is bound");
Ok(Server { inner: server })
Expand Down Expand Up @@ -101,7 +99,7 @@ impl Server {

/// Open a deep link by sending it to the already-running instance of the app
pub async fn open(url: &url::Url) -> Result<()> {
let path = named_pipe_path(BUNDLE_ID);
let path = pipe_path();
let mut client = named_pipe::ClientOptions::new()
.open(path)
.context("Couldn't connect to named pipe server")?;
Expand All @@ -112,6 +110,11 @@ pub async fn open(url: &url::Url) -> Result<()> {
Ok(())
}

/// Named pipe for our deep links
fn pipe_path() -> String {
firezone_headless_client::imp::named_pipe_path(format!("{BUNDLE_ID}.deep_link"))
}

/// Registers the current exe as the handler for our deep link scheme.
///
/// This is copied almost verbatim from tauri-plugin-deep-link's `register` fn, with an improvement
Expand Down Expand Up @@ -147,23 +150,3 @@ fn set_registry_values(id: &str, exe: &str) -> Result<(), io::Error> {

Ok(())
}

/// Returns a valid name for a Windows named pipe
///
/// # Arguments
///
/// * `id` - BUNDLE_ID, e.g. `dev.firezone.client`
fn named_pipe_path(id: &str) -> String {
format!(r"\\.\pipe\{}", id)
}

#[cfg(test)]
mod tests {
#[test]
fn named_pipe_path() {
assert_eq!(
super::named_pipe_path("dev.firezone.client"),
r"\\.\pipe\dev.firezone.client"
);
}
}
13 changes: 0 additions & 13 deletions rust/gui-client/src-tauri/src/client/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ pub(crate) enum Error {
#[error("Log filter couldn't be parsed")]
Parse(#[from] tracing_subscriber::filter::ParseError),
#[error(transparent)]
SetGlobalDefault(#[from] tracing::subscriber::SetGlobalDefaultError),
#[error(transparent)]
SetLogger(#[from] tracing_log::log_tracer::SetLoggerError),
}

Expand Down Expand Up @@ -73,17 +71,6 @@ pub(crate) fn setup(log_filter: &str) -> Result<Handles> {
})
}

/// Sets up logging for stderr only, with INFO level by default
pub(crate) fn debug_command_setup() -> Result<(), Error> {
let filter = EnvFilter::builder()
.with_default_directive(tracing_subscriber::filter::LevelFilter::INFO.into())
.from_env_lossy();
let layer = fmt::layer().with_filter(filter);
let subscriber = Registry::default().with(layer);
set_global_default(subscriber)?;
Ok(())
}

#[tauri::command]
pub(crate) async fn clear_logs() -> StdResult<(), String> {
clear_logs_inner().await.map_err(|e| e.to_string())
Expand Down
9 changes: 8 additions & 1 deletion rust/gui-client/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@
"icons/icon.png"
],
"publisher": "Firezone",
"shortDescription": "Firezone"
"shortDescription": "Firezone",
"windows": {
"wix": {
"componentRefs": ["FirezoneClientIpcService"],
"fragmentPaths": ["./win_files/service.wxs"],
"template": "./win_files/main.wxs"
}
}
},
"security": {
"csp": null
Expand Down