You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ce8e85e
Browse filesBrowse the repository at this point in the historyBrowse files
fix(cli): preserve external TLS for SSH forwarding
Resolve the external scheme together with its authority when replacing an
internal bind address with the registered gateway endpoint.
Ported from #3714.
Fixes: #3674
Signed-off-by: Daneyon Hansen <[email protected]>
/// Resolve the SSH gateway host and port for a sandbox connection.
829
+
/// Resolve the SSH gateway scheme, host, and port for a sandbox connection.
830
830
///
831
831
/// If the server-provided gateway host is a loopback address, use the host
832
832
/// and port from the cluster endpoint instead so the client connects to the
833
-
/// right machine. The server returns its internal bind address (e.g. 0.0.0.0:8080)
834
-
/// which may not be reachable from outside — the cluster URL has the actual
835
-
/// Docker-mapped or tunnel port.
833
+
/// right machine. The server returns its internal bind address (e.g.
834
+
/// `http://0.0.0.0:8080`) which may not be reachable from outside — the
835
+
/// cluster URL has the actual scheme and Docker-mapped or tunnel authority.
836
836
pubfnresolve_ssh_gateway(
837
+
gateway_scheme:&str,
837
838
gateway_host:&str,
838
839
gateway_port:u16,
839
840
cluster_url:&str,
840
-
) -> (String,u16){
841
+
) -> (String,String,u16){
841
842
let is_loopback = gateway_host == "127.0.0.1"
842
843
|| gateway_host == "0.0.0.0"
843
844
|| gateway_host == "localhost"
845
+
|| gateway_host == "::"
844
846
|| gateway_host == "::1";
845
847
846
848
if !is_loopback {
847
-
return(gateway_host.to_string(), gateway_port);
849
+
return(
850
+
gateway_scheme.to_string(),
851
+
gateway_host.to_string(),
852
+
gateway_port,
853
+
);
848
854
}
849
855
850
-
// Extract host and port from the cluster URL. The cluster URL represents
851
-
// the externally reachable endpoint (e.g. Docker port-mapped address).
856
+
// Extract the scheme, host, and port from the cluster URL. The cluster URL
857
+
// represents the externally reachable endpoint (e.g. a TLS-terminating
858
+
// proxy or Docker port-mapped address).
852
859
ifletOk(url) = url::Url::parse(cluster_url)
860
+
&& matches!(url.scheme(),"http" | "https")
853
861
&& letSome(host) = url.host_str()
854
862
{
863
+
let cluster_scheme = url.scheme().to_string();
855
864
let cluster_port = url.port_or_known_default().unwrap_or(gateway_port);
let resolved = resolve_ssh_gateway("https","0.0.0.0",8080,"http://gateway.example.test");
let resolved = resolve_ssh_gateway("http","localhost",8080,"https://remote-host:443");
0 commit comments