Skip to content

Commit 7222135

Browse files
committed
chore: replace wsconncache with a single tailnet
1 parent 1406838 commit 7222135

File tree

23 files changed

+1250
-333
lines changed

23 files changed

+1250
-333
lines changed

agent/agent.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ type Options struct {
6464
SSHMaxTimeout time.Duration
6565
TailnetListenPort uint16
6666
Subsystem codersdk.AgentSubsystem
67+
Addresses []netip.Prefix
6768

6869
PrometheusRegistry *prometheus.Registry
6970
}
@@ -111,6 +112,16 @@ func New(options Options) Agent {
111112
prometheusRegistry = prometheus.NewRegistry()
112113
}
113114

115+
if len(options.Addresses) == 0 {
116+
options.Addresses = []netip.Prefix{
117+
// This is the IP that should be used primarily.
118+
netip.PrefixFrom(tailnet.IP(), 128),
119+
// We also listen on the legacy codersdk.WorkspaceAgentIP. This
120+
// allows for a transition away from wsconncache.
121+
netip.PrefixFrom(codersdk.WorkspaceAgentIP, 128),
122+
}
123+
}
124+
114125
ctx, cancelFunc := context.WithCancel(context.Background())
115126
a := &agent{
116127
tailnetListenPort: options.TailnetListenPort,
@@ -131,6 +142,7 @@ func New(options Options) Agent {
131142
connStatsChan: make(chan *agentsdk.Stats, 1),
132143
sshMaxTimeout: options.SSHMaxTimeout,
133144
subsystem: options.Subsystem,
145+
addresses: options.Addresses,
134146

135147
prometheusRegistry: prometheusRegistry,
136148
metrics: newAgentMetrics(prometheusRegistry),
@@ -174,6 +186,7 @@ type agent struct {
174186
lifecycleStates []agentsdk.PostLifecycleRequest
175187

176188
network *tailnet.Conn
189+
addresses []netip.Prefix
177190
connStatsChan chan *agentsdk.Stats
178191
latestStat atomic.Pointer[agentsdk.Stats]
179192

@@ -639,7 +652,7 @@ func (a *agent) trackConnGoroutine(fn func()) error {
639652

640653
func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap, disableDirectConnections bool) (_ *tailnet.Conn, err error) {
641654
network, err := tailnet.NewConn(&tailnet.Options{
642-
Addresses: []netip.Prefix{netip.PrefixFrom(codersdk.WorkspaceAgentIP, 128)},
655+
Addresses: a.addresses,
643656
DERPMap: derpMap,
644657
Logger: a.logger.Named("tailnet"),
645658
ListenPort: a.tailnetListenPort,

0 commit comments

Comments
 (0)
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