all: another rework on discovering bootstrap IPs

Instead of re-query DNS record for upstream when re-bootstrapping, just
query all records on startup, then selecting the next bootstrap ip
depends on the current network stack.
This commit is contained in:
Cuong Manh Le
2023-03-08 11:38:46 +07:00
committed by Cuong Manh Le
parent 018f6651c1
commit fa50cd4df4
3 changed files with 108 additions and 76 deletions

View File

@@ -64,10 +64,12 @@ func (p *prog) run() {
for n := range p.cfg.Upstream {
uc := p.cfg.Upstream[n]
uc.Init()
if err := uc.SetupBootstrapIP(); err != nil {
mainLog.Fatal().Err(err).Msgf("failed to setup bootstrap IP for upstream.%s", n)
if uc.BootstrapIP == "" {
uc.SetupBootstrapIP()
mainLog.Info().Str("bootstrap_ip", uc.BootstrapIP).Msgf("Setting bootstrap IP for upstream.%s", n)
} else {
mainLog.Info().Str("bootstrap_ip", uc.BootstrapIP).Msgf("Using bootstrap IP for upstream.%s", n)
}
mainLog.Info().Str("bootstrap_ip", uc.BootstrapIP).Msgf("Setting bootstrap IP for upstream.%s", n)
uc.SetupTransport()
}