From 75395e1215b39c70efea6f649d516acd7224d882 Mon Sep 17 00:00:00 2001 From: Ethan Dickson Date: Wed, 9 Apr 2025 15:45:35 +1000 Subject: [PATCH 1/5] chore: add generic DNS record for checking if Coder Connect is running --- tailnet/controllers.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tailnet/controllers.go b/tailnet/controllers.go index bf2ec1d964f56..1fd7614b685a2 100644 --- a/tailnet/controllers.go +++ b/tailnet/controllers.go @@ -16,6 +16,7 @@ import ( "golang.org/x/xerrors" "storj.io/drpc" "storj.io/drpc/drpcerr" + "tailscale.com/net/tsaddr" "tailscale.com/tailcfg" "tailscale.com/util/dnsname" @@ -1265,6 +1266,11 @@ func (t *tunnelUpdater) updateDNSNamesLocked() map[dnsname.FQDN][]netip.Addr { } } } + fqdn, err := dnsname.ToFQDN("is.coder.connect.enabled.right.now--.coder.") + if err != nil { + panic(fmt.Sprintf("failed to create static FQDN: %v", err)) + } + names[fqdn] = []netip.Addr{tsaddr.CoderServiceIPv6()} return names } From 40250e88a08e3cf482305595fb53243f1e0aecee Mon Sep 17 00:00:00 2001 From: Ethan Dickson Date: Wed, 9 Apr 2025 06:05:25 +0000 Subject: [PATCH 2/5] tests, change name --- tailnet/controllers.go | 2 +- tailnet/controllers_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tailnet/controllers.go b/tailnet/controllers.go index 1fd7614b685a2..41d5f3acee66d 100644 --- a/tailnet/controllers.go +++ b/tailnet/controllers.go @@ -1266,7 +1266,7 @@ func (t *tunnelUpdater) updateDNSNamesLocked() map[dnsname.FQDN][]netip.Addr { } } } - fqdn, err := dnsname.ToFQDN("is.coder.connect.enabled.right.now--.coder.") + fqdn, err := dnsname.ToFQDN("is--coder--connect--enabled--right--now.coder.") if err != nil { panic(fmt.Sprintf("failed to create static FQDN: %v", err)) } diff --git a/tailnet/controllers_test.go b/tailnet/controllers_test.go index 16f254e3240a7..253ee601c1460 100644 --- a/tailnet/controllers_test.go +++ b/tailnet/controllers_test.go @@ -22,6 +22,7 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" "storj.io/drpc" "storj.io/drpc/drpcerr" + "tailscale.com/net/tsaddr" "tailscale.com/tailcfg" "tailscale.com/types/key" "tailscale.com/util/dnsname" @@ -1570,6 +1571,7 @@ func TestTunnelAllWorkspaceUpdatesController_Initial(t *testing.T) { "w2a1.w2.testy.coder.": {w2a1IP}, "w2a2.w2.testy.coder.": {w2a2IP}, "w1.coder.": {ws1a1IP}, + "is--coder--connect--enabled--right--now.coder.": {tsaddr.CoderServiceIPv6()}, } dnsCall := testutil.RequireRecvCtx(ctx, t, fDNS.calls) require.Equal(t, expectedDNS, dnsCall.hosts) @@ -1664,6 +1666,7 @@ func TestTunnelAllWorkspaceUpdatesController_DeleteAgent(t *testing.T) { "w1a1.w1.testy.coder.": {ws1a1IP}, "w1a1.w1.me.coder.": {ws1a1IP}, "w1.coder.": {ws1a1IP}, + "is--coder--connect--enabled--right--now.coder.": {tsaddr.CoderServiceIPv6()}, } dnsCall := testutil.RequireRecvCtx(ctx, t, fDNS.calls) require.Equal(t, expectedDNS, dnsCall.hosts) @@ -1719,6 +1722,7 @@ func TestTunnelAllWorkspaceUpdatesController_DeleteAgent(t *testing.T) { "w1a2.w1.testy.coder.": {ws1a2IP}, "w1a2.w1.me.coder.": {ws1a2IP}, "w1.coder.": {ws1a2IP}, + "is--coder--connect--enabled--right--now.coder.": {tsaddr.CoderServiceIPv6()}, } dnsCall = testutil.RequireRecvCtx(ctx, t, fDNS.calls) require.Equal(t, expectedDNS, dnsCall.hosts) @@ -1801,6 +1805,7 @@ func TestTunnelAllWorkspaceUpdatesController_DNSError(t *testing.T) { "w1a1.w1.me.coder.": {ws1a1IP}, "w1a1.w1.testy.coder.": {ws1a1IP}, "w1.coder.": {ws1a1IP}, + "is--coder--connect--enabled--right--now.coder.": {tsaddr.CoderServiceIPv6()}, } dnsCall := testutil.RequireRecvCtx(ctx, t, fDNS.calls) require.Equal(t, expectedDNS, dnsCall.hosts) From c2cd5905527d72f3d2a475b7e23a507b7a9f309a Mon Sep 17 00:00:00 2001 From: Ethan Dickson Date: Wed, 9 Apr 2025 06:12:41 +0000 Subject: [PATCH 3/5] const --- tailnet/conn.go | 5 +++++ tailnet/controllers.go | 2 +- tailnet/controllers_test.go | 40 ++++++++++++++++++------------------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/tailnet/conn.go b/tailnet/conn.go index 59ddefc636d13..289f3e6bbede9 100644 --- a/tailnet/conn.go +++ b/tailnet/conn.go @@ -354,6 +354,11 @@ func NewConn(options *Options) (conn *Conn, err error) { return server, nil } +// A FQDN to be mapped to `tsaddr.CoderServiceIPv6`. This address can be used +// when you want to know if Coder Connect is running, but are not trying to +// connect to a specific known workspace. +const IsCoderConnectEnabledFQDNString = "is--coder--connect--enabled--right--now.coder." + type ServicePrefix [6]byte var ( diff --git a/tailnet/controllers.go b/tailnet/controllers.go index 41d5f3acee66d..bbd888d2fc799 100644 --- a/tailnet/controllers.go +++ b/tailnet/controllers.go @@ -1266,7 +1266,7 @@ func (t *tunnelUpdater) updateDNSNamesLocked() map[dnsname.FQDN][]netip.Addr { } } } - fqdn, err := dnsname.ToFQDN("is--coder--connect--enabled--right--now.coder.") + fqdn, err := dnsname.ToFQDN(IsCoderConnectEnabledFQDNString) if err != nil { panic(fmt.Sprintf("failed to create static FQDN: %v", err)) } diff --git a/tailnet/controllers_test.go b/tailnet/controllers_test.go index 253ee601c1460..3cfa47e3adca2 100644 --- a/tailnet/controllers_test.go +++ b/tailnet/controllers_test.go @@ -1564,14 +1564,14 @@ func TestTunnelAllWorkspaceUpdatesController_Initial(t *testing.T) { // Also triggers setting DNS hosts expectedDNS := map[dnsname.FQDN][]netip.Addr{ - "w1a1.w1.me.coder.": {ws1a1IP}, - "w2a1.w2.me.coder.": {w2a1IP}, - "w2a2.w2.me.coder.": {w2a2IP}, - "w1a1.w1.testy.coder.": {ws1a1IP}, - "w2a1.w2.testy.coder.": {w2a1IP}, - "w2a2.w2.testy.coder.": {w2a2IP}, - "w1.coder.": {ws1a1IP}, - "is--coder--connect--enabled--right--now.coder.": {tsaddr.CoderServiceIPv6()}, + "w1a1.w1.me.coder.": {ws1a1IP}, + "w2a1.w2.me.coder.": {w2a1IP}, + "w2a2.w2.me.coder.": {w2a2IP}, + "w1a1.w1.testy.coder.": {ws1a1IP}, + "w2a1.w2.testy.coder.": {w2a1IP}, + "w2a2.w2.testy.coder.": {w2a2IP}, + "w1.coder.": {ws1a1IP}, + tailnet.IsCoderConnectEnabledFQDNString: {tsaddr.CoderServiceIPv6()}, } dnsCall := testutil.RequireRecvCtx(ctx, t, fDNS.calls) require.Equal(t, expectedDNS, dnsCall.hosts) @@ -1663,10 +1663,10 @@ func TestTunnelAllWorkspaceUpdatesController_DeleteAgent(t *testing.T) { // DNS for w1a1 expectedDNS := map[dnsname.FQDN][]netip.Addr{ - "w1a1.w1.testy.coder.": {ws1a1IP}, - "w1a1.w1.me.coder.": {ws1a1IP}, - "w1.coder.": {ws1a1IP}, - "is--coder--connect--enabled--right--now.coder.": {tsaddr.CoderServiceIPv6()}, + "w1a1.w1.testy.coder.": {ws1a1IP}, + "w1a1.w1.me.coder.": {ws1a1IP}, + "w1.coder.": {ws1a1IP}, + tailnet.IsCoderConnectEnabledFQDNString: {tsaddr.CoderServiceIPv6()}, } dnsCall := testutil.RequireRecvCtx(ctx, t, fDNS.calls) require.Equal(t, expectedDNS, dnsCall.hosts) @@ -1719,10 +1719,10 @@ func TestTunnelAllWorkspaceUpdatesController_DeleteAgent(t *testing.T) { // DNS contains only w1a2 expectedDNS = map[dnsname.FQDN][]netip.Addr{ - "w1a2.w1.testy.coder.": {ws1a2IP}, - "w1a2.w1.me.coder.": {ws1a2IP}, - "w1.coder.": {ws1a2IP}, - "is--coder--connect--enabled--right--now.coder.": {tsaddr.CoderServiceIPv6()}, + "w1a2.w1.testy.coder.": {ws1a2IP}, + "w1a2.w1.me.coder.": {ws1a2IP}, + "w1.coder.": {ws1a2IP}, + tailnet.IsCoderConnectEnabledFQDNString: {tsaddr.CoderServiceIPv6()}, } dnsCall = testutil.RequireRecvCtx(ctx, t, fDNS.calls) require.Equal(t, expectedDNS, dnsCall.hosts) @@ -1802,10 +1802,10 @@ func TestTunnelAllWorkspaceUpdatesController_DNSError(t *testing.T) { // DNS for w1a1 expectedDNS := map[dnsname.FQDN][]netip.Addr{ - "w1a1.w1.me.coder.": {ws1a1IP}, - "w1a1.w1.testy.coder.": {ws1a1IP}, - "w1.coder.": {ws1a1IP}, - "is--coder--connect--enabled--right--now.coder.": {tsaddr.CoderServiceIPv6()}, + "w1a1.w1.me.coder.": {ws1a1IP}, + "w1a1.w1.testy.coder.": {ws1a1IP}, + "w1.coder.": {ws1a1IP}, + tailnet.IsCoderConnectEnabledFQDNString: {tsaddr.CoderServiceIPv6()}, } dnsCall := testutil.RequireRecvCtx(ctx, t, fDNS.calls) require.Equal(t, expectedDNS, dnsCall.hosts) From 141f0c45c2fceaa02a03679bb0ef5578290406ab Mon Sep 17 00:00:00 2001 From: Ethan Dickson Date: Wed, 9 Apr 2025 06:16:07 +0000 Subject: [PATCH 4/5] const --- tailnet/conn.go | 2 ++ tailnet/controllers.go | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tailnet/conn.go b/tailnet/conn.go index 289f3e6bbede9..c7cd9c843983a 100644 --- a/tailnet/conn.go +++ b/tailnet/conn.go @@ -359,6 +359,8 @@ func NewConn(options *Options) (conn *Conn, err error) { // connect to a specific known workspace. const IsCoderConnectEnabledFQDNString = "is--coder--connect--enabled--right--now.coder." +var IsCoderConnectEnabledFQDN, _ = dnsname.ToFQDN(IsCoderConnectEnabledFQDNString) + type ServicePrefix [6]byte var ( diff --git a/tailnet/controllers.go b/tailnet/controllers.go index bbd888d2fc799..7a077ffabfaa0 100644 --- a/tailnet/controllers.go +++ b/tailnet/controllers.go @@ -1266,11 +1266,7 @@ func (t *tunnelUpdater) updateDNSNamesLocked() map[dnsname.FQDN][]netip.Addr { } } } - fqdn, err := dnsname.ToFQDN(IsCoderConnectEnabledFQDNString) - if err != nil { - panic(fmt.Sprintf("failed to create static FQDN: %v", err)) - } - names[fqdn] = []netip.Addr{tsaddr.CoderServiceIPv6()} + names[IsCoderConnectEnabledFQDN] = []netip.Addr{tsaddr.CoderServiceIPv6()} return names } From be2f54364ad0b4d2f17b415e7830139fb3c44f95 Mon Sep 17 00:00:00 2001 From: Ethan Dickson Date: Wed, 9 Apr 2025 06:47:13 +0000 Subject: [PATCH 5/5] remove hyphens in 3rd and 4th position --- tailnet/conn.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tailnet/conn.go b/tailnet/conn.go index c7cd9c843983a..89b3b7d483d0c 100644 --- a/tailnet/conn.go +++ b/tailnet/conn.go @@ -357,7 +357,7 @@ func NewConn(options *Options) (conn *Conn, err error) { // A FQDN to be mapped to `tsaddr.CoderServiceIPv6`. This address can be used // when you want to know if Coder Connect is running, but are not trying to // connect to a specific known workspace. -const IsCoderConnectEnabledFQDNString = "is--coder--connect--enabled--right--now.coder." +const IsCoderConnectEnabledFQDNString = "is.coder--connect--enabled--right--now.coder." var IsCoderConnectEnabledFQDN, _ = dnsname.ToFQDN(IsCoderConnectEnabledFQDNString) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy