From 20eab40ea806036b997978890041cca53c283eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Djema=C3=AF?= <53857555+SamyDjemai@users.noreply.github.com> Date: Wed, 13 Nov 2024 11:55:50 +0100 Subject: [PATCH 1/3] feat: add socket path option --- src/TailscaleManager.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/TailscaleManager.hs b/src/TailscaleManager.hs index 5513b25..430c0ea 100644 --- a/src/TailscaleManager.hs +++ b/src/TailscaleManager.hs @@ -28,6 +28,7 @@ data TailscaleManagerOptions { configFile :: FilePath , dryRun :: Bool , tailscaleCmd :: FilePath + , socketPath :: FilePath , interval :: Seconds , maxShrinkRatio :: Double } @@ -68,6 +69,11 @@ tsManagerOptions = <> help "Path to the tailscale executable" <> value "tailscale" <> showDefault) + <*> strOption (long "socket" + <> metavar "SOCKET_PATH" + <> help "Path to the tailscaled socket" + <> value "/var/run/tailscale/tailscaled.sock" + <> showDefault) <*> option auto (long "interval" <> metavar "INT" <> help "Interval (in seconds) between runs. 0 means exit after running once." @@ -128,7 +134,7 @@ runOnce options prevRoutes = do let shrinkage = shrinkRatio prevRoutes newRoutes if shrinkage < maxShrinkRatio options then do - invokeTailscale $ ["set", "--advertise-routes=" ++ intercalate "," (map show $ S.toList newRoutes)] ++ tsExtraArgs config + invokeTailscale $ ["--socket=" ++ socketPath options, "set", "--advertise-routes=" ++ intercalate "," (map show $ S.toList newRoutes)] ++ tsExtraArgs config logDelay return newRoutes else do From 32337cf3a7f8abe8b0728780813d7d17aed79805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Djema=C3=AF?= <53857555+SamyDjemai@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:05:03 +0100 Subject: [PATCH 2/3] docs: update help text in README.md --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 19fbeed..b831413 100644 --- a/README.md +++ b/README.md @@ -67,8 +67,9 @@ and update tailscale route advertisements accordingly. ## Commandline options ``` -Usage: tailscale-manager [--dryrun] [--tailscale PATH] - [--interval INT] [--max-shrink-ratio RATIO] +Usage: tailscale-manager [--dryrun] [--tailscale PATH] + [--socket SOCKET_PATH] [--interval INT] + [--max-shrink-ratio RATIO] Tailscale routes manager @@ -96,6 +97,8 @@ Available options: --dryrun Dryrun mode --tailscale PATH Path to the tailscale executable (default: "tailscale") + --socket SOCKET_PATH Path to the tailscaled socket + (default: "/var/run/tailscale/tailscaled.sock") --interval INT Interval (in seconds) between runs. 0 means exit after running once. (default: 0) --max-shrink-ratio RATIO Max allowed route shrinkage between consecutive runs, From 1aeffaa2c6ec5e3988ae242a201677488552f51c Mon Sep 17 00:00:00 2001 From: Benjamin Staffin Date: Tue, 3 Dec 2024 13:19:32 -0500 Subject: [PATCH 3/3] nixos module: Add socketPath option --- flake.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flake.nix b/flake.nix index d0d38fa..013ed41 100644 --- a/flake.nix +++ b/flake.nix @@ -100,6 +100,11 @@ default = 0.5; description = "How much route shrinkage is allowed between subsequent runs (between 0 and 1)"; }; + socketPath = mkOption { + type = types.path; + default = "/var/run/tailscale/tailscaled.sock"; + description = "Path to the tailscaled socket"; + }; }; config = mkIf cfg.enable { systemd.services.tailscale-manager = { @@ -112,6 +117,7 @@ ExecStart = lib.escapeShellArgs ( [ "${cfg.package}/bin/tailscale-manager" configFile "--tailscale=${config.services.tailscale.package}/bin/tailscale" + "--socket=${cfg.socketPath}" "--interval=${toString cfg.interval}" "--max-shrink-ratio=${toString cfg.maxShrinkRatio}" ] ++ lib.optional cfg.dryRun "--dryrun"