From 6b7188a0ff9ad6e295229095146da24eca657fef Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 11 Jul 2024 21:29:44 +0300 Subject: [PATCH] feat(menu): allow overriding admin console URL via TAILRAY_ADMIN_URL --- README.md | 30 ++++++++++++++++++++++++++---- src/tray/menu.rs | 5 ++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 296e81f..d67a3c4 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,35 @@ A modern and fast implementation of tailscale-systray in Rust. -> [!NOTE] Tailray is a work in progress. Most things don't work, or work in a -> degraded state. If you find bugs that are not aggressed in the issues tab, -> feel free to create a new issue or a pull request! You are advi + + +## Usage + +> [!NOTE] +> Tailray is a work in progress. Most things don't work, or work in a +> degraded state. If you find bugs that are not addressed in the issues tab, +> feel free to create a new issue or a pull request! + + + +Tailray requires Tailscaled to be up and running. On Linux systems, you can +check its status with `systemctl status tailscaled`. + +After you confirm that Tailscale is running, and that you are authenticated run +`tailray` from a terminal or consider writing a systemd service for it. + +### Overriding Admin Console URL + +Tailray will assume `https://login.tailscale.com/admin/machines` to be the Admin +Console URL by default. You may override this URL by setting `TAILRAY_ADMIN_URL` +to an URL of your choice. ## Hacking -Simply run `nix develop` in the project root. +The recommended way of building Tailray is with the Nix build tool. You may run +`nix develop` in the repository to enter a devShell with the necessary +dependencies. Direnv users may also use `direnv allow` to let direnv handle +their shell environment. ## License diff --git a/src/tray/menu.rs b/src/tray/menu.rs index c5bb719..f74e0b9 100644 --- a/src/tray/menu.rs +++ b/src/tray/menu.rs @@ -220,7 +220,10 @@ impl Tray for SysTray { StandardItem { label: "Admin Consoleā€¦".into(), activate: Box::new(|_| { - if let Err(e) = open::that("https://login.tailscale.com/admin/machines") { + let admin_url = std::env::var("TAILRAY_ADMIN_URL").unwrap_or_else(|_| { + "https://login.tailscale.com/admin/machines".to_string() + }); + if let Err(e) = open::that(admin_url.as_str()) { eprintln!("failed to open admin console: {}", e); } }),