multi connections#1
Open
yefriddavid wants to merge 2 commits into
Open
Conversation
elliotchance
requested changes
Oct 7, 2019
| } | ||
|
|
||
| func NewSSHTunnel(tunnel string, auth ssh.AuthMethod, destination string) *SSHTunnel { | ||
| func NewSSHTunnel(tunnel string, auth ssh.AuthMethod, destination string, localPort string) *SSHTunnel { |
Owner
There was a problem hiding this comment.
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) |
Owner
There was a problem hiding this comment.
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() |
Owner
There was a problem hiding this comment.
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) |
| } | ||
|
|
||
| if retry > 1 { | ||
| tunnel.logf("Retry server: %s", strconv.Itoa(retry)) |
Owner
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
multi connections had error, with several request.
This change is