Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(cli): implement ssh remote forward #8515

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 14 commits into from
Jul 20, 2023
Prev Previous commit
Next Next commit
format
  • Loading branch information
mtojek committed Jul 19, 2023
commit 5e87bc6fb604b339a30a0c82b0eabfd773f55359
4 changes: 2 additions & 2 deletions cli/remoteforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type cookieAddr struct {
cookie []byte
}

// Format:
// remote_port:local_address:local_port
var remoteForwardRegex = regexp.MustCompile(`^(\d+):(.+):(\d+)$`)
Copy link
Member

@johnstcn johnstcn Jul 19, 2023

Choose a reason for hiding this comment

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

nit: add a comment to clarify what this should match

This could also be done with a simple strings.Split()

Copy link
Member Author

Choose a reason for hiding this comment

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

nit: add a comment to clarify what this should match

👍

This could also be done with a simple strings.Split()

Right, but with regexp we can check if ports are numbers :)


func validateRemoteForward(flag string) bool {
Expand All @@ -30,8 +32,6 @@ func validateRemoteForward(flag string) bool {
func parseRemoteForward(flag string) (net.Addr, net.Addr, error) {
matches := remoteForwardRegex.FindStringSubmatch(flag)

// Format:
// remote_port:local_address:local_port
remotePort, err := strconv.Atoi(matches[1])
if err != nil {
return nil, nil, xerrors.Errorf("remote port is invalid: %w", err)
Expand Down