Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for configurable keep-alives #2349

Merged
merged 1 commit into from Nov 29, 2018
Merged

Conversation

russjones
Copy link
Contributor

Purpose

Allow configurable keep-alives to be sent from Teleport servers to clients. This is to prevent firewalls, load balancers, and VPNs from tearing down idle SSH session.

Implementation

  • Added keep_alive_interval to Teleport configuration. This sets the interval at which Teleport will send keep-alive messages. The default value mirrors sshd at 15 minutes.
  • Added keep_alive_count_max, the number of messed keep-alive messages before the server tears down the connection to the client. The default value mirrors sshd at 3.
  • Both the regular and forwarding server now both use the same keep-alive code.

Related Issues

Fixes #2334

@russjones russjones changed the title Add support for keep-alives Add support for configurable keep-alives Nov 8, 2018
lib/client/client.go Outdated Show resolved Hide resolved
lib/srv/forward/sshserver.go Outdated Show resolved Hide resolved
lib/srv/keepalive.go Outdated Show resolved Hide resolved
lib/srv/keepalive.go Outdated Show resolved Hide resolved
lib/srv/keepalive.go Outdated Show resolved Hide resolved
lib/srv/keepalive.go Show resolved Hide resolved
@@ -38,13 +38,13 @@ import (
"github.com/gravitational/teleport/lib/utils"

"github.com/gravitational/trace"
log "github.com/sirupsen/logrus"
Copy link
Contributor

Choose a reason for hiding this comment

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

what's up with this refactoring?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to our new structured logging everywhere in lib/srv.

Copy link
Contributor

Choose a reason for hiding this comment

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

how does renaming to logrus help?

closeContext, closeCancel := context.WithCancel(context.Background())
defer closeCancel()

clusterConfig, err := s.GetAccessPoint().GetClusterConfig()
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto for the error handling logic and cleanup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Everything should be cleaned up in a defer here.

// The keep-alive loop will keep pinging the remote server and after it has
// missed a certain number of keep-alive requests it will cancel the
// closeContext which signals the server to shutdown.
go srv.StartKeepAliveLoop(srv.KeepAliveParams{
Copy link
Contributor

Choose a reason for hiding this comment

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

why don't you pass a context to keepalive loop as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am passing a context to the keep-alive loop?

lib/srv/regular/sshserver.go Outdated Show resolved Hide resolved
control how often the server sends keep-alive messages to clients and
after how many missed keep-alive replies the server tears down the
connection to the client.
@russjones russjones merged commit 6c37b4a into master Nov 29, 2018
@russjones russjones deleted the rjones/keep-alives branch November 29, 2018 21:36
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.

None yet

2 participants