Repository navigation
Conversation
…ig targets
runServeSetConfig built every non-file, non-unix endpoint target as
"<protocol>://<host:port>", so a tls-terminated-tcp endpoint produced the
target tls-terminated-tcp://host:port. TLS termination is carried by the serve
type rather than the target, though: applyTCPServe derives terminateTLS from
serveTypeTLSTerminatedTCP and then expands the target allowing only
{tcp, unix}, so every such endpoint failed with "unable to expand target".
The flag form already passes the pair the expander expects,
--tls-terminated-tcp=<port> tcp://host:port.
Map the protocol to the tcp scheme for that one case. https+insecure needs no
mapping, since the web path accepts it as a target scheme, and unix targets
skip scheme construction entirely.
Fixes tailscale#21786
Signed-off-by: Vivek1898 <[email protected]>
bcreane
left a comment
There was a problem hiding this comment.
Thanks for submitting a PR. This looks good to me with a few minor caveats.
|
Thanks — all four taken, in Keying on the serve type. Agreed, and it reads better as the rule rather than the exception: if serveType == serveTypeTCP || serveType == serveTypeTLSTerminatedTCP {
scheme = conffile.ProtoTCP
}Behaviour is unchanged: Both comments. Cut to your wording. You were right that they argued the case instead of documenting the behaviour. The Both green with the fix. |
Key the target-scheme mapping on the serve type rather than on the protocol string, so it states the rule applyTCPServe enforces -- a TCP apply always wants a tcp target scheme -- instead of special-casing tls-terminated-tcp. Same behaviour: serveTypeTCP already arrives with the tcp protocol. Cut the code and test comments to what they describe rather than the bug history, and add an --all variant of the round-trip test, since --all shares the endpoint loop and so needs the same scheme. Signed-off-by: Vivek1898 <[email protected]>
cd52087 to
137fe27
Compare
|
@bcreane all four threads are addressed and resolved above. One correction to my earlier comment: it named The policy bot reads |
bcreane
left a comment
There was a problem hiding this comment.
thanks for making the edits, looks good!
tailscale/tailscale#21789 is in the tailscale input; the patch no longer applies.
services.tailscale.serve's set-config rejects tls-terminated-tcp endpoints in 1.104.x (fixed upstream in tailscale/tailscale#21789, not yet released), so publish navidrome and filebrowser with `tailscale serve --service` from a small unit instead, as HTTPS in front of their HTTP ports.
Fixes #21786.
tailscale serve set-configrejected everytls-terminated-tcpendpoint:runServeSetConfigbuilds each non-file, non-unix target asfmt.Sprintf("%s://%s", ep.Protocol, …), so atls-terminated-tcpendpointbecomes the target
tls-terminated-tcp://localhost:9481. But TLS terminationis carried by the serve type, not by the proxy target:
applyTCPServederives
terminateTLSfromserveTypeTLSTerminatedTCPand then callsipn.ExpandProxyTargetValue(target, []string{"tcp", "unix"}, "tcp"), whichrefuses that scheme. The flag form already passes the pair the expander
expects —
--tls-terminated-tcp=443 tcp://localhost:9481— which is why itworks and the config file does not.
So this maps the protocol to the
tcpscheme for that one case, leaving theserve type to carry TLS termination.
https+insecuredeliberately needs no such mapping: the web path expands with{"http", "https", "https+insecure", "unix"}, so the protocol name is alreadya valid target scheme there. Unix targets were unaffected because they skip the
scheme construction entirely.
tls-terminated-tcpwas the only protocol whosename is not accepted as a target scheme by the path it reaches.
Testing
Added
TestRunServeSetConfig/tls_terminated_tcp_roundtrip, which applies theconfig from the issue and then round-trips it through
get-config, followingthe existing
http_over_unix_roundtripsubtest.Without the change it fails with the reported error verbatim:
With it, the endpoint applies as
TCPForward: "localhost:9481"withTerminateTLS: "foo.test.ts.net", andget-configreproduces"tcp:443": "tls-terminated-tcp://localhost:9481".go test ./cmd/tailscale/cli/,go vet ./cmd/tailscale/cli/andgofmtareclean (Go 1.27.2, linux/amd64).