Skip to content
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

Fix checks for local development DNS name #474

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cs/src/Management/TunnelManagementClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,9 @@ private Uri BuildUri(
if (!string.IsNullOrEmpty(clusterId) &&
baseAddress.HostNameType == UriHostNameType.Dns)
{
if (baseAddress.Host != "localhost" && !baseAddress.Host.Contains(".local") &&
// tunnels.local.api.visualstudio.com resolves to localhost (for local development).
if (baseAddress.Host != "localhost" &&
baseAddress.Host != "tunnels.local.api.visualstudio.com" &&
!baseAddress.Host.StartsWith($"{clusterId}."))
{
// A specific cluster ID was specified (while not running on localhost).
Expand Down
8 changes: 5 additions & 3 deletions go/tunnels/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ func NewManager(userAgents []UserAgent, tp tokenProviderfn, tunnelServiceUrl *ur

var client *http.Client
if httpHandler == nil {
if strings.Contains(tunnelServiceUrl.Host, "localhost") || strings.Contains(tunnelServiceUrl.Host, ".local") {
// tunnels.local.api.visualstudio.com resolves to localhost (for local development).
if tunnelServiceUrl.Host == "localhost" || tunnelServiceUrl.Host == "tunnels.local.api.visualstudio.com" {
client = &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}
} else {
client = &http.Client{}
Expand Down Expand Up @@ -825,8 +826,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.Contains(baseAddress.Host, ".local") &&
// tunnels.local.api.visualstudio.com resolves to localhost (for local development).
if baseAddress.Host != "localhost" &&
baseAddress.Host != "tunnels.local.api.visualstudio.com" &&
!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.
Expand Down
2 changes: 1 addition & 1 deletion go/tunnels/tunnels.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/rodaine/table"
)

const PackageVersion = "0.1.11"
const PackageVersion = "0.1.12"

func (tunnel *Tunnel) requestObject() (*Tunnel, error) {
convertedTunnel := &Tunnel{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,10 @@ private URI buildUri(String clusterId,
String host = null;
int port = baseAddress.getPort();

// tunnels.local.api.visualstudio.com resolves to localhost (for local development).
if (StringUtils.isNotBlank(clusterId)) {
if (!baseAddress.getHost().equals("localhost")
&& !baseAddress.getHost().contains(".local")
&& !baseAddress.getHost().equals("tunnels.local.api.visualstudio.com")
&& !baseAddress.getHost().startsWith(clusterId + ".")) {
host = (clusterId + "." + baseAddress.getHost()).replace("global.", "");
} else if (baseAddress.getScheme().equals("https")
Expand Down
4 changes: 2 additions & 2 deletions ts/src/connections/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"buffer": "^5.2.1",
"debug": "^4.1.1",
"vscode-jsonrpc": "^4.0.0",
"@microsoft/dev-tunnels-contracts": ">1.1.32",
"@microsoft/dev-tunnels-management": ">1.1.32",
"@microsoft/dev-tunnels-contracts": ">1.1.37",
"@microsoft/dev-tunnels-management": ">1.1.37",
"@microsoft/dev-tunnels-ssh": "^3.11.36",
"@microsoft/dev-tunnels-ssh-tcp": "^3.11.36",
"uuid": "^3.3.3",
Expand Down
2 changes: 1 addition & 1 deletion ts/src/management/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"buffer": "^5.2.1",
"debug": "^4.1.1",
"vscode-jsonrpc": "^4.0.0",
"@microsoft/dev-tunnels-contracts": ">1.1.32",
"@microsoft/dev-tunnels-contracts": ">1.1.37",
"axios": "^1.6.6"
}
}
4 changes: 3 additions & 1 deletion ts/src/management/tunnelManagementHttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,10 @@ export class TunnelManagementHttpClient implements TunnelManagementClient {
if (clusterId) {
const url = new URL(baseAddress);
const portNumber = parseInt(url.port, 10);

// tunnels.local.api.visualstudio.com resolves to localhost (for local development).
if (url.hostname !== 'localhost' &&
!url.hostname.includes('.local') &&
url.hostname !== 'tunnels.local.api.visualstudio.com' &&
!url.hostname.startsWith(`${clusterId}.`)
) {
// A specific cluster ID was specified (while not running on localhost).
Expand Down
Loading