Skip to content

Commit c2cd590

Browse files
committed
const
1 parent 40250e8 commit c2cd590

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

tailnet/conn.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ func NewConn(options *Options) (conn *Conn, err error) {
354354
return server, nil
355355
}
356356

357+
// A FQDN to be mapped to `tsaddr.CoderServiceIPv6`. This address can be used
358+
// when you want to know if Coder Connect is running, but are not trying to
359+
// connect to a specific known workspace.
360+
const IsCoderConnectEnabledFQDNString = "is--coder--connect--enabled--right--now.coder."
361+
357362
type ServicePrefix [6]byte
358363

359364
var (

tailnet/controllers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ func (t *tunnelUpdater) updateDNSNamesLocked() map[dnsname.FQDN][]netip.Addr {
12661266
}
12671267
}
12681268
}
1269-
fqdn, err := dnsname.ToFQDN("is--coder--connect--enabled--right--now.coder.")
1269+
fqdn, err := dnsname.ToFQDN(IsCoderConnectEnabledFQDNString)
12701270
if err != nil {
12711271
panic(fmt.Sprintf("failed to create static FQDN: %v", err))
12721272
}

tailnet/controllers_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,14 +1564,14 @@ func TestTunnelAllWorkspaceUpdatesController_Initial(t *testing.T) {
15641564

15651565
// Also triggers setting DNS hosts
15661566
expectedDNS := map[dnsname.FQDN][]netip.Addr{
1567-
"w1a1.w1.me.coder.": {ws1a1IP},
1568-
"w2a1.w2.me.coder.": {w2a1IP},
1569-
"w2a2.w2.me.coder.": {w2a2IP},
1570-
"w1a1.w1.testy.coder.": {ws1a1IP},
1571-
"w2a1.w2.testy.coder.": {w2a1IP},
1572-
"w2a2.w2.testy.coder.": {w2a2IP},
1573-
"w1.coder.": {ws1a1IP},
1574-
"is--coder--connect--enabled--right--now.coder.": {tsaddr.CoderServiceIPv6()},
1567+
"w1a1.w1.me.coder.": {ws1a1IP},
1568+
"w2a1.w2.me.coder.": {w2a1IP},
1569+
"w2a2.w2.me.coder.": {w2a2IP},
1570+
"w1a1.w1.testy.coder.": {ws1a1IP},
1571+
"w2a1.w2.testy.coder.": {w2a1IP},
1572+
"w2a2.w2.testy.coder.": {w2a2IP},
1573+
"w1.coder.": {ws1a1IP},
1574+
tailnet.IsCoderConnectEnabledFQDNString: {tsaddr.CoderServiceIPv6()},
15751575
}
15761576
dnsCall := testutil.RequireRecvCtx(ctx, t, fDNS.calls)
15771577
require.Equal(t, expectedDNS, dnsCall.hosts)
@@ -1663,10 +1663,10 @@ func TestTunnelAllWorkspaceUpdatesController_DeleteAgent(t *testing.T) {
16631663

16641664
// DNS for w1a1
16651665
expectedDNS := map[dnsname.FQDN][]netip.Addr{
1666-
"w1a1.w1.testy.coder.": {ws1a1IP},
1667-
"w1a1.w1.me.coder.": {ws1a1IP},
1668-
"w1.coder.": {ws1a1IP},
1669-
"is--coder--connect--enabled--right--now.coder.": {tsaddr.CoderServiceIPv6()},
1666+
"w1a1.w1.testy.coder.": {ws1a1IP},
1667+
"w1a1.w1.me.coder.": {ws1a1IP},
1668+
"w1.coder.": {ws1a1IP},
1669+
tailnet.IsCoderConnectEnabledFQDNString: {tsaddr.CoderServiceIPv6()},
16701670
}
16711671
dnsCall := testutil.RequireRecvCtx(ctx, t, fDNS.calls)
16721672
require.Equal(t, expectedDNS, dnsCall.hosts)
@@ -1719,10 +1719,10 @@ func TestTunnelAllWorkspaceUpdatesController_DeleteAgent(t *testing.T) {
17191719

17201720
// DNS contains only w1a2
17211721
expectedDNS = map[dnsname.FQDN][]netip.Addr{
1722-
"w1a2.w1.testy.coder.": {ws1a2IP},
1723-
"w1a2.w1.me.coder.": {ws1a2IP},
1724-
"w1.coder.": {ws1a2IP},
1725-
"is--coder--connect--enabled--right--now.coder.": {tsaddr.CoderServiceIPv6()},
1722+
"w1a2.w1.testy.coder.": {ws1a2IP},
1723+
"w1a2.w1.me.coder.": {ws1a2IP},
1724+
"w1.coder.": {ws1a2IP},
1725+
tailnet.IsCoderConnectEnabledFQDNString: {tsaddr.CoderServiceIPv6()},
17261726
}
17271727
dnsCall = testutil.RequireRecvCtx(ctx, t, fDNS.calls)
17281728
require.Equal(t, expectedDNS, dnsCall.hosts)
@@ -1802,10 +1802,10 @@ func TestTunnelAllWorkspaceUpdatesController_DNSError(t *testing.T) {
18021802

18031803
// DNS for w1a1
18041804
expectedDNS := map[dnsname.FQDN][]netip.Addr{
1805-
"w1a1.w1.me.coder.": {ws1a1IP},
1806-
"w1a1.w1.testy.coder.": {ws1a1IP},
1807-
"w1.coder.": {ws1a1IP},
1808-
"is--coder--connect--enabled--right--now.coder.": {tsaddr.CoderServiceIPv6()},
1805+
"w1a1.w1.me.coder.": {ws1a1IP},
1806+
"w1a1.w1.testy.coder.": {ws1a1IP},
1807+
"w1.coder.": {ws1a1IP},
1808+
tailnet.IsCoderConnectEnabledFQDNString: {tsaddr.CoderServiceIPv6()},
18091809
}
18101810
dnsCall := testutil.RequireRecvCtx(ctx, t, fDNS.calls)
18111811
require.Equal(t, expectedDNS, dnsCall.hosts)

0 commit comments

Comments
 (0)