Pull request 1898: fix-whois-gocognit
Squashed commit of the following:
commit 69675b742a3b8a1d513f1b5f9c488577ced329b8
Merge: 0d069b769 ee8eb1d8a
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Thu Jun 29 19:31:26 2023 +0300
Merge branch 'master' into fix-whois-gocognit
commit 0d069b76938d9b3011b8d92865e7630027f1ebd1
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Thu Jun 29 19:21:02 2023 +0300
whois: imp code more
commit 6c4ab4a4e0451551bcec5472d997a88989f013e4
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Thu Jun 29 18:08:50 2023 +0300
whois: imp code
commit 0d04ddbd6f8bb3848673c3f86fc26dca2fd4d402
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Thu Jun 29 17:47:06 2023 +0300
whois: imp docs
commit d7b75f7b42604374cb8cb0aaf141eb5c7fc985d3
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date: Thu Jun 29 16:54:49 2023 +0300
all: imp code
This commit is contained in:
parent
ee8eb1d8a6
commit
ad1bf5cf6e
|
@ -288,6 +288,16 @@ func (w *Default) Process(ctx context.Context, ip netip.Addr) (wi *Info, changed
|
||||||
return wi, false
|
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
|
var info Info
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -311,12 +321,14 @@ func (w *Default) Process(ctx context.Context, ip netip.Addr) (wi *Info, changed
|
||||||
Orgname: kv["orgname"],
|
Orgname: kv["orgname"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
changed = cached == nil || info != *cached
|
||||||
|
|
||||||
// Don't return an empty struct so that the frontend doesn't get confused.
|
// Don't return an empty struct so that the frontend doesn't get confused.
|
||||||
if (info == Info{}) {
|
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.
|
// findInCache finds Info in the cache. expired indicates that Info is valid.
|
||||||
|
|
|
@ -176,9 +176,10 @@ run_linter gocognit --over 10\
|
||||||
./internal/aghchan/\
|
./internal/aghchan/\
|
||||||
./internal/aghhttp/\
|
./internal/aghhttp/\
|
||||||
./internal/aghio/\
|
./internal/aghio/\
|
||||||
./internal/tools/\
|
|
||||||
./internal/next/\
|
./internal/next/\
|
||||||
|
./internal/tools/\
|
||||||
./internal/version/\
|
./internal/version/\
|
||||||
|
./internal/whois/\
|
||||||
;
|
;
|
||||||
|
|
||||||
run_linter ineffassign ./...
|
run_linter ineffassign ./...
|
||||||
|
|
Loading…
Reference in New Issue