Skip to content

cmd/tailcat: serve Unix-domain sockets - #104

Merged
bradfitz merged 1 commit into
tailscale:mainfrom
atirna:feat/serve-unix-sockets
Nov 22, 2026
Merged

bradfitz merged 1 commit into
tailscale:mainfrom
atirna:feat/serve-unix-sockets

Conversation

@atirna

@atirna atirna commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add tailcat serve --unix-socket=<path> for a local Unix-domain stream socket.
  • Each inbound tailcat stream gets a fresh connection to that socket on port 1, leaving the socket's existing filesystem permissions unchanged.

Why

This lets a local Unix-socket service be reached directly without first exposing it on a TCP port.

Testing

  • Before: current main has no --unix-socket serve option.
  • After: go test ./cmd/tailcat -run '^TestServeUnixSocket$' -count=1

Fixes #93

Comment thread README.md Resolved
@atirna
atirna force-pushed the feat/serve-unix-sockets branch from 9f8c01b to be4b69e Compare September 19, 2026 20:16
@atirna

atirna commented Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

added: --unix-socket now takes an optional ,port suffix (port 1 stays the default), the packet filter and dispatch key on the parsed port, and the README shows the forward command for reaching a custom port. ,8022 with an empty pathname is rejected at startup.

@atirna
atirna force-pushed the feat/serve-unix-sockets branch 2 times, most recently from b7ac680 to 07dd1dd Compare September 24, 2026 18:12
A serve spec item starting with "/" or "unix:" now names a local
Unix-domain stream socket to proxy connections to. Given alone, as in
"tailcat serve /run/git-annex/socket", it serves every port not
otherwise served, like the exec service, so clients reach it with a
plain "tailcat <tc-addr>" and never need a port number. As a port
mapping target, as in "8022:/run/app.sock", it serves just that port,
which allows several sockets or a socket alongside other services.

Items are still classified purely lexically, and the grammar is now
written down in parsePortSet's doc comment: a service name, then a
socket, then a "port:target" mapping split at the first colon, then a
port or range. Any target starting with "unix:" is a socket. A
catch-all socket can't be combined with another, or with all, exec,
or exit-node, since those claim every port too. After parsing, the
server checks that each socket exists (and on Unix that it is a
socket) and refuses to start otherwise. tailcat doesn't create the
socket or change its permissions.

This is PR tailscale#104 reworked by Brad: it replaces the PR's --unix-socket
flag and its ",port" suffix with socket targets in the serve spec.

Fixes tailscale#93
Fixes tailscale#104

Co-authored-by: Brad Fitzpatrick <bradfitz@tailscale.com>
@bradfitz
bradfitz force-pushed the feat/serve-unix-sockets branch from 07dd1dd to 54017f4 Compare November 22, 2026 19:27
@bradfitz

Copy link
Copy Markdown
Member

I've changed the UX of this to match some of the other modes more closely. (the comma-separated thing was kinda weird considering we already had the portspec thing)

@bradfitz
bradfitz merged commit ecdbd1f into tailscale:main Nov 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for serving unix domain sockets

2 participants