[tunnel] --port flag for explicit destination port#78
Open
theRealWardo wants to merge 1 commit intomainfrom
Open
[tunnel] --port flag for explicit destination port#78theRealWardo wants to merge 1 commit intomainfrom
theRealWardo wants to merge 1 commit intomainfrom
Conversation
dilyevsky
reviewed
Oct 31, 2025
|
|
||
| // Override port if specified | ||
| if overridePort != "" { | ||
| if port, err := netip.ParseAddrPort("127.0.0.1:" + overridePort); err == nil { |
Contributor
There was a problem hiding this comment.
I think you can just strconv.Atoi instead - this is confusing (why is there 127.0.0.1 in there?) Also it swallows the error
Comment on lines
+60
to
+64
|
|
||
| // Extract IPv4 address from IPv6-mapped address | ||
| dstAddr := Unmap4in6(addrFromNetstackIP(reqDetails.LocalAddress)) | ||
| dstPort := reqDetails.LocalPort | ||
|
|
Contributor
There was a problem hiding this comment.
Suggested change
| // Extract IPv4 address from IPv6-mapped address | |
| dstAddr := Unmap4in6(addrFromNetstackIP(reqDetails.LocalAddress)) | |
| dstPort := reqDetails.LocalPort | |
| dstAddrPort := netip.AddrPortFrom( | |
| Unmap4in6(addrFromNetstackIP(reqDetails.LocalAddress)), | |
| reqDetails.LocalPort, | |
| ) | |
| if overridePort != 0 { | |
| logger.Debug("Overriding port", "original_port", dstAddrPort.Port, "ovveride_port", overridePort) | |
| } |
These comments are not needed
| tunnelRunCmd.Flags().BoolVar(&autoCreate, "auto", false, "Automatically create TunnelNode if it doesn't exist.") | ||
| tunnelRunCmd.Flags().StringVar(&healthAddr, "health-addr", ":8080", "Listen address for health endpoint (default: :8080).") | ||
| tunnelRunCmd.Flags().StringVar(&metricsAddr, "metrics-addr", ":8081", "Listen address for metrics endpoint (default: :8081).") | ||
| tunnelRunCmd.Flags().StringVar(&overridePort, "port", "", "Override destination port for forwarded packets (empty string preserves original port).") |
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.
setting this flag should force all packets to be routed to a specified port. I did not add support for overriding the destination address.
in practice, this allows users to not worry about setting a
portin an HTTPBackendRef or any other API object that references a tunnel.