133 Commits
Author SHA1 Message Date
Will NorrisandWill Norris 55a3c6e2fe use semantic version tagging for docker images
we've never tagged stable releases, but should really do so.  This
change will cause our docker images to be tagged following typical
semver fashion... the initial `v1.0.0` release will be tagged `v1`,
`v1.0`, `v1.0.0`, and `latest`.

Updates #104

Signed-off-by: Will Norris <will@tailscale.com>
2024-05-08 16:33:21 -07:00
Will NorrisandWill Norris 187497a7ce add regexp.Match to template funcs
Add a "Match" template func, which uses regexp.MatchString to match a
value against a regular expression pattern.

Fixes #125

Signed-off-by: Will Norris <will@tailscale.com>
2024-05-07 12:18:56 -07:00
Dave AndersonandWill Norris 41e9dc91ec flake.nix: don't wait for network-online.target to start golink
golink is a tsnet service, and Tailscale's data plane is very good at monitoring for changes to network state and reacting to them. As such, it doesn't need to wait for network-online.target, it can start up concurrently with everything else and shorten the long pole of bootup.

Additionally, network-online.target is an antipattern in systemd that almost never means what people want it to mean. "Online" has no precise definition, and (I posit) almost never matches the ideal version of "online" that people have in their mind. It specifically does _not_ mean that the network functions, or that any particular flavor of connectivity exists. A machine behind a captive portal is "online" for the purposes of bootup, and so is a machine that got a DHCP lease but is having all its packets blackholed. Systemd has a whole page of documentation on "what does online even mean", because this is such a recurring point of confusion: https://systemd.io/NETWORK_ONLINE/

It is almost always wrong to depend on network-online.target, and I wish it was named slow-down-boot-for-no-reason.target, which is how most downstream programs use it.

</rant>, the point is, golink is a well-behaved service that reacts to connectivity changes on the fly (it has to, that's what tailscale does), and so can be started concurrently with networking and other services.
2024-04-25 09:20:28 -07:00
Will NorrisandWill Norris e2c7c78ae1 README: document permission model and grants
Updates #18
Updates #22
Updates #86
Updates #120

Signed-off-by: Will Norris <will@tailscale.com>
2024-04-02 11:39:56 -07:00
Chris PalmerandGitHub c66cbb8eca Protect save and update from CSRF (#117)
Also, fix a lint.

Fixes #116

Signed-off-by: Chris Palmer <cpalmer@tailscale.com>
2024-04-01 18:20:58 -07:00
Will NorrisandWill Norris 6c79b503e1 suggest long URL for new go links if peer exists
If you visit a non-existent go link, we render the home page and pre-
populate the "short" input with the name of the link, and autofocus the
"long" input so that you can simply paste a long URL and submit.

It is common (at least at Tailscale) to create go links that correspond
to the name of a device on the tailnet.  For example, go/who points to
http://who/.  With this change, when you visit a non-existent go link,
we check to see if a peer exists on the tailnet with that name, and if
so we suggest that as the long URL.

Signed-off-by: Will Norris <will@tailscale.com>
2024-03-15 14:42:43 -07:00
Will NorrisandWill Norris 0b61ec165e make https optional (but default to on)
Fixes #107

Signed-off-by: Will Norris <will@tailscale.com>
2024-03-04 11:26:20 -08:00
Will NorrisandWill Norris 544870985e enable new web ui for managing node
we've had support for enabling the web UI in tsnet apps from the
beginning, but I don't think we've ever actually used it anywhere.
some of the settings exposed through the web ui don't make a ton of
sense for tsnet, and might not even work.  But we're working toward
being able to enable the web ui on clients by default (with all of the
existing restrictions and ACL enforcement in place), and golink seemed
like a good playground to try it in a tsnet app.

Signed-off-by: Will Norris <will@tailscale.com>
2024-03-04 10:04:19 -08:00
Will NorrisandWill Norris b76177ac91 go.mod: use latest stable build of tailscale
We have fixed the issue in the corp repo that required us to use
pseudo-versions for the tailscale.com module here. So we can now switch
to the latest stable version.

Signed-off-by: Will Norris <will@tailscale.com>
2024-03-01 12:01:05 -08:00
Patrick O'DohertyandWill Norris 38cb010901 flake.nix: bump flake & build 1.22 go module
Resolve broken nix build due to us using Go 1.21 to build a 1.22 minimum
package.

Signed-off-by: Patrick O'Doherty <patrick@tailscale.com>
2024-02-28 17:00:00 -08:00
Will NorrisandWill Norris 9583fd9c67 go.mod: bump to tailscale 1.60.0
Commit 256ecd0e8f7cc7ccc1a20e3f2846f6e3cc336d02 was the latest actual
commit before tagging v1.60.0

Signed-off-by: Will Norris <will@tailscale.com>
2024-02-28 17:00:00 -08:00
PatkaandGitHub d9de913fb1 Replace deprecated Nix vendorSha256 call with vendorHash (#110)
Signed-off-by: Patka <patka@patka.dev>
2024-01-26 08:55:06 -08:00
Emil NikolovandDave Anderson b75983b637 service: explicitly depend on network-online.target
Signed-off-by: Emil Nikolov <emil.e.nikolov@gmail.com>
2024-01-20 23:22:21 -08:00
M. J. FrombergerandGitHub 5ee5a81391 go.mod: update tailscale.com to commit ca48db0d606d (#106)
Updates #96

Signed-off-by: M. J. Fromberger <fromberger@tailscale.com>
2024-01-11 08:37:35 -08:00
M. J. FrombergerandGitHub 4d96c55246 go.mod: update tailscale.com to v1.56.1 (#105)
Previous versions flag a potential security fix in the admin panel.

Updates #96

Signed-off-by: M. J. Fromberger <fromberger@tailscale.com>
2024-01-11 07:58:06 -08:00
Patrick O'DohertyandGitHub 311ede68ef golink: check for CertDomains before enabling HTTPS (#103)
Fixes https://github.com/tailscale/golink/issues/102

Ensure that we have CertDomains for the HTTPS listener before asking
tsnet to create one.

Signed-off-by: Patrick O'Doherty <patrick@tailscale.com>
2023-12-20 09:59:06 -08:00
Patrick O'DohertyandGitHub 3f822b66e7 golink: listen on HTTPS and redirect HTTP traffic (#99)
golink: listen on HTTPS and redirect HTTP traffic

Updates tailscale/golink#9
Fixes tailscale/golink#29

On tailnets with HTTPS enabled golink will serve the primary endpoints via
HTTPS. With HTTPS enabled golink will respond to HTTP traffic with a 
separate redirectHandler which redirects requests to their HTTPS equivalent.

Update documented examples of `curl` to include the `-L` flog to follow these
redirects if present. 

Add a HTTPS section to the README documenting all of the above.

Signed-off-by: Patrick O'Doherty <patrick@tailscale.com>
2023-12-18 14:14:52 -08:00
Will NorrisandWill Norris 0abea01a93 golink: align on tailscale.com/cap naming convention
Signed-off-by: Will Norris <will@tailscale.com>
2023-12-13 09:09:57 -08:00
Will NorrisandWill Norris c9212a47de .github: update actions in docker workflow
Signed-off-by: Will Norris <will@tailscale.com>
2023-11-15 08:26:40 -08:00
Will NorrisandWill Norris c4bacfd78c .github: run yaml files through prettier
Signed-off-by: Will Norris <will@tailscale.com>
2023-11-15 08:26:40 -08:00
Will NorrisandWill Norris 7f89e2e42c golink: set HTTP status after Location header
I didn't think the order mattered (as long as none of the response body
had been written), but I guess I was wrong. Currently, it's returning
the 302 status, but no Location header. And tests, at least some of
which should be passing through this full code path, are passing. I'll
look into adding better testing later, but for now this fixes the
immediate issue.

Updates #91

Signed-off-by: Will Norris <will@tailscale.com>
2023-11-14 21:42:41 -08:00
Will NorrisandWill Norris 7db43e2d37 golink: use new serveHandler with tsnet
In 46ed42f, I mistakenly only attached the serveHandler to the dev
listener, but not tsnet.

Fixes #91

Signed-off-by: Will Norris <will@tailscale.com>
2023-11-14 20:18:12 -08:00
Will NorrisandWill Norris 46ed42fc5d golink: don't modify URL path when resolving link
Both http.ServeMux as well as the http.Redirect method pass the request
URL through `cleanPath` which, among other things, collapses double
slashes `//` to a single slash `/`. Most of the time this is fine, since
most servers treat those as identical anyway. But some destination
servers need the original path unmodified. Since we're just redirecting,
we don't need to be concerned with the additional benefits of
`cleanPath` such as eliminating `../` path components, since that is the
responsibility of the destination server to clean if needed.

This change adds a separate root http.Handler for golink requests. It
still uses http.ServeMux for internal endpoints, but serves golinks
directly without passing the request through ServeMux. Additionally,
this sets the redirect status and Location header directly rather than
calling http.Redirect, since that also modifies the URL it is given.

Fixes #89

Signed-off-by: Will Norris <will@tailscale.com>
2023-11-14 08:38:17 -08:00
Will NorrisandWill Norris 2ff7d040f8 add support for golink peer capability
The "tailscale.com/golink" peercap includes a single "admin" bool field.
When set, this grants the user the ability to edit all links stored in
the system.

Update currentUser to return a simple user struct instead of just a bare
username. Rename checkLinkOwnership to canEditLink and change to a bool
return value.

Signed-off-by: Will Norris <will@tailscale.com>
2023-10-30 20:29:58 -07:00
Will NorrisandWill Norris 97cee318a6 go.mod: bump to tailscale 1.52.0
Technically, this is one commit before the 1.52.0 tag to keep it a
pseudo-version.

Signed-off-by: Will Norris <will@tailscale.com>
2023-10-30 20:29:58 -07:00
Will NorrisandWill Norris 3d62a353ac Dockerfile: stop using chainguard go image
Chainguard is no longer allowing free users to use specific versions of
images like go (instead, having to always use "latest"). So instead, we
will create our own build image by installing the needed packages on top
of the wolfi-base image.

This is one of the recommended approaches in their migration guide:
https://www.chainguard.dev/unchained/a-guide-on-how-to-use-chainguard-images-for-public-catalog-tier-users

Fixes #82

Signed-off-by: Will Norris <will@tailscale.com>
2023-07-14 12:17:24 -07:00
Marco HofstetterandWill Norris 843e615dbf remove unused disabled input fields in form
The detail page of a link only displays the form if the link is editable
for the logged in user.

Therefore, it's not necessary to disable the input fields within the
form if the link isn't editable.

Signed-off-by: Marco Hofstetter <marco.hofstetter@bluewin.ch>
2023-06-26 08:13:54 -07:00
Marco HofstetterandWill Norris e6a9c75f4f support tagged-devices in userExists in devmode
Even in dev mode, the user `tagged-devices` should not be
reported as existing user.

This allows editing & deleting links owned by `taggged-devices`
in dev mode.

Signed-off-by: Marco Hofstetter <marco.hofstetter@bluewin.ch>
2023-06-21 17:36:56 -07:00
Marco HofstetterandWill Norris 2b98aed2ea allow deletion of unowned links
It should be possible to delete links owned by non-existing users
(tagged-devices or deleted) in the same ways as it's possible
to edit these links.

Signed-off-by: Marco Hofstetter <marco.hofstetter@bluewin.ch>
2023-06-21 17:36:56 -07:00
Will NorrisandWill Norris a762273463 retain query string from original request
When resolving a go link, combine the query string parameters from the
request and long URL.

Updates #77

Signed-off-by: Will Norris <will@tailscale.com>
2023-05-16 10:17:35 -07:00
Will NorrisandWill Norris ae5d8c9b6c pass url.URL rather than string
return a *url.URL value from expandLink rather than a string, and both
accept and return a *url.URL value from resolveLink rather than a
string. These are both unexported funcs, so this has no changes to the
current behavior. It does prevent a few unnecessary conversions back and
forth between url.URL and string values, and will make it simpler to
retain request query strings.

Updates #77

Signed-off-by: Will Norris <will@tailscale.com>
2023-05-16 10:17:35 -07:00
Will NorrisandWill Norris f00de63b45 parse link short name just from request path
Previously, we were parsing from r.RequestURI, which includes both the
path and query string.  This causes problem for requests like go/who?q
which try to lookup a link named "who?q" rather than "who" (see #77).

For now, this just ignores the request query string. Eventually we
should probably retain the query string, but this begins by parsing out
the short name properly.

Updates #77

Signed-off-by: Will Norris <will@tailscale.com>
2023-05-16 10:17:35 -07:00
Kristoffer DalbyandWill Norris 3ec5bd9693 nix: update nix dependencies
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
2023-05-02 11:40:12 -07:00
Kristoffer DalbyandWill Norris 3eb57635ae nix: update flake hash to mirror go.mod
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
2023-05-02 11:40:12 -07:00
Will NorrisandWill Norris 41060ba068 go.mod: bump tailscale.com version
bump version again, back to the latest commit on main, rather than the
latest released version. Otherwise, this causes issues in tailscale's
corp repo (sadly).

Signed-off-by: Will Norris <will@tailscale.com>
2023-05-01 21:01:05 -07:00
Will NorrisandWill Norris ec2a3e94c6 go.mod: bump tailscale.com version
Signed-off-by: Will Norris <will@tailscale.com>
2023-05-01 20:55:34 -07:00
Will NorrisandWill Norris 61a86749e3 allow links to be saved without known owner
If the current user can't be determined (either because of a legitimate
error within the localapi client, or the user is coming through a subnet
router and doesn't have a Tailscale IP address), and the
-allow-unknown-users flag is set, then go ahead and save new links
without an owner.

By saving links without an owner, these unknown users can continue to
modify the link, and actual Tailscale users can take ownership. Once the
link is owned, it can no longer be modified by anyone other than the
owner.

Links that use the current user by having `{{ .User }}` in their long
URL cannot be resolved by unknown users and will return an error.

Fixes #60

Signed-off-by: Will Norris <will@tailscale.com>
2023-05-01 20:55:34 -07:00
c7ac33d04c golink: add support for deleting links
To delete a link, go to its page in `.detail` and click on the "Delete"
button. Stats for the deleted link are removed as well.

Co-authored-by: Will Norris <will@tailscale.com>
Signed-off-by: Gabriel Wong <gabriel@bifrost.ai>
Signed-off-by: Will Norris <will@tailscale.com>
2023-05-01 17:34:41 -07:00
Will NorrisandWill Norris 132a396390 update colors and tweak detail layout
Signed-off-by: Will Norris <will@tailscale.com>
2023-05-01 17:34:41 -07:00
Will NorrisandWill Norris 31b1ce1ac1 add tests for serve methods
Also check error returned from tmpl.Execute. Refactor currentUser to
make the logic a little simpler, and make it a package var for easier
testing.

Signed-off-by: Will Norris <will@tailscale.com>
2023-05-01 12:22:42 -07:00
Will NorrisandWill Norris b9fdc2dcab golink: allow -resolve-from-backup to resolve alias links
It's not uncommon to have multiple links pointing to the same
destination, for example to handle different spellings of a word or
because different people created them at different times.

A common best practice is to select one as the "primary" link and point
the others to that link as "aliases".  This change updates resolveLink
to follow those aliases so that the final destination is returned when
using `golink -resolve-from-backup`.

Signed-off-by: Will Norris <will@tailscale.com>
2023-03-29 13:55:38 -07:00
Maisem AliandGitHub 7fa6e009f6 golink: set hostinfo.Package to "golink" (#64)
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-02-28 15:51:38 -08:00
Maisem AliandGitHub acd564144f go.mod: bump tailscale.com from main (#67)
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-02-28 15:44:50 -08:00
Kristoffer DalbyandGitHub 9bf1f0a11e nix: update go to 1.20 in flake.nix (#66) 2023-02-28 18:39:06 +01:00
Kristoffer DalbyandGitHub d0a6324e2f nix: add script to update flake vendor hash (#65) 2023-02-28 18:35:14 +01:00
Felix HeilmeyerandWill Norris 0d1e616fe9 db: add mutex to fix http errors during stats save
Signed-off-by: Felix Heilmeyer <code@fehe.eu>
2023-02-12 20:00:51 -08:00
Will NorrisandWill Norris 7fd2d35ba6 include current user resolving link in expandEnv
Add "User" to the expansion environment for links.  The intent here it
support personalized go links such as:

go/mycal => https://calendar.google.com/calendar/embed?src={{.User}}

That's not a terribly interesting example, but there are others I intend
to use internally.

Signed-off-by: Will Norris <will@tailscale.com>
2023-02-08 16:24:36 -08:00
Will NorrisandWill Norris 9c46bb3412 stats: return early if no stats to write
Signed-off-by: Will Norris <will@tailscale.com>
2023-02-08 14:51:00 -08:00
Will NorrisandWill Norris 3c4fb78866 css: responsive design for /.all page
Signed-off-by: Will Norris <will@tailscale.com>
2023-02-07 16:08:19 -08:00
Gabriel WongandWill Norris 340adb143b golink: add .all page to display all existing links
Signed-off-by: Gabriel Wong <gabriel@bifrost.ai>
2023-02-07 16:08:19 -08:00