MCPcopy Index your code
hub / github.com/coder/coder / reconfig

Method reconfig

tailnet/configmaps.go:345–373  ·  view source on GitHub ↗

reconfig computes the correct wireguard config and calls the engine.Reconfig with the config we have. It is not intended for this to be called outside of the updateLoop()

(nm *netmap.NetworkMap, hosts map[dnsname.FQDN][]netip.Addr)

Source from the content-addressed store, hash-verified

343// with the config we have. It is not intended for this to be called outside of
344// the updateLoop()
345func (c *configMaps) reconfig(nm *netmap.NetworkMap, hosts map[dnsname.FQDN][]netip.Addr) {
346 dnsCfg := &dns.Config{}
347 if len(hosts) > 0 {
348 dnsCfg.Hosts = hosts
349 dnsCfg.OnlyIPv6 = true
350 dnsCfg.Routes = map[dnsname.FQDN][]*dnstype.Resolver{
351 c.matchDomain: nil,
352 }
353 }
354 cfg, err := nmcfg.WGCfg(nm, Logger(c.logger.Named("net.wgconfig")), netmap.AllowSingleHosts, "")
355 if err != nil {
356 // WGCfg never returns an error at the time this code was written. If it starts, returning
357 // errors if/when we upgrade tailscale, we'll need to deal.
358 c.logger.Critical(context.Background(), "update wireguard config failed", slog.Error(err))
359 return
360 }
361
362 rc := &router.Config{
363 LocalAddrs: nm.Addresses,
364 Routes: []netip.Prefix{CoderServicePrefix.AsNetip()},
365 }
366 err = c.engine.Reconfig(cfg, rc, dnsCfg, &tailcfg.Debug{})
367 if err != nil {
368 if errors.Is(err, wgengine.ErrNoChanges) {
369 return
370 }
371 c.logger.Error(context.Background(), "failed to reconfigure wireguard engine", slog.Error(err))
372 }
373}
374
375// filterLocked returns the current filter, based on our local addresses. c.L
376// must be held.

Callers 1

configLoopMethod · 0.95

Calls 6

NamedMethod · 0.80
AsNetipMethod · 0.80
LoggerFunction · 0.70
ReconfigMethod · 0.65
ErrorMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected