Skip to content

use callback to create net.Listener #1

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

Merged
merged 3 commits into from
Sep 5, 2024
Merged

use callback to create net.Listener #1

merged 3 commits into from
Sep 5, 2024

Conversation

samchouse
Copy link

@samchouse samchouse commented Jul 27, 2024

		ReverseUnixForwardingCallback: ssh.ReverseUnixForwardingCallback(func(ctx ssh.Context, socketPath string) func() (net.Listener, error) {
			isAllowed := true

			if isAllowed {
				return ssh.DefaultSocketListener
			}

			return nil
		}),

OR

ReverseUnixForwardingCallback: ssh.ReverseUnixForwardingCallback(func(ctx ssh.Context, socketPath string) func() (net.Listener, error) {
			isAllowed := true

			if isAllowed {
				return func(socketPath string) (net.Listener, error) {
					ln, err := ssh.DefaultSocketListener(socketPath)
					if err != nil {
						return nil, err
					}

					if err := os.Chmod(socketPath, os.FileMode(0777)); err != nil {
						return nil, err
					}

					return ln, nil
				}
			}

			return nil
		}),

Co-authored-by: Dean Sheather <dean@deansheather.com>
@deansheather
Copy link
Owner

Should the mkdir and unlink be part of this too? And do you think we should create a public function that provides a basic implementation?

@samchouse
Copy link
Author

samchouse commented Jul 30, 2024

Yeah that might be best since now users can change where the socket is created. I think a default implementation of mkdir and unlink would be good in this case since they generally should be called for most uses.

I'll add that in a little later.

@deansheather
Copy link
Owner

I think just having a single public function that does the combo of mkdir+unlink+listen should work

Co-authored-by: Dean Sheather <dean@deansheather.com>
@samchouse
Copy link
Author

Hey @deansheather, sorry I kinda forgot about this. I made the changes so if you think this is good could we get this merged please?

@deansheather deansheather merged commit f86b780 into deansheather:dean/unix-forwarding Sep 5, 2024
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.

2 participants