-
Notifications
You must be signed in to change notification settings - Fork 1
[tunnel] --port flag for explicit destination port #78
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
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| // Override port if specified | ||
| if overridePort != "" { | ||
| if port, err := netip.ParseAddrPort("127.0.0.1:" + overridePort); err == nil { |
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.
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
|
|
||
| // Extract IPv4 address from IPv6-mapped address | ||
| dstAddr := Unmap4in6(addrFromNetstackIP(reqDetails.LocalAddress)) | ||
| dstPort := reqDetails.LocalPort | ||
|
|
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.
| // 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).") |
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.
Port should be a uint
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.