Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7222135

Browse files
committed
chore: replace wsconncache with a single tailnet
1 parent1406838 commit7222135

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
TailnetListenPortuint16
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+
iflen(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
connStatsChanchan*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,disableDirectConnectionsbool) (_*tailnet.Conn,errerror) {
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)

[8]ページ先頭

©2009-2025 Movatter.jp