Module: Portless::Share::Tailscale
- Defined in:
- lib/portless/share/tailscale.rb
Overview
Expose the local app on your tailnet (serve) or publicly (funnel) via
the tailscale CLI. Returns { mode:, url: } or nil. EXPERIMENTAL. Mirrors
portless's tailscale.ts.
Class Method Summary collapse
-
.magic_dns_url ⇒ Object
The machine's MagicDNS name → its tailnet HTTPS URL.
- .start(backend_port:, funnel: false) ⇒ Object
- .stop(handle) ⇒ Object
Class Method Details
.magic_dns_url ⇒ Object
The machine's MagicDNS name → its tailnet HTTPS URL.
36 37 38 39 40 41 42 |
# File 'lib/portless/share/tailscale.rb', line 36 def magic_dns_url json = JSON.parse(`tailscale status --json 2>/dev/null`) dns = json.dig("Self", "DNSName").to_s.chomp(".") dns.empty? ? nil : "https://#{dns}" rescue StandardError nil end |
.start(backend_port:, funnel: false) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/portless/share/tailscale.rb', line 13 def start(backend_port:, funnel: false) return nil unless Portless.which("tailscale") mode = funnel ? "funnel" : "serve" ok = system("tailscale", mode, "--bg", "--https=443", "http://127.0.0.1:#{backend_port}", out: File::NULL, err: File::NULL) return nil unless ok url = magic_dns_url url ? { mode: mode, url: url } : nil rescue StandardError nil end |