-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 remote port forwarding for Teleport nodes #38828
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall. I looked over some other related PRs to get the proper context for review:
c828a08
to
269ac1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first pass
if err != nil { | ||
if !utils.IsOKNetworkError(err) { | ||
log.WithError(err).Warn("failed to accept connection") | ||
} | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The net/http
server will check if the error is temporary and if so, it'll continue accepting after a small delay; it's a pattern that I've been using, but I'm not sure if it's actually necessary.
lib/srv/regular/sshserver.go
Outdated
// Verify that reuse is not enabled on the socket | ||
if reuseAddr, err := unix.GetsockoptInt(int(listenerFD.Fd()), unix.SOL_SOCKET, unix.SO_REUSEADDR); err != nil { | ||
return trace.Wrap(err) | ||
} else if reuseAddr != 0 { | ||
return trace.AccessDenied("SO_REUSEADDR is enabled on the socket") | ||
} | ||
if reusePort, err := unix.GetsockoptInt(int(listenerFD.Fd()), unix.SOL_SOCKET, unix.SO_REUSEPORT); err != nil { | ||
// Some systems may not support SO_REUSEPORT, so we ignore the error here | ||
} else if reusePort != 0 { | ||
return trace.AccessDenied("SO_REUSEPORT is enabled on the socket") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we check GOOS to see which of those are supposed to be supported?
16ed426
to
fe65245
Compare
|
||
// remoteForwardingMap holds the remote port forwarding listeners that need | ||
// to be closed when forwarding finishes, keyed by listen addr. | ||
remoteForwardingMap utils.SyncMap[string, io.Closer] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some extra synchronization that prevents new additions to remoteForwardingMap
while the *Server
is being closed or is closed?
lib/srv/regular/sshserver.go
Outdated
_, fn, err := localConn.ReadWithFDs(nil, fbuf) | ||
if err != nil || fn == 0 { | ||
fileCh <- nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure one can recvmsg()
and get data and an error, but we shouldn't risk it:
_, fn, err := localConn.ReadWithFDs(nil, fbuf) | |
if err != nil || fn == 0 { | |
fileCh <- nil | |
} | |
if _, fn, _ := localConn.ReadWithFDs(nil, fbuf); fn == 0 { | |
fileCh <- nil | |
} |
lib/srv/regular/sshserver.go
Outdated
if err != nil || fn == 0 { | ||
fileCh <- nil | ||
} | ||
fileCh <- fbuf[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might get stuck if the reader is gone.
fileCh <- fbuf[0] | |
select { | |
case fileCh <- fbuf[0]: | |
case <-proc.Done: | |
fbuf[0].Close() | |
} |
9969ecf
to
fd74e1c
Compare
This change adds support for remote port forwarding (ssh -R) for Teleport nodes.
ff335c6
to
86dc672
Compare
* Add remote port forwarding for Teleport nodes This change adds support for remote port forwarding (ssh -R) for Teleport nodes. * Fix windows build
* Add remote port forwarding for Teleport nodes This change adds support for remote port forwarding (ssh -R) for Teleport nodes. * Fix windows build
* Add remote port forwarding for Teleport nodes This change adds support for remote port forwarding (ssh -R) for Teleport nodes. * Fix windows build
This change adds support for remote port forwarding (
ssh -R
) for Teleport nodes.Changelog: Added remote port forwarding for Teleport nodes