mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
refactor(bin-shared): remove CommonArgs (#6068)
Closes #6025 It was only used in the Gateway, so we inline it there and remove `clap` as a dep for ~~that crate~~ `bin-shared`
This commit is contained in:
1
rust/Cargo.lock
generated
1
rust/Cargo.lock
generated
@@ -1782,7 +1782,6 @@ name = "firezone-bin-shared"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"connlib-shared",
|
||||
"futures",
|
||||
"ip-packet",
|
||||
|
||||
@@ -7,7 +7,6 @@ description = "Firezone-specific modules shared between binaries."
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.82"
|
||||
clap = { version = "4.5", features = ["derive", "env"] }
|
||||
connlib-shared = { workspace = true }
|
||||
futures = "0.3"
|
||||
ip-packet = { workspace = true }
|
||||
|
||||
@@ -4,12 +4,10 @@ mod tun_device_manager;
|
||||
#[cfg(target_os = "windows")]
|
||||
pub mod windows;
|
||||
|
||||
use clap::Args;
|
||||
use tracing_log::LogTracer;
|
||||
use tracing_subscriber::{
|
||||
fmt, prelude::__tracing_subscriber_SubscriberExt, EnvFilter, Layer, Registry,
|
||||
};
|
||||
use url::Url;
|
||||
|
||||
/// Bundle ID / App ID that the client uses to distinguish itself from other programs on the system
|
||||
///
|
||||
@@ -45,22 +43,3 @@ where
|
||||
tracing::subscriber::set_global_default(subscriber).expect("Could not set global default");
|
||||
LogTracer::init().unwrap();
|
||||
}
|
||||
|
||||
/// Arguments common to all Firezone CLI components.
|
||||
#[derive(Args, Clone)]
|
||||
pub struct CommonArgs {
|
||||
#[arg(
|
||||
short = 'u',
|
||||
long,
|
||||
hide = true,
|
||||
env = "FIREZONE_API_URL",
|
||||
default_value = "wss://api.firezone.dev"
|
||||
)]
|
||||
pub api_url: Url,
|
||||
/// Token generated by the portal to authorize websocket connection.
|
||||
#[arg(env = "FIREZONE_TOKEN")]
|
||||
pub token: String,
|
||||
/// Friendly name to display in the UI
|
||||
#[arg(short = 'n', long, env = "FIREZONE_NAME")]
|
||||
pub firezone_name: Option<String>,
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use anyhow::{Context, Result};
|
||||
use backoff::ExponentialBackoffBuilder;
|
||||
use clap::Parser;
|
||||
use connlib_shared::{get_user_agent, keypair, messages::Interface, LoginUrl, StaticSecret};
|
||||
use firezone_bin_shared::{setup_global_subscriber, CommonArgs, TunDeviceManager};
|
||||
use firezone_bin_shared::{setup_global_subscriber, TunDeviceManager};
|
||||
use firezone_tunnel::GatewayTunnel;
|
||||
|
||||
use futures::channel::mpsc;
|
||||
@@ -18,6 +18,7 @@ use std::sync::Arc;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tokio::signal::ctrl_c;
|
||||
use tracing_subscriber::layer;
|
||||
use url::Url;
|
||||
use uuid::Uuid;
|
||||
|
||||
mod eventloop;
|
||||
@@ -49,10 +50,10 @@ async fn try_main() -> Result<()> {
|
||||
|
||||
let (private_key, public_key) = keypair();
|
||||
let login = LoginUrl::gateway(
|
||||
cli.common.api_url,
|
||||
&SecretString::new(cli.common.token),
|
||||
cli.api_url,
|
||||
&SecretString::new(cli.token),
|
||||
firezone_id,
|
||||
cli.common.firezone_name,
|
||||
cli.firezone_name,
|
||||
public_key.to_bytes(),
|
||||
)?;
|
||||
|
||||
@@ -156,8 +157,20 @@ async fn update_device_task(
|
||||
#[derive(Parser)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
struct Cli {
|
||||
#[command(flatten)]
|
||||
common: CommonArgs,
|
||||
#[arg(
|
||||
short = 'u',
|
||||
long,
|
||||
hide = true,
|
||||
env = "FIREZONE_API_URL",
|
||||
default_value = "wss://api.firezone.dev"
|
||||
)]
|
||||
api_url: Url,
|
||||
/// Token generated by the portal to authorize websocket connection.
|
||||
#[arg(env = "FIREZONE_TOKEN")]
|
||||
token: String,
|
||||
/// Friendly name to display in the UI
|
||||
#[arg(short = 'n', long, env = "FIREZONE_NAME")]
|
||||
firezone_name: Option<String>,
|
||||
|
||||
#[command(flatten)]
|
||||
health_check: http_health_check::HealthCheckArgs,
|
||||
|
||||
Reference in New Issue
Block a user