@@ -593,7 +593,7 @@ func (a *agent) run(ctx context.Context) error {
593
593
network := a .network
594
594
a .closeMutex .Unlock ()
595
595
if network == nil {
596
- network , err = a .createTailnet (ctx , manifest .DERPMap )
596
+ network , err = a .createTailnet (ctx , manifest .DERPMap , manifest . DisableDirectConnections )
597
597
if err != nil {
598
598
return xerrors .Errorf ("create tailnet: %w" , err )
599
599
}
@@ -611,8 +611,9 @@ func (a *agent) run(ctx context.Context) error {
611
611
612
612
a .startReportingConnectionStats (ctx )
613
613
} else {
614
- // Update the DERP map!
614
+ // Update the DERP map and allow/disallow direct connections.
615
615
network .SetDERPMap (manifest .DERPMap )
616
+ network .SetBlockEndpoints (manifest .DisableDirectConnections )
616
617
}
617
618
618
619
a .logger .Debug (ctx , "running tailnet connection coordinator" )
@@ -637,12 +638,13 @@ func (a *agent) trackConnGoroutine(fn func()) error {
637
638
return nil
638
639
}
639
640
640
- func (a * agent ) createTailnet (ctx context.Context , derpMap * tailcfg.DERPMap ) (_ * tailnet.Conn , err error ) {
641
+ func (a * agent ) createTailnet (ctx context.Context , derpMap * tailcfg.DERPMap , disableDirectConnections bool ) (_ * tailnet.Conn , err error ) {
641
642
network , err := tailnet .NewConn (& tailnet.Options {
642
- Addresses : []netip.Prefix {netip .PrefixFrom (codersdk .WorkspaceAgentIP , 128 )},
643
- DERPMap : derpMap ,
644
- Logger : a .logger .Named ("tailnet" ),
645
- ListenPort : a .tailnetListenPort ,
643
+ Addresses : []netip.Prefix {netip .PrefixFrom (codersdk .WorkspaceAgentIP , 128 )},
644
+ DERPMap : derpMap ,
645
+ Logger : a .logger .Named ("tailnet" ),
646
+ ListenPort : a .tailnetListenPort ,
647
+ BlockEndpoints : disableDirectConnections ,
646
648
})
647
649
if err != nil {
648
650
return nil , xerrors .Errorf ("create tailnet: %w" , err )
0 commit comments