mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
wip(windows): impl get_host_name (#3089)
Resolves #3082 I can remove the debug subcommand before merging. I just wanted to confirm it gets my laptop's hostname. connlib already has an indirect dependency on `hostname` via Hickory, so I just used that. 
This commit is contained in:
2
rust/Cargo.lock
generated
2
rust/Cargo.lock
generated
@@ -1198,6 +1198,7 @@ dependencies = [
|
||||
"futures",
|
||||
"futures-util",
|
||||
"hickory-resolver",
|
||||
"hostname",
|
||||
"ip_network",
|
||||
"libc",
|
||||
"log",
|
||||
@@ -2078,6 +2079,7 @@ dependencies = [
|
||||
"connlib-client-shared",
|
||||
"connlib-shared",
|
||||
"firezone-cli-utils",
|
||||
"hostname",
|
||||
"ipconfig",
|
||||
"keyring",
|
||||
"ring 0.17.7",
|
||||
|
||||
@@ -15,6 +15,8 @@ boringtun = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
futures = { version = "0.3", default-features = false, features = ["std", "async-await", "executor"] }
|
||||
futures-util = { version = "0.3", default-features = false, features = ["std", "async-await", "async-await-macro"] }
|
||||
# Hickory already depends on `hostname` so this isn't new
|
||||
hostname = "0.3.1"
|
||||
ip_network = { version = "0.4", default-features = false, features = ["serde"] }
|
||||
os_info = { version = "3", default-features = false }
|
||||
parking_lot = "0.12"
|
||||
|
||||
@@ -153,10 +153,10 @@ fn get_host_name() -> Option<String> {
|
||||
String::from_utf8(buf.split(|c| *c == 0).next()?.to_vec()).ok()
|
||||
}
|
||||
|
||||
/// Returns the hostname, or `None` if it's not valid UTF-8
|
||||
#[cfg(target_os = "windows")]
|
||||
fn get_host_name() -> Option<String> {
|
||||
// FIXME: windows
|
||||
None
|
||||
hostname::get().ok().and_then(|x| x.into_string().ok())
|
||||
}
|
||||
|
||||
fn set_ws_scheme(url: &mut Url) -> Result<()> {
|
||||
|
||||
@@ -18,6 +18,8 @@ clap = { version = "4.4", features = ["derive", "env"] }
|
||||
connlib-client-shared = { workspace = true }
|
||||
connlib-shared = { workspace = true }
|
||||
firezone-cli-utils = { workspace = true }
|
||||
# Same crate Hickory uses
|
||||
hostname = "0.3.1"
|
||||
# This is the same crate hickory uses to get system resolvers
|
||||
ipconfig = "0.3.2"
|
||||
keyring = "2.0.5"
|
||||
|
||||
@@ -66,6 +66,7 @@ pub(crate) fn run() -> Result<()> {
|
||||
println!("debug");
|
||||
Ok(())
|
||||
}
|
||||
Some(Cmd::DebugHostname) => debug_commands::hostname(),
|
||||
Some(Cmd::DebugPipeServer) => debug_commands::pipe_server(),
|
||||
Some(Cmd::DebugWintun) => debug_commands::wintun(cli),
|
||||
// If we already tried to elevate ourselves, don't try again
|
||||
|
||||
@@ -12,6 +12,7 @@ pub struct Cli {
|
||||
#[derive(clap::Subcommand)]
|
||||
pub enum CliCommands {
|
||||
Debug,
|
||||
DebugHostname,
|
||||
DebugPipeServer,
|
||||
DebugWintun,
|
||||
Elevated,
|
||||
|
||||
@@ -8,6 +8,14 @@ use tokio::runtime::Runtime;
|
||||
// TODO: In tauri-plugin-deep-link, this is the identifier in tauri.conf.json
|
||||
const PIPE_NAME: &str = "dev.firezone.client";
|
||||
|
||||
pub fn hostname() -> Result<()> {
|
||||
println!(
|
||||
"{:?}",
|
||||
hostname::get().ok().and_then(|x| x.into_string().ok())
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn open_deep_link(path: &url::Url) -> Result<()> {
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user