Pull request 1948: imp-test
Squashed commit of the following: commit d2e61b0a2406a503d9d7bcd12612ed7e04c1fac6 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Aug 1 18:02:29 2023 +0300 client: imp addrproc test commit f7cf0fb1549299b00fdbe400bb4a96c73530bfe0 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Aug 1 17:23:12 2023 +0300 dnsforward: rm mutex
This commit is contained in:
@@ -58,6 +58,12 @@ type DefaultAddrProcConfig struct {
|
||||
// immediately by [NewDefaultAddrProc].
|
||||
InitialAddresses []netip.Addr
|
||||
|
||||
// CatchPanics, if true, makes the address processor catch and log panics.
|
||||
//
|
||||
// TODO(a.garipov): Consider better ways to do this or apply this method to
|
||||
// other parts of the codebase.
|
||||
CatchPanics bool
|
||||
|
||||
// UseRDNS, if true, enables resolving of client IP addresses using reverse
|
||||
// DNS.
|
||||
UseRDNS bool
|
||||
@@ -151,7 +157,7 @@ func NewDefaultAddrProc(c *DefaultAddrProcConfig) (p *DefaultAddrProc) {
|
||||
p.whois = newWHOIS(c.DialContext)
|
||||
}
|
||||
|
||||
go p.process()
|
||||
go p.process(c.CatchPanics)
|
||||
|
||||
for _, ip := range c.InitialAddresses {
|
||||
p.Process(ip)
|
||||
@@ -214,8 +220,10 @@ func (p *DefaultAddrProc) Process(ip netip.Addr) {
|
||||
|
||||
// process processes the incoming client IP-address information. It is intended
|
||||
// to be used as a goroutine. Once clientIPs is closed, process exits.
|
||||
func (p *DefaultAddrProc) process() {
|
||||
defer log.OnPanic("addrProcessor.process")
|
||||
func (p *DefaultAddrProc) process(catchPanics bool) {
|
||||
if catchPanics {
|
||||
defer log.OnPanic("addrProcessor.process")
|
||||
}
|
||||
|
||||
log.Info("clients: processing addresses")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user