From f03a63910d22b8ca8362081ee80d57b3e25cdcc6 Mon Sep 17 00:00:00 2001 From: Will Norris Date: Fri, 9 Sep 2022 12:14:08 -0700 Subject: [PATCH] cmd/tailscale: add licenses link to web UI The `tailscale web` UI is the primary interface for Synology and Home Assistant users (and perhaps others), so is the logical place to put our open source license notices. I don't love adding things to what is currently a very minimal UI, but I'm not sure of a better option. Updates tailscale/corp#5780 Signed-off-by: Will Norris --- cmd/tailscale/cli/licenses.go | 17 ++++++++++------- cmd/tailscale/cli/web.go | 2 ++ cmd/tailscale/cli/web.html | 5 ++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/cmd/tailscale/cli/licenses.go b/cmd/tailscale/cli/licenses.go index 16b07d37d..65ac41aa1 100644 --- a/cmd/tailscale/cli/licenses.go +++ b/cmd/tailscale/cli/licenses.go @@ -19,24 +19,27 @@ var licensesCmd = &ffcli.Command{ Exec: runLicenses, } -func runLicenses(ctx context.Context, args []string) error { - var licenseURL string +// licensesURL returns the absolute URL containing open source license information for the current platform. +func licensesURL() string { switch runtime.GOOS { case "android": - licenseURL = "https://tailscale.com/licenses/android" + return "https://tailscale.com/licenses/android" case "darwin", "ios": - licenseURL = "https://tailscale.com/licenses/apple" + return "https://tailscale.com/licenses/apple" case "windows": - licenseURL = "https://tailscale.com/licenses/windows" + return "https://tailscale.com/licenses/windows" default: - licenseURL = "https://tailscale.com/licenses/tailscale" + return "https://tailscale.com/licenses/tailscale" } +} +func runLicenses(ctx context.Context, args []string) error { + licenses := licensesURL() outln(` Tailscale wouldn't be possible without the contributions of thousands of open source developers. To see the open source packages included in Tailscale and their respective license information, visit: - ` + licenseURL) + ` + licenses) return nil } diff --git a/cmd/tailscale/cli/web.go b/cmd/tailscale/cli/web.go index d53d1fda8..deef4b51d 100644 --- a/cmd/tailscale/cli/web.go +++ b/cmd/tailscale/cli/web.go @@ -59,6 +59,7 @@ type tmplData struct { IP string AdvertiseExitNode bool AdvertiseRoutes string + LicensesURL string } var webCmd = &ffcli.Command{ @@ -392,6 +393,7 @@ func webHandler(w http.ResponseWriter, r *http.Request) { Profile: profile, Status: st.BackendState, DeviceName: deviceName, + LicensesURL: licensesURL(), } exitNodeRouteV4 := netip.MustParsePrefix("0.0.0.0/0") exitNodeRouteV6 := netip.MustParsePrefix("::/0") diff --git a/cmd/tailscale/cli/web.html b/cmd/tailscale/cli/web.html index 429708cf8..76ff6f3eb 100644 --- a/cmd/tailscale/cli/web.html +++ b/cmd/tailscale/cli/web.html @@ -11,7 +11,7 @@ -
+
@@ -100,6 +100,9 @@ {{ end }}
+