Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion core/nylon.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ type Nylon struct {
DispatchChannel chan func() error
Log *slog.Logger
ConfigPath string
configFetcher *configFetcher
configPollDelay atomic.Int64

// resources
Tun tun.Device
Expand Down Expand Up @@ -156,6 +158,8 @@ func NewNylon(ccfg state.CentralCfg, ncfg state.LocalCfg, logLevel slog.Level, c
DNSResolver: dnsResolver,
EndpointResolver: state.NewEndpointResolver(dnsResolver),
}
n.configFetcher = newConfigFetcher(dnsResolver)
n.updateConfigPollDelay(&n.CentralCfg)

n.Log.Info("init modules")

Expand Down Expand Up @@ -245,7 +249,10 @@ func (n *Nylon) Init() error {
for _, repo := range n.CentralCfg.Dist.Repos {
n.Log.Info("config source", "repo", repo)
}
n.RepeatTask(func() error { return checkForConfigUpdates(n) }, n.CentralUpdateDelay)
n.RepeatTaskDynamic(
func() error { return checkForConfigUpdates(n) },
func() time.Duration { return time.Duration(n.configPollDelay.Load()) },
)
}
return nil
}
Expand Down Expand Up @@ -330,6 +337,9 @@ func (n *Nylon) Cleanup() error {
if n.observability != nil {
n.observability.close()
}
if n.configFetcher != nil {
n.configFetcher.client.CloseIdleConnections()
}
n.PingBuf.Stop()
for _, health := range n.prefixHealth {
health.monitor.Stop()
Expand Down
1 change: 1 addition & 0 deletions core/nylon_apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func (n *Nylon) ApplyCentralConfig(cfg *state.CentralCfg) (ApplyResult, error) {
}
n.reconcileAdvertisedPrefixes(candidate)
n.CentralCfg = *candidate
n.updateConfigPollDelay(candidate)

// From here on the candidate is the accepted desired state. Failures while
// converging WireGuard or OS state are retryable and must not describe the
Expand Down
Loading
Loading