mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: add Coder service prefix to tailnet (#14943)
re: #14715 This PR introduces the Coder service prefix: `fd60:627a:a42b::/48` and refactors our existing code as calling the Tailscale service prefix explicitly (rather than implicitly). Removes the unused `Addresses` agent option. All clients today assume they can compute the Agent's IP address based on its UUID, so an agent started with a custom address would break things.
This commit is contained in:
+4
-11
@@ -82,7 +82,6 @@ type Options struct {
|
||||
SSHMaxTimeout time.Duration
|
||||
TailnetListenPort uint16
|
||||
Subsystems []codersdk.AgentSubsystem
|
||||
Addresses []netip.Prefix
|
||||
PrometheusRegistry *prometheus.Registry
|
||||
ReportMetadataInterval time.Duration
|
||||
ServiceBannerRefreshInterval time.Duration
|
||||
@@ -180,7 +179,6 @@ func New(options Options) Agent {
|
||||
announcementBannersRefreshInterval: options.ServiceBannerRefreshInterval,
|
||||
sshMaxTimeout: options.SSHMaxTimeout,
|
||||
subsystems: options.Subsystems,
|
||||
addresses: options.Addresses,
|
||||
syscaller: options.Syscaller,
|
||||
modifiedProcs: options.ModifiedProcesses,
|
||||
processManagementTick: options.ProcessManagementTick,
|
||||
@@ -250,7 +248,6 @@ type agent struct {
|
||||
lifecycleLastReportedIndex int // Keeps track of the last lifecycle state we successfully reported.
|
||||
|
||||
network *tailnet.Conn
|
||||
addresses []netip.Prefix
|
||||
statsReporter *statsReporter
|
||||
logSender *agentsdk.LogSender
|
||||
|
||||
@@ -1112,15 +1109,11 @@ func (a *agent) updateCommandEnv(current []string) (updated []string, err error)
|
||||
return updated, nil
|
||||
}
|
||||
|
||||
func (a *agent) wireguardAddresses(agentID uuid.UUID) []netip.Prefix {
|
||||
if len(a.addresses) == 0 {
|
||||
return []netip.Prefix{
|
||||
// This is the IP that should be used primarily.
|
||||
netip.PrefixFrom(tailnet.IPFromUUID(agentID), 128),
|
||||
}
|
||||
func (*agent) wireguardAddresses(agentID uuid.UUID) []netip.Prefix {
|
||||
return []netip.Prefix{
|
||||
// This is the IP that should be used primarily.
|
||||
tailnet.TailscaleServicePrefix.PrefixFromUUID(agentID),
|
||||
}
|
||||
|
||||
return a.addresses
|
||||
}
|
||||
|
||||
func (a *agent) trackGoroutine(fn func()) error {
|
||||
|
||||
+2
-2
@@ -1880,7 +1880,7 @@ func TestAgent_UpdatedDERP(t *testing.T) {
|
||||
// Setup a client connection.
|
||||
newClientConn := func(derpMap *tailcfg.DERPMap, name string) *workspacesdk.AgentConn {
|
||||
conn, err := tailnet.NewConn(&tailnet.Options{
|
||||
Addresses: []netip.Prefix{netip.PrefixFrom(tailnet.IP(), 128)},
|
||||
Addresses: []netip.Prefix{tailnet.TailscaleServicePrefix.RandomPrefix()},
|
||||
DERPMap: derpMap,
|
||||
Logger: logger.Named(name),
|
||||
})
|
||||
@@ -2372,7 +2372,7 @@ func setupAgent(t *testing.T, metadata agentsdk.Manifest, ptyTimeout time.Durati
|
||||
_ = agnt.Close()
|
||||
})
|
||||
conn, err := tailnet.NewConn(&tailnet.Options{
|
||||
Addresses: []netip.Prefix{netip.PrefixFrom(tailnet.IP(), 128)},
|
||||
Addresses: []netip.Prefix{netip.PrefixFrom(tailnet.TailscaleServicePrefix.RandomAddr(), 128)},
|
||||
DERPMap: metadata.DERPMap,
|
||||
Logger: logger.Named("client"),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user