diff --git a/cs/src/Management/TunnelManagementClient.cs b/cs/src/Management/TunnelManagementClient.cs index 54d6454e..b5d21325 100644 --- a/cs/src/Management/TunnelManagementClient.cs +++ b/cs/src/Management/TunnelManagementClient.cs @@ -649,7 +649,7 @@ private string UserLimitsPath errorMessage = "Tunnel service error: " + problemDetails!.Title + " " + problemDetails.Detail; } - + if (problemDetails.Errors != null) { foreach (var error in problemDetails.Errors) @@ -785,7 +785,7 @@ private Uri BuildUri( if (!string.IsNullOrEmpty(clusterId) && baseAddress.HostNameType == UriHostNameType.Dns) { - if (baseAddress.Host != "localhost" && + if (baseAddress.Host != "localhost" && !baseAddress.Host.Contains(".local") && !baseAddress.Host.StartsWith($"{clusterId}.")) { // A specific cluster ID was specified (while not running on localhost). diff --git a/go/tunnels/manager.go b/go/tunnels/manager.go index 0cfdc3b7..52546097 100644 --- a/go/tunnels/manager.go +++ b/go/tunnels/manager.go @@ -108,7 +108,7 @@ func NewManager(userAgents []UserAgent, tp tokenProviderfn, tunnelServiceUrl *ur var client *http.Client if httpHandler == nil { - if strings.Contains(tunnelServiceUrl.Host, "localhost") { + if strings.Contains(tunnelServiceUrl.Host, "localhost") || strings.Contains(tunnelServiceUrl.Host, ".local") { client = &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}} } else { client = &http.Client{} @@ -825,7 +825,9 @@ func (m *Manager) getAccessToken(tunnel *Tunnel, tunnelRequestOptions *TunnelReq func (m *Manager) buildUri(clusterId string, path string, options *TunnelRequestOptions, query string) *url.URL { baseAddress := m.uri if clusterId != "" { - if !strings.HasPrefix(baseAddress.Host, "localhost") && !strings.HasPrefix(baseAddress.Host, clusterId) { + if !strings.HasPrefix(baseAddress.Host, "localhost") && + !strings.Contains(baseAddress.Host, ".local") && + !strings.HasPrefix(baseAddress.Host, clusterId) { // A specific cluster ID was specified (while not running on localhost). // Prepend the cluster ID to the hostname, and optionally strip a global prefix. baseAddress.Host = fmt.Sprintf("%s.%s", clusterId, baseAddress.Host) diff --git a/go/tunnels/tunnels.go b/go/tunnels/tunnels.go index 1fd4e93d..46953168 100644 --- a/go/tunnels/tunnels.go +++ b/go/tunnels/tunnels.go @@ -10,7 +10,7 @@ import ( "github.com/rodaine/table" ) -const PackageVersion = "0.1.9" +const PackageVersion = "0.1.10" func (tunnel *Tunnel) requestObject() (*Tunnel, error) { convertedTunnel := &Tunnel{ diff --git a/java/src/main/java/com/microsoft/tunnels/management/TunnelManagementClient.java b/java/src/main/java/com/microsoft/tunnels/management/TunnelManagementClient.java index 8402311d..fc4f5ffb 100644 --- a/java/src/main/java/com/microsoft/tunnels/management/TunnelManagementClient.java +++ b/java/src/main/java/com/microsoft/tunnels/management/TunnelManagementClient.java @@ -302,6 +302,7 @@ private URI buildUri(String clusterId, if (StringUtils.isNotBlank(clusterId)) { if (!baseAddress.getHost().equals("localhost") + && !baseAddress.getHost().contains(".local") && !baseAddress.getHost().startsWith(clusterId + ".")) { host = (clusterId + "." + baseAddress.getHost()).replace("global.", ""); } else if (baseAddress.getScheme().equals("https") diff --git a/rs/src/connections/relay_tunnel_host.rs b/rs/src/connections/relay_tunnel_host.rs index e52e27fe..b800164a 100644 --- a/rs/src/connections/relay_tunnel_host.rs +++ b/rs/src/connections/relay_tunnel_host.rs @@ -389,7 +389,7 @@ impl RelayTunnelHost { &self.locator, &TunnelRelayTunnelEndpoint { base: TunnelEndpoint { - id: format!("{}-relay", self.host_id), + id: Some(format!("{}-relay", self.host_id)), connection_mode: TunnelConnectionMode::TunnelRelay, host_id: self.host_id.to_string(), host_public_keys: vec![], diff --git a/rs/src/contracts/tunnel_endpoint.rs b/rs/src/contracts/tunnel_endpoint.rs index a0f8ee02..aef96832 100644 --- a/rs/src/contracts/tunnel_endpoint.rs +++ b/rs/src/contracts/tunnel_endpoint.rs @@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize}; #[serde(rename_all(serialize = "camelCase", deserialize = "camelCase"))] pub struct TunnelEndpoint { // Gets or sets the ID of this endpoint. - pub id: String, + pub id: Option, // Gets or sets the connection mode of the endpoint. // diff --git a/rs/src/management/http_client.rs b/rs/src/management/http_client.rs index 0ad685c9..20986bf7 100644 --- a/rs/src/management/http_client.rs +++ b/rs/src/management/http_client.rs @@ -162,7 +162,7 @@ impl TunnelManagementClient { ) -> HttpResult { let mut url = self.build_tunnel_uri( locator, - Some(&format!("{}/{}", ENDPOINTS_API_SUB_PATH, endpoint.id)), + Some(&format!("{}/{}", ENDPOINTS_API_SUB_PATH, endpoint.id.as_deref().unwrap())), ); url.query_pairs_mut() .append_pair("connectionMode", &endpoint.connection_mode.to_string()); @@ -180,7 +180,7 @@ impl TunnelManagementClient { ) -> HttpResult { let mut url = self.build_tunnel_uri( locator, - Some(&format!("{}/{}", ENDPOINTS_API_SUB_PATH, endpoint.base.id)), + Some(&format!("{}/{}", ENDPOINTS_API_SUB_PATH, endpoint.base.id.as_deref().unwrap())), ); url.query_pairs_mut() .append_pair("connectionMode", &endpoint.base.connection_mode.to_string()); diff --git a/ts/src/connections/package.json b/ts/src/connections/package.json index 85d57dc1..a2a83472 100644 --- a/ts/src/connections/package.json +++ b/ts/src/connections/package.json @@ -18,8 +18,8 @@ "buffer": "^5.2.1", "debug": "^4.1.1", "vscode-jsonrpc": "^4.0.0", - "@microsoft/dev-tunnels-contracts": ">1.1.26", - "@microsoft/dev-tunnels-management": ">1.1.26", + "@microsoft/dev-tunnels-contracts": ">1.1.32", + "@microsoft/dev-tunnels-management": ">1.1.32", "@microsoft/dev-tunnels-ssh": "^3.11.36", "@microsoft/dev-tunnels-ssh-tcp": "^3.11.36", "uuid": "^3.3.3", diff --git a/ts/src/management/package.json b/ts/src/management/package.json index 758d67b3..d1bff272 100644 --- a/ts/src/management/package.json +++ b/ts/src/management/package.json @@ -18,7 +18,7 @@ "buffer": "^5.2.1", "debug": "^4.1.1", "vscode-jsonrpc": "^4.0.0", - "@microsoft/dev-tunnels-contracts": ">1.1.26", + "@microsoft/dev-tunnels-contracts": ">1.1.32", "axios": "^1.6.6" } } diff --git a/ts/src/management/tunnelManagementHttpClient.ts b/ts/src/management/tunnelManagementHttpClient.ts index 19aa7885..b41abccd 100644 --- a/ts/src/management/tunnelManagementHttpClient.ts +++ b/ts/src/management/tunnelManagementHttpClient.ts @@ -875,7 +875,10 @@ export class TunnelManagementHttpClient implements TunnelManagementClient { if (clusterId) { const url = new URL(baseAddress); const portNumber = parseInt(url.port, 10); - if (url.hostname !== 'localhost' && !url.hostname.startsWith(`${clusterId}.`)) { + if (url.hostname !== 'localhost' && + !url.hostname.includes('.local') && + !url.hostname.startsWith(`${clusterId}.`) + ) { // A specific cluster ID was specified (while not running on localhost). // Prepend the cluster ID to the hostname, and optionally strip a global prefix. url.hostname = `${clusterId}.${url.hostname}`.replace('global.', '');