@@ -64,6 +64,7 @@ type Options struct {
6464SSHMaxTimeout time.Duration
6565TailnetListenPort uint16
6666Subsystem codersdk.AgentSubsystem
67+ Addresses []netip.Prefix
6768
6869PrometheusRegistry * prometheus.Registry
6970}
@@ -111,6 +112,16 @@ func New(options Options) Agent {
111112prometheusRegistry = 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+
114125ctx ,cancelFunc := context .WithCancel (context .Background ())
115126a := & agent {
116127tailnetListenPort :options .TailnetListenPort ,
@@ -131,6 +142,7 @@ func New(options Options) Agent {
131142connStatsChan :make (chan * agentsdk.Stats ,1 ),
132143sshMaxTimeout :options .SSHMaxTimeout ,
133144subsystem :options .Subsystem ,
145+ addresses :options .Addresses ,
134146
135147prometheusRegistry :prometheusRegistry ,
136148metrics :newAgentMetrics (prometheusRegistry ),
@@ -174,6 +186,7 @@ type agent struct {
174186lifecycleStates []agentsdk.PostLifecycleRequest
175187
176188network * tailnet.Conn
189+ addresses []netip.Prefix
177190connStatsChan chan * agentsdk.Stats
178191latestStat atomic.Pointer [agentsdk.Stats ]
179192
@@ -639,7 +652,7 @@ func (a *agent) trackConnGoroutine(fn func()) error {
639652
640653func (a * agent )createTailnet (ctx context.Context ,derpMap * tailcfg.DERPMap ,disableDirectConnections bool ) (_ * tailnet.Conn ,err error ) {
641654network ,err := tailnet .NewConn (& tailnet.Options {
642- Addresses :[]netip. Prefix { netip . PrefixFrom ( codersdk . WorkspaceAgentIP , 128 )} ,
655+ Addresses :a . addresses ,
643656DERPMap :derpMap ,
644657Logger :a .logger .Named ("tailnet" ),
645658ListenPort :a .tailnetListenPort ,