func walkTargets()

in config/config.go [582:610]


func walkTargets(grc *RemoteConfig, ts []target, ext bool, remotes RemoteStore, logger *log.Logger) {

	for _, t := range ts {
		if grc.ResolveDNS && t.HostName != "" {
			addrs, err := net.LookupHost(t.HostName)
			if err != nil {
				logger.Error("failed to DNS resolve hostname", zap.Error(err))
				continue
			}
			t.IP = addrs[0]
		}

		// Validate address string
		currIP := net.ParseIP(t.IP)
		if currIP == nil {
			logger.Error("configuration file parse error",
				zap.String("err", "invalid IP address for host %s"),
				zap.String("hostname", t.HostName))
		}
		if currIP.Equal(grc.SrcAddress) {
			logger.Debug("Local server's address not added in remote target list",
				zap.String("JSON_source_address", grc.SrcAddress.String()),
				zap.String("target", currIP.String()))
			continue
		}
		remotes[currIP.String()] = Remote{currIP, network.Family(&currIP),
			t.HostName, t.Location, ext}
	}
}