I have several use cases for automation using Shortcuts on iOS / iPadOS that would require me to be able to detect if I am connected to my tailnet, if I am using an exit node or not, etc. I don’t see any support for this in the Tailscale app. Is this on the roadmap?
For anyone else that is interested, I was able to figure out a way to detect if Tailscale is active on my iPad via Shortcuts. Its the dirtiest of dirty hacks, but that’s what life is all about, right?
I have an app on my iPad called iSH, which runs a userspace x86 emulator to run a simple Linux environment. It is possible to run an SSH server in this environment, and you can connect to it locally if its running on a non-privileged port. You can also keep iSH running in the background to ensure that it doesn’t get garbage collected by iPadOS.
Then, I created a simple Python script (you can install Python inside of iSH) that attempts to connect to an IP on my tailnet (redacted below), and then either outputs “connceted” or nothing:
#!/usr/bin/python3
import subprocess
result = subprocess.run(['ping', '-c1', '-W1', '100.x.y.z'], capture_output=True)
if '1 packets received' in str(result.stdout):
print('connected')
Then, I created a Shortcut that uses the “run script over SSH” action to connect to the local SSH server, execute my script, and then fire the output into an if block that checks “if Shell Script Result has any value” to determine if I am connected to the tailnet.
Voila!