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(headless-client): deprecate subcommands for now #4953

Merged
merged 35 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 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
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
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
0a7e678
remove unimplemented fn
ReactorScram May 10, 2024
9be70e2
feedback from review
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
45af33f
refactor(headless-client): deprecate subcommands for now
ReactorScram May 10, 2024
da81b64
typo
ReactorScram May 10, 2024
b356edf
remove inactionable comment
ReactorScram May 10, 2024
82529a6
Merge remote-tracking branch 'origin/main' into refactor/deprecate-su…
ReactorScram May 13, 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
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ services:
- type=registry,ref=us-east1-docker.pkg.dev/firezone-staging/cache/client:main
args:
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}
cap_add:
- NET_ADMIN
Expand Down
47 changes: 12 additions & 35 deletions rust/headless-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ const TOKEN_ENV_KEY: &str = "FIREZONE_TOKEN";
#[derive(clap::Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
// Needed to preserve CLI arg compatibility
// TODO: Remove
#[command(subcommand)]
command: Option<Cmd>,
_command: Option<Cmd>,

#[arg(
short = 'u',
Expand Down Expand Up @@ -104,22 +106,10 @@ struct Cli {
max_partition_time: Option<humantime::Duration>,
}

impl Cli {
fn command(&self) -> Cmd {
// Needed for backwards compatibility with old Docker images
self.command.unwrap_or(Cmd::Auto)
}
}

#[derive(clap::Subcommand, Clone, Copy)]
enum Cmd {
/// If there is a token on disk, run in standalone mode. Otherwise, run as an IPC service. This will be removed in a future version.
#[command(hide = true)]
Auto,
/// Listen for IPC connections and act as a privileged tunnel process for a GUI client
#[command(hide = true)]
IpcService,
/// Act as a CLI-only Client
Standalone,
}

Expand All @@ -139,7 +129,7 @@ pub enum IpcServerMsg {
TunnelReady,
}

pub fn run() -> Result<()> {
pub fn run_only_headless_client() -> Result<()> {
let mut cli = Cli::parse();

// Modifying the environment of a running process is unsafe. If any other
Expand Down Expand Up @@ -168,27 +158,14 @@ pub fn run() -> Result<()> {
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()?;
let (_shutdown_tx, shutdown_rx) = mpsc::channel(1);

match cli.command() {
Cmd::Auto => {
if let Some(token) = get_token(token_env_var, &cli)? {
run_standalone(cli, rt, &token)
} else {
imp::run_ipc_service(cli, rt, shutdown_rx)
}
}
Cmd::IpcService => imp::run_ipc_service(cli, rt, shutdown_rx),
Cmd::Standalone => {
let token = get_token(token_env_var, &cli)?.with_context(|| {
format!(
"Can't find the Firezone token in ${TOKEN_ENV_KEY} or in `{}`",
cli.token_path
)
})?;
run_standalone(cli, rt, &token)
}
}

let token = get_token(token_env_var, &cli)?.with_context(|| {
format!(
"Can't find the Firezone token in ${TOKEN_ENV_KEY} or in `{}`",
cli.token_path
)
})?;
run_standalone(cli, rt, &token)
}

// Allow dead code because Windows doesn't have an obvious SIGHUP equivalent
Expand Down
2 changes: 1 addition & 1 deletion rust/headless-client/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fn main() -> anyhow::Result<()> {
firezone_headless_client::run()
firezone_headless_client::run_only_headless_client()
}
Loading