Skip to content

Allow tunnel nodes to enable the ssh listener#53473

Merged
rosstimothy merged 1 commit intomasterfrom
tross/tunnel_direct_node
Apr 22, 2025
Merged

Allow tunnel nodes to enable the ssh listener#53473
rosstimothy merged 1 commit intomasterfrom
tross/tunnel_direct_node

Conversation

@rosstimothy
Copy link
Copy Markdown
Contributor

@rosstimothy rosstimothy commented Mar 26, 2025

This allows the service to be connectable by users with direct network access. All connections still require a valid user
certificate to be presented and will not permit any extra access. This is intended to provide an optional connection path to hosts that may provide reduced latency if the Proxy is not co-located with the user and service.

Changelog: Allow the ssh_service.listen_addr to forcibly be enabled when operating in reverse tunnel mode to provide an optional direct access path to hosts.

@rosstimothy rosstimothy force-pushed the tross/tunnel_direct_node branch 2 times, most recently from 8add08a to 7fa96e7 Compare April 15, 2025 14:44
@rosstimothy rosstimothy force-pushed the tross/tunnel_direct_node branch from 7fa96e7 to 6d23b17 Compare April 15, 2025 14:44
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 15, 2025

Amplify deployment status

Branch Commit Job ID Status Preview Updated (UTC)
tross/tunnel_direct_node e6bf732 5 ✅SUCCEED tross-tunnel-direct-node 2025-04-22 13:32:17

Comment thread lib/service/service.go Outdated
Comment on lines +3223 to +3210
if !useLocalListener {
// Start the SSH server. This kicks off updating labels and starting the
// heartbeat.
if err := s.Start(); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this conditional start reads a bit funny when scanning this logic. Might be worth an explanatory comment. Ex:

// if local listener setup wasn't run, the server still needs to be started

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd consider making it even more explicit in the code and setting a flag for serverStarted to true right before the go s.Serve(listener) and checking for conn.UseTunnel() && !serverStarted here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this back into the else clause to reduce confusion.

Comment thread lib/service/service.go Outdated
Comment on lines +3222 to +3207
if conn.UseTunnel() {
if !useLocalListener {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if conn.UseTunnel() {
if !useLocalListener {
if conn.UseTunnel() && !useLocalListener {

Comment thread lib/config/fileconf.go Outdated
Comment on lines +9203 to +9206
func testForceListenerInTunnelMode(t *testing.T, suite *integrationTestSuite) {
// InsecureDevMode needed for IoT node handshake
lib.SetInsecureDevMode(true)
defer lib.SetInsecureDevMode(false)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm always scared of global state manipulation in tests.

Suggested change
func testForceListenerInTunnelMode(t *testing.T, suite *integrationTestSuite) {
// InsecureDevMode needed for IoT node handshake
lib.SetInsecureDevMode(true)
defer lib.SetInsecureDevMode(false)
func testForceListenerInTunnelMode(t *testing.T, suite *integrationTestSuite) {
// InsecureDevMode needed for IoT node handshake
defer lib.SetInsecureDevMode(lib.IsInsecureDevMode())
lib.SetInsecureDevMode(true)
// fail the test if it's accidentally made parallel
t.SetEnv("_testForceListenerInTunnelMode_SetInsecureDevMode", "1")

Comment thread lib/service/service.go Outdated
Comment on lines +3223 to +3210
if !useLocalListener {
// Start the SSH server. This kicks off updating labels and starting the
// heartbeat.
if err := s.Start(); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd consider making it even more explicit in the code and setting a flag for serverStarted to true right before the go s.Serve(listener) and checking for conn.UseTunnel() && !serverStarted here.

@rosstimothy rosstimothy force-pushed the tross/tunnel_direct_node branch from 224b603 to 540d53f Compare April 21, 2025 18:55
This allows the service to be connectable by users with direct
network access. All connections still require a valid user
certificate to be presented and will not permit any extra access.
This is intended to provide an optional connection path to hosts
that may provide reduced latency if the Proxy is not co-located with
the user and service.
@rosstimothy rosstimothy force-pushed the tross/tunnel_direct_node branch from 9fb28d3 to e6bf732 Compare April 22, 2025 13:27
@rosstimothy rosstimothy added this pull request to the merge queue Apr 22, 2025
Merged via the queue into master with commit 529dec6 Apr 22, 2025
43 checks passed
@rosstimothy rosstimothy deleted the tross/tunnel_direct_node branch April 22, 2025 20:51
@backport-bot-workflows
Copy link
Copy Markdown
Contributor

@rosstimothy See the table below for backport results.

Branch Result
branch/v17 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants