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

x/crypto/ssh: provide Client.DialContext method #20288

Open
ydnar opened this issue May 8, 2017 · 4 comments
Open

x/crypto/ssh: provide Client.DialContext method #20288

ydnar opened this issue May 8, 2017 · 4 comments
Milestone

Comments

@ydnar
Copy link

@ydnar ydnar commented May 8, 2017

Similar to #17759, it would be useful for ssh.Client to provide a DialContext method next to its Dial method. We use SSH tunnels for connecting to domain registries that use IP whitelisting.

We’ve been progressively consolidating our timeout and deadline code to use context.Context throughout, implementing workarounds for dialers in APIs that lack Context support.

@gopherbot gopherbot added this to the Unreleased milestone May 8, 2017
@hanwen
Copy link
Contributor

@hanwen hanwen commented Jun 7, 2017

what exactly do you want controlled with deadline? The underlying TCP deadline? Or were you thinking of a SSH-level support for deadlines?

@glycerine
Copy link

@glycerine glycerine commented Aug 11, 2017

My use case is not leaking goroutines. When my goroutine does a blocking read on an ssh.Channel it is always blocked, I can't signal that goroutine to shutdown. The usual way with a net.Conn is to set read and write deadlines, then poll for errors. So I was thinking of SSH channel level support for (both read and write) deadlines.

@glycerine
Copy link

@glycerine glycerine commented Aug 26, 2017

My experimental fork https://github.com/glycerine/xcryptossh provides Dial with context and idle timers for Read/Write unblocking.

@denisvmedia
Copy link

@denisvmedia denisvmedia commented Oct 12, 2020

Actually it's doable with user code without forking/modifying the lib.

func Dial(ctx context.Context, network, addr string, config *ssh.ClientConfig) (*ssh.Client, error) {
	d := net.Dialer{Timeout: config.Timeout}
	conn, err := d.DialContext(ctx, network, addr)
	if err != nil {
		return nil, err
	}
	c, chans, reqs, err := ssh.NewClientConn(conn, addr, config)
	if err != nil {
		return nil, err
	}
	return ssh.NewClient(c, chans, reqs), nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.