-
Notifications
You must be signed in to change notification settings - Fork 63
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
multi connections #1
base: master
Are you sure you want to change the base?
Conversation
} | ||
|
||
func NewSSHTunnel(tunnel string, auth ssh.AuthMethod, destination string) *SSHTunnel { | ||
func NewSSHTunnel(tunnel string, auth ssh.AuthMethod, destination string, localPort string) *SSHTunnel { |
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 will have to be a different constructor, such as NewSSHTunnelWithPort
. Unless there is a special reason why the called needs to provide a specific port, it's much cleaner to allow hide that.
_, err := io.Copy(writer, reader) | ||
if err != nil { | ||
tunnel.logf("io.Copy error: %s", err) | ||
tunnel.logf("io.Copy local to remote warm: %s", err) |
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 "warm" means to be "warn"? Is so it's not a warning because it will break the connection. How about "io.Copy local to remote failed: %s"
|
||
go func(writer, reader net.Conn) { | ||
defer writer.Close() | ||
defer reader.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.
You are closing both connections twice.
defer reader.Close() | ||
_, err := io.Copy(writer, reader) | ||
if err != nil { | ||
tunnel.logf("io.Copy remote to local warm: %s", err) |
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.
As noted above.
} | ||
|
||
if retry > 1 { | ||
tunnel.logf("Retry server: %s", strconv.Itoa(retry)) |
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.
There are a few things I don't like about this:
- This is unlimited retry. There must be a way to configure it or give it a save default (such as 3 times).
- It's repeated code, the same thing happens below. The retry mechanism can be moved to be a method.
- There's no need to print the number of failures if you have already logged each failure.
multi connections had error, with several request.
This change is