Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f3aa92cd87 | ||
|
6654db26b7 |
@@ -20,7 +20,14 @@ class TailscaleFunnelPlugin(octoprint.plugin.StartupPlugin,
|
||||
##~~ StartupPlugin mixin
|
||||
|
||||
def on_after_startup(self):
|
||||
self._logger = self._plugin_manager.get_logger("octoprint_tailscale_funnel")
|
||||
# Ensure a valid logger; older OctoPrints don't provide PluginManager.get_logger
|
||||
try:
|
||||
import logging
|
||||
if getattr(self, "_logger", None) is None:
|
||||
self._logger = logging.getLogger("octoprint.plugins.tailscale_funnel")
|
||||
except Exception:
|
||||
pass
|
||||
if self._logger:
|
||||
self._logger.info("Tailscale Funnel Plugin started")
|
||||
self.tailscale_interface = TailscaleInterface(self._logger)
|
||||
self.status_monitor = StatusMonitor(self)
|
||||
|
@@ -74,14 +74,30 @@ class TailscaleInterface:
|
||||
"""
|
||||
Check if tailscale is installed
|
||||
"""
|
||||
result = self._run_command("which tailscale")
|
||||
return result["success"] and result["output"] != ""
|
||||
# Try PATH lookup, absolute path, or a sudo check that doesn't prompt
|
||||
candidates = [
|
||||
"command -v tailscale",
|
||||
"test -x /usr/bin/tailscale && echo /usr/bin/tailscale",
|
||||
"test -x /usr/local/bin/tailscale && echo /usr/local/bin/tailscale",
|
||||
]
|
||||
result = self._run_first_success(candidates)
|
||||
if result and result["success"] and result.get("output"):
|
||||
return True
|
||||
# Fallback: ask tailscale for version via sudo -n (non-interactive)
|
||||
version_check = self._run_command("sudo -n tailscale version")
|
||||
return version_check["success"]
|
||||
|
||||
def is_tailscale_running(self):
|
||||
"""
|
||||
Check if tailscale is running
|
||||
"""
|
||||
result = self._run_command("tailscale status --json")
|
||||
# Prefer non-interactive sudo to avoid PATH/permission issues
|
||||
result = self._run_first_success([
|
||||
"sudo -n tailscale status --json",
|
||||
"tailscale status --json",
|
||||
"/usr/bin/tailscale status --json",
|
||||
"/usr/local/bin/tailscale status --json",
|
||||
])
|
||||
return result["success"]
|
||||
|
||||
def get_tailscale_status(self):
|
||||
@@ -109,7 +125,12 @@ class TailscaleInterface:
|
||||
if not self.is_tailscale_installed():
|
||||
raise TailscaleNotInstalledError("Tailscale is not installed")
|
||||
|
||||
result = self._run_command("tailscale funnel status --json")
|
||||
result = self._run_first_success([
|
||||
"sudo -n tailscale funnel status --json",
|
||||
"tailscale funnel status --json",
|
||||
"/usr/bin/tailscale funnel status --json",
|
||||
"/usr/local/bin/tailscale funnel status --json",
|
||||
])
|
||||
if result["success"]:
|
||||
try:
|
||||
status = json.loads(result["output"]) if result["output"] else {}
|
||||
@@ -204,7 +225,12 @@ class TailscaleInterface:
|
||||
if not self.is_tailscale_installed():
|
||||
raise TailscaleNotInstalledError("Tailscale is not installed")
|
||||
|
||||
result = self._run_command("tailscale funnel status --json")
|
||||
result = self._run_first_success([
|
||||
"sudo -n tailscale funnel status --json",
|
||||
"tailscale funnel status --json",
|
||||
"/usr/bin/tailscale funnel status --json",
|
||||
"/usr/local/bin/tailscale funnel status --json",
|
||||
])
|
||||
if result["success"]:
|
||||
try:
|
||||
status = json.loads(result["output"]) if result["output"] else {}
|
||||
|
@@ -14,7 +14,7 @@ plugin_package = "octoprint_tailscale_funnel"
|
||||
plugin_name = "OctoPrint-Tailscale-Funnel"
|
||||
|
||||
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
|
||||
plugin_version = "0.1.2"
|
||||
plugin_version = "0.1.5"
|
||||
|
||||
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
|
||||
# module
|
||||
|
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"version": "0.1.2"
|
||||
"version": "0.1.5"
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user