quality / commitlint (push) Skipped
quality / changes (push) Successful in 9s
quality / docker-check (push) Skipped
quality / openapi (push) Successful in 46s
quality / web (push) Successful in 1m16s
quality / go (push) Successful in 2m42s
quality / bird2 (push) Successful in 16s
CD / quality (push) Successful in 5m19s
CD / publish (push) Successful in 7m19s
- Deleted unused components: `DashboardActivityTimeline`, `DashboardFramePanel`, `DashboardModulesGrid`, `DashboardRecentJobsGrid`, and `DashboardRecentRevisionsGrid` to streamline the dashboard. - Updated `DashboardKpiGrid` to improve KPI display logic, including progress indicators and enhanced badge functionality. - Refactored `DashboardNetworkHealth` to provide better status representation based on loading states and network conditions. - Introduced new properties for KPI cards to support progress tracking and improved visual feedback. This cleanup aims to enhance performance and maintainability of the dashboard while providing a better user experience.
68 lines
1.5 KiB
Go
68 lines
1.5 KiB
Go
package pipeline
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"net/netip"
|
|
"os"
|
|
"strconv"
|
|
"strings"
|
|
"time"
|
|
|
|
"evobgp/internal/store"
|
|
)
|
|
|
|
func domainCacheTTL() time.Duration {
|
|
sec := 300
|
|
if s := strings.TrimSpace(os.Getenv("EVOBGP_DOMAIN_CACHE_TTL_SEC")); s != "" {
|
|
if v, err := strconv.Atoi(s); err == nil && v > 0 {
|
|
sec = v
|
|
}
|
|
}
|
|
return time.Duration(sec) * time.Second
|
|
}
|
|
|
|
func resolveDomainIPsCached(ctx context.Context, st store.Backend, hc *http.Client, profiles []*store.DohProfile, policy, fqdn string) ([]netip.Addr, error) {
|
|
key := strings.TrimSpace(fqdn)
|
|
ttl := domainCacheTTL()
|
|
if st != nil && ttl > 0 {
|
|
if ent, ok, err := st.GetDomainResolveCache(key); err == nil && ok && ent != nil {
|
|
if time.Since(ent.ResolvedAt) < ttl {
|
|
if addrs := parseCachedDomainAddrs(ent.Addrs); len(addrs) > 0 {
|
|
return addrs, nil
|
|
}
|
|
}
|
|
}
|
|
}
|
|
addrs, err := resolveDomainIPsWithPolicy(ctx, hc, profiles, policy, key)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if st != nil {
|
|
_ = st.SetDomainResolveCache(key, domainAddrsToStrings(addrs))
|
|
}
|
|
return addrs, nil
|
|
}
|
|
|
|
func parseCachedDomainAddrs(raw []string) []netip.Addr {
|
|
out := make([]netip.Addr, 0, len(raw))
|
|
for _, s := range raw {
|
|
a, err := netip.ParseAddr(strings.TrimSpace(s))
|
|
if err != nil {
|
|
continue
|
|
}
|
|
out = append(out, a)
|
|
}
|
|
return out
|
|
}
|
|
|
|
func domainAddrsToStrings(addrs []netip.Addr) []string {
|
|
out := make([]string, 0, len(addrs))
|
|
for _, a := range addrs {
|
|
if a.IsValid() {
|
|
out = append(out, a.String())
|
|
}
|
|
}
|
|
return out
|
|
}
|