diff --git a/internal/whois/whois.go b/internal/whois/whois.go index e55bcaf7..2a64bdd1 100644 --- a/internal/whois/whois.go +++ b/internal/whois/whois.go @@ -288,6 +288,16 @@ func (w *Default) Process(ctx context.Context, ip netip.Addr) (wi *Info, changed return wi, false } + return w.requestInfo(ctx, ip, wi) +} + +// requestInfo makes WHOIS request and returns WHOIS info. changed is false if +// received information is equal to cached. +func (w *Default) requestInfo( + ctx context.Context, + ip netip.Addr, + cached *Info, +) (wi *Info, changed bool) { var info Info defer func() { @@ -311,12 +321,14 @@ func (w *Default) Process(ctx context.Context, ip netip.Addr) (wi *Info, changed Orgname: kv["orgname"], } + changed = cached == nil || info != *cached + // Don't return an empty struct so that the frontend doesn't get confused. if (info == Info{}) { - return nil, true + return nil, changed } - return &info, wi == nil || info != *wi + return &info, changed } // findInCache finds Info in the cache. expired indicates that Info is valid. diff --git a/scripts/make/go-lint.sh b/scripts/make/go-lint.sh index 09cf981f..3409ed2b 100644 --- a/scripts/make/go-lint.sh +++ b/scripts/make/go-lint.sh @@ -176,9 +176,10 @@ run_linter gocognit --over 10\ ./internal/aghchan/\ ./internal/aghhttp/\ ./internal/aghio/\ - ./internal/tools/\ ./internal/next/\ + ./internal/tools/\ ./internal/version/\ + ./internal/whois/\ ; run_linter ineffassign ./...