Possibility not to specify BoundHost when using ForwardedPortRemote#1234
Open
ch1seL wants to merge 1 commit intosshnet:developfrom
Open
Possibility not to specify BoundHost when using ForwardedPortRemote#1234ch1seL wants to merge 1 commit intosshnet:developfrom
ch1seL wants to merge 1 commit intosshnet:developfrom
Conversation
186aec3 to
092b486
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR modifies ForwardedPortRemote to support optional BoundHost specification, allowing the bound host address to be null to simulate SSH remote port forwarding commands like ssh -R 80:127.0.0.1:5000 nokey@localhost.run.
Key Changes:
- Removed the null check for
boundHostAddressparameter in the main constructor - Modified the constructor chain to pass
nullinstead of empty string whenboundHostis not specified - Updated the
BoundHostproperty getter to handle nullBoundHostAddress
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| /// <param name="port">The port.</param> | ||
| public ForwardedPortRemote(string boundHost, uint boundPort, string host, uint port) | ||
| : this(DnsAbstraction.GetHostAddresses(boundHost)[0], | ||
| : this(boundHost == null ? null : DnsAbstraction.GetHostAddresses(boundHost)[0], |
There was a problem hiding this comment.
Direct array indexing without bounds checking could throw IndexOutOfRangeException if GetHostAddresses returns an empty array. Consider adding validation to ensure the array is not empty before accessing the first element.
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.
When using overload ForwardedPortRemote without boundHost parameter it is still transmitted as empty string and then resolved by DnsAbstraction.GetHostAddresses -> '::1'.
This is necessary to simulate ssh command like this
ssh -R 80:127.0.0.1:5000 nokey@localhost.run(https://localhost.run/docs/)