-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: add ssh jump server #1517
Conversation
1b6de70
to
bbfd120
Compare
internal/utils/utils.go
Outdated
@@ -21,3 +23,15 @@ func NewConversationID() string { | |||
} | |||
return hex.EncodeToString(buf) | |||
} | |||
|
|||
// GetFreePort asks the kernel for a free open port that is ready to use. | |||
func GetFreePort() (int, error) { |
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.
nifty!
internal/ssh/ssh_test.go
Outdated
|
||
func (s *sshSuite) Init(c *qt.C) { | ||
s.received = make(chan bool) | ||
port, err := utils.GetFreePort() |
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 don't think there's a guarantee that the returned port won't be taken by another process before it's used in the gliderssh.Server ListenAndServe..
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.
no, is not guaranteed. If we see these tests being flaky I will try to implement a locking mechanism or smt else.
Is it fine for now to leave it like this with a comment?
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 port is chosen randomly from the free ones, so you'd be very unlucky to have two times the same port
9e4f2d4
to
1ac215f
Compare
1ac215f
to
33674e5
Compare
} | ||
}() | ||
go func() { | ||
defer srcDest.Close() |
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.
won't we get a panic if we try to close the channel twice (in both goroutines)?
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.
// writeMu serializes calls to mux.conn.writePacket() and
// protects sentClose and packetPool. This mutex must be
// different from windowMu, as writePacket can block if there
// is a key exchange pending.
writeMu sync.Mutex
sentClose bool
there is a mutex and a bool guarding the close msg
Description
This pr introduces the ssh jump server.
It is the basic struct to start, we still are missing:
But this is the initial blueprint.
Engineering checklist
Test instructions